sdr_view_components 0.13.0 → 0.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a345126e4b1ae936afb830c142944b842691edbf460fd2092136905f4035a1b2
4
- data.tar.gz: 4dcce16061ff42a6d46fc74fa91b432b60298fb96aa22860ed752d43c09aefa1
3
+ metadata.gz: 0e5e2f0083c7b5a245f3276e52280e0be507a5db14ee7484cef0c892c67413fa
4
+ data.tar.gz: a703231a7e71fcd77da8cedbdebe0b58d7d99a966e60ed3557ee314daf112a10
5
5
  SHA512:
6
- metadata.gz: d1e085e557f9a045c2915b8f944db1ebac286fd6245e6e22b80202bf1ee87cbe1efc2e74f0c2f9650959c9ea40a35c63049d6085a67e9a9485fc623b1bad90e3
7
- data.tar.gz: 1ebaa46555633944bbe4a301193fde11929668392dad3457559991ca0d279774f0a0e56b0ce3dda08f34690db49d6cd13054e8a057fc8e3796a1fbb40725382b
6
+ metadata.gz: fd3178e40c6b438f3a76f991fba019cb7739065f10a73e1f1585e244425ca7188eac9e81ddf03b9c2aa068f16009f46209298f2e11511ec2c5c8f0325647d6a2
7
+ data.tar.gz: 37cd0b6f501476cd949fe1cef03370a000869e8440e1b55e18fd23b2f74c3ab0aedbd82dd752807a7a5f08d60a4effc4111292aeab2900ff240d7c8afe4de67e
@@ -4,11 +4,12 @@ module SdrViewComponents
4
4
  module Elements
5
5
  # Component for a button that is wrapped in a form
6
6
  class ButtonFormComponent < BaseComponent
7
- def initialize(link:, label: nil, variant: :primary, classes: [], method: :get, confirm: nil, # rubocop:disable Metrics/ParameterLists, Metrics/MethodLength
7
+ def initialize(link:, label: nil, variant: :primary, size: nil, classes: [], method: :get, confirm: nil, # rubocop:disable Metrics/ParameterLists, Metrics/MethodLength
8
8
  top: true, data: {}, disabled: false, params: {})
9
9
  @link = link
10
10
  @label = label
11
11
  @variant = variant
12
+ @size = size
12
13
  @classes = classes
13
14
  @method = method
14
15
  @confirm = confirm
@@ -23,7 +24,10 @@ module SdrViewComponents
23
24
 
24
25
  def call
25
26
  button_to(link, method: @method,
26
- class: ComponentSupport::ButtonSupport.classes(variant: @variant, classes:, disabled: @disabled),
27
+ class: ComponentSupport::ButtonSupport.classes(variant: @variant, size: @size, classes:,
28
+ disabled: @disabled),
29
+ # The class only styles the button; the attribute keeps it from submitting the form.
30
+ disabled: @disabled,
27
31
  form: { data: },
28
32
  params:) do
29
33
  @label || content
@@ -4,12 +4,13 @@ module SdrViewComponents
4
4
  module Elements
5
5
  # Component for a button which is an icon and is wrapped in a form
6
6
  class IconButtonFormComponent < BaseComponent
7
- def initialize(link:, icon:, label:, variant: :'outline-primary', classes: [], icon_classes: [], method: :get, # rubocop:disable Metrics/ParameterLists, Metrics/MethodLength
8
- confirm: nil, top: true, data: {}, disabled: false, params: {})
7
+ def initialize(link:, icon:, label:, variant: :'outline-primary', size: nil, classes: [], icon_classes: [], # rubocop:disable Metrics/ParameterLists, Metrics/MethodLength
8
+ method: :get, confirm: nil, top: true, data: {}, disabled: false, params: {})
9
9
  @link = link
10
10
  @icon = icon
11
11
  @label = label
12
12
  @variant = variant
13
+ @size = size
13
14
  @classes = classes
14
15
  @icon_classes = icon_classes
15
16
  @method = method
@@ -29,7 +30,10 @@ module SdrViewComponents
29
30
 
30
31
  def call
31
32
  button_to(link, method: @method,
32
- class: ComponentSupport::ButtonSupport.classes(variant: @variant, classes:, disabled: @disabled),
33
+ class: ComponentSupport::ButtonSupport.classes(variant: @variant, size: @size, classes:,
34
+ disabled: @disabled),
35
+ # The class only styles the button; the attribute keeps it from submitting the form.
36
+ disabled: @disabled,
33
37
  form: { data: },
34
38
  params:) do
35
39
  concat button_icon
@@ -37,9 +37,11 @@ module SdrViewComponents
37
37
  end
38
38
 
39
39
  def spinner_style
40
- return unless @height && @width
41
-
42
- "height: #{@height}px; width: #{@width}px; --bs-spinner-animation-speed: #{@speed}s;"
40
+ [
41
+ ("height: #{@height}px;" if @height),
42
+ ("width: #{@width}px;" if @width),
43
+ "--bs-spinner-animation-speed: #{@speed}s;"
44
+ ].compact.join(' ')
43
45
  end
44
46
 
45
47
  private
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SdrViewComponents
4
- VERSION = '0.13.0'
4
+ VERSION = '0.15.0'
5
5
  end
@@ -34,6 +34,16 @@ module SdrViewComponents
34
34
  end
35
35
  # @!endgroup
36
36
 
37
+ # @!group Button Sizes
38
+ def small
39
+ render SdrViewComponents::Elements::ButtonFormComponent.new(link: '/action', label: 'Small Button', size: 'sm')
40
+ end
41
+
42
+ def large
43
+ render SdrViewComponents::Elements::ButtonFormComponent.new(link: '/action', label: 'Large Button', size: 'lg')
44
+ end
45
+ # @!endgroup
46
+
37
47
  # @!group With Confirmation
38
48
  def with_confirmation
39
49
  render SdrViewComponents::Elements::ButtonFormComponent.new(
@@ -18,6 +18,18 @@ module SdrViewComponents
18
18
  )
19
19
  end
20
20
 
21
+ # @!group Button Sizes
22
+ def small
23
+ render SdrViewComponents::Elements::IconButtonFormComponent.new(link: '/example', icon: :download,
24
+ label: 'Download item', size: :sm)
25
+ end
26
+
27
+ def large
28
+ render SdrViewComponents::Elements::IconButtonFormComponent.new(link: '/example', icon: :download,
29
+ label: 'Download item', size: :lg)
30
+ end
31
+ # @!endgroup
32
+
21
33
  # @!group Disabled State
22
34
  def enabled
23
35
  render SdrViewComponents::Elements::IconButtonFormComponent.new(link: '/example', icon: :download,
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sdr_view_components
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.13.0
4
+ version: 0.15.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aaron Collier
@@ -378,7 +378,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
378
378
  - !ruby/object:Gem::Version
379
379
  version: '0'
380
380
  requirements: []
381
- rubygems_version: 4.0.6
381
+ rubygems_version: 4.0.20
382
382
  specification_version: 4
383
383
  summary: Rails gem for providing SDR-specific ViewComponents.
384
384
  test_files: []