sdr_view_components 0.8.1 → 0.9.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 +4 -4
- data/app/components/component_support/button_support.rb +2 -1
- data/app/components/sdr_view_components/elements/button_component.rb +3 -2
- data/app/components/sdr_view_components/elements/button_form_component.rb +3 -2
- data/app/components/sdr_view_components/elements/button_link_component.rb +5 -2
- data/app/components/sdr_view_components/elements/icon_button_component.html.erb +1 -1
- data/app/components/sdr_view_components/elements/icon_button_component.rb +3 -2
- data/app/components/sdr_view_components/elements/icon_button_link_component.html.erb +1 -1
- data/app/components/sdr_view_components/elements/icon_button_link_component.rb +3 -2
- data/lib/sdr_view_components/version.rb +1 -1
- data/spec/components/previews/sdr_view_components/elements/button_component_preview.rb +12 -0
- data/spec/components/previews/sdr_view_components/elements/button_form_component_preview.rb +20 -0
- data/spec/components/previews/sdr_view_components/elements/button_link_component_preview.rb +12 -0
- data/spec/components/previews/sdr_view_components/elements/icon_button_component_preview.rb +12 -0
- data/spec/components/previews/sdr_view_components/elements/icon_button_link_component_preview.rb +20 -0
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 85d60c2eba6ecbc0fde6f7a234479c1bc8f4ff03e20cd06d59c765e0753f9f4e
|
|
4
|
+
data.tar.gz: 3f3f9cad04f4282acdaa1db74aa11af206b390eb1cf4d2f2e63750fecea6846b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: eb8f72e8174004db2949286a2447f52587a14fefc08a4eb577336594795f1156b671a97be9d0af2bd1e46cca6e83590721b115b42a1fb8fdb25974e7dd92e564
|
|
7
|
+
data.tar.gz: 43324da6a0cbecf28cf5b8fc0f8fa287b4debdb243ee6593b5b1d3510efc06de7c80760623c91a0ea5fb2265d4868dca4527016de6158293bc12de2543e8af4f
|
|
@@ -3,11 +3,12 @@
|
|
|
3
3
|
module ComponentSupport
|
|
4
4
|
# General support for buttons.
|
|
5
5
|
class ButtonSupport
|
|
6
|
-
def self.classes(variant: nil, size: nil, classes: [], bordered: true)
|
|
6
|
+
def self.classes(variant: nil, size: nil, classes: [], bordered: true, disabled: false)
|
|
7
7
|
ComponentSupport::CssClasses.merge('btn',
|
|
8
8
|
variant ? "btn-#{variant}" : nil,
|
|
9
9
|
size ? "btn-#{size}" : nil,
|
|
10
10
|
bordered ? nil : %w[border border-0],
|
|
11
|
+
disabled ? 'disabled' : nil,
|
|
11
12
|
classes)
|
|
12
13
|
end
|
|
13
14
|
end
|
|
@@ -4,13 +4,14 @@ module SdrViewComponents
|
|
|
4
4
|
module Elements
|
|
5
5
|
# Generic button component
|
|
6
6
|
class ButtonComponent < BaseComponent
|
|
7
|
-
def initialize(label: nil, classes: [], variant: nil, size: nil, bordered: true, **options) # rubocop:disable Metrics/ParameterLists
|
|
7
|
+
def initialize(label: nil, classes: [], variant: nil, size: nil, bordered: true, disabled: false, **options) # rubocop:disable Metrics/ParameterLists
|
|
8
8
|
@label = label
|
|
9
9
|
@classes = classes
|
|
10
10
|
@variant = variant
|
|
11
11
|
@size = size
|
|
12
12
|
@options = options
|
|
13
13
|
@bordered = bordered
|
|
14
|
+
@disabled = disabled
|
|
14
15
|
super()
|
|
15
16
|
end
|
|
16
17
|
|
|
@@ -19,7 +20,7 @@ module SdrViewComponents
|
|
|
19
20
|
def call
|
|
20
21
|
tag.button(
|
|
21
22
|
class: ComponentSupport::ButtonSupport.classes(variant: @variant, size: @size, classes: @classes,
|
|
22
|
-
bordered: @bordered),
|
|
23
|
+
bordered: @bordered, disabled: @disabled),
|
|
23
24
|
type: 'button',
|
|
24
25
|
**options
|
|
25
26
|
) do
|
|
@@ -5,7 +5,7 @@ module SdrViewComponents
|
|
|
5
5
|
# Component for a button that is wrapped in a form
|
|
6
6
|
class ButtonFormComponent < BaseComponent
|
|
7
7
|
def initialize(link:, label: nil, variant: :primary, classes: [], method: :get, confirm: nil, # rubocop:disable Metrics/ParameterLists
|
|
8
|
-
top: true, data: {})
|
|
8
|
+
top: true, data: {}, disabled: false)
|
|
9
9
|
@link = link
|
|
10
10
|
@label = label
|
|
11
11
|
@variant = variant
|
|
@@ -14,6 +14,7 @@ module SdrViewComponents
|
|
|
14
14
|
@confirm = confirm
|
|
15
15
|
@top = top
|
|
16
16
|
@data = data
|
|
17
|
+
@disabled = disabled
|
|
17
18
|
super()
|
|
18
19
|
end
|
|
19
20
|
|
|
@@ -21,7 +22,7 @@ module SdrViewComponents
|
|
|
21
22
|
|
|
22
23
|
def call
|
|
23
24
|
button_to(link, method: @method,
|
|
24
|
-
class: ComponentSupport::ButtonSupport.classes(variant: @variant, classes:),
|
|
25
|
+
class: ComponentSupport::ButtonSupport.classes(variant: @variant, classes:, disabled: @disabled),
|
|
25
26
|
form: { data: }) do
|
|
26
27
|
@label || content
|
|
27
28
|
end
|
|
@@ -4,7 +4,8 @@ module SdrViewComponents
|
|
|
4
4
|
module Elements
|
|
5
5
|
# Component for a button that is a link
|
|
6
6
|
class ButtonLinkComponent < BaseComponent
|
|
7
|
-
def initialize(link:, label: nil, variant: :primary, classes: [], bordered: true, size: nil,
|
|
7
|
+
def initialize(link:, label: nil, variant: :primary, classes: [], bordered: true, size: nil, # rubocop:disable Metrics/ParameterLists
|
|
8
|
+
disabled: false, **options)
|
|
8
9
|
@link = link
|
|
9
10
|
@label = label
|
|
10
11
|
@variant = variant
|
|
@@ -12,6 +13,7 @@ module SdrViewComponents
|
|
|
12
13
|
@classes = classes
|
|
13
14
|
@bordered = bordered
|
|
14
15
|
@size = size
|
|
16
|
+
@disabled = disabled
|
|
15
17
|
super()
|
|
16
18
|
end
|
|
17
19
|
|
|
@@ -19,7 +21,8 @@ module SdrViewComponents
|
|
|
19
21
|
|
|
20
22
|
def call
|
|
21
23
|
link_to(link, class: ComponentSupport::ButtonSupport.classes(classes: @classes, variant: @variant,
|
|
22
|
-
bordered: @bordered, size: @size
|
|
24
|
+
bordered: @bordered, size: @size,
|
|
25
|
+
disabled: @disabled),
|
|
23
26
|
**@options) do
|
|
24
27
|
label || content
|
|
25
28
|
end
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
<%= render SdrViewComponents::Elements::ButtonComponent.new(classes:, variant: :'outline-primary', **options) do %>
|
|
1
|
+
<%= render SdrViewComponents::Elements::ButtonComponent.new(classes:, variant: :'outline-primary', disabled:, **options) do %>
|
|
2
2
|
<%= button_icon %><span class="visually-hidden"><%= label %></span>
|
|
3
3
|
<% end %>
|
|
@@ -4,10 +4,11 @@ module SdrViewComponents
|
|
|
4
4
|
module Elements
|
|
5
5
|
# Component for a button which is an icon
|
|
6
6
|
class IconButtonComponent < BaseComponent
|
|
7
|
-
def initialize(icon:, label:, classes: [], **options)
|
|
7
|
+
def initialize(icon:, label:, classes: [], disabled: false, **options)
|
|
8
8
|
@icon = icon
|
|
9
9
|
@label = label
|
|
10
10
|
@classes = classes
|
|
11
|
+
@disabled = disabled
|
|
11
12
|
@options = options
|
|
12
13
|
super()
|
|
13
14
|
end
|
|
@@ -16,7 +17,7 @@ module SdrViewComponents
|
|
|
16
17
|
raise SdrViewComponents::Error::UnknownComponentIcon, "Unknown icon type: #{@icon}" unless button_icon?
|
|
17
18
|
end
|
|
18
19
|
|
|
19
|
-
attr_reader :label, :options
|
|
20
|
+
attr_reader :label, :options, :disabled
|
|
20
21
|
|
|
21
22
|
def classes
|
|
22
23
|
merge_classes(%w[border border-0], @classes)
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
<%= render SdrViewComponents::Elements::ButtonLinkComponent.new(classes:, variant: :'outline-primary', link:, **options) do %>
|
|
1
|
+
<%= render SdrViewComponents::Elements::ButtonLinkComponent.new(classes:, variant: :'outline-primary', link:, disabled:, **options) do %>
|
|
2
2
|
<%= button_icon %><span class="visually-hidden"><%= label %></span>
|
|
3
3
|
<% end %>
|
|
@@ -4,17 +4,18 @@ module SdrViewComponents
|
|
|
4
4
|
module Elements
|
|
5
5
|
# Component for a button which is an icon
|
|
6
6
|
class IconButtonLinkComponent < BaseComponent
|
|
7
|
-
def initialize(icon:, label:, classes: [], icon_classes: [], link: nil, **options) # rubocop:disable Metrics/ParameterLists
|
|
7
|
+
def initialize(icon:, label:, classes: [], icon_classes: [], link: nil, disabled: false, **options) # rubocop:disable Metrics/ParameterLists
|
|
8
8
|
@icon = icon
|
|
9
9
|
@label = label
|
|
10
10
|
@classes = classes
|
|
11
11
|
@link = link
|
|
12
12
|
@options = options
|
|
13
13
|
@icon_classes = icon_classes
|
|
14
|
+
@disabled = disabled
|
|
14
15
|
super()
|
|
15
16
|
end
|
|
16
17
|
|
|
17
|
-
attr_reader :label, :link, :options
|
|
18
|
+
attr_reader :label, :link, :options, :disabled
|
|
18
19
|
|
|
19
20
|
def classes
|
|
20
21
|
merge_classes(%w[border border-0], @classes)
|
|
@@ -63,6 +63,18 @@ module SdrViewComponents
|
|
|
63
63
|
end
|
|
64
64
|
# @!endgroup
|
|
65
65
|
|
|
66
|
+
# @!group Disabled State
|
|
67
|
+
def enabled
|
|
68
|
+
render SdrViewComponents::Elements::ButtonComponent.new(label: 'Enabled Button', variant: 'primary',
|
|
69
|
+
disabled: false)
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
def disabled
|
|
73
|
+
render SdrViewComponents::Elements::ButtonComponent.new(label: 'Disabled Button', variant: 'primary',
|
|
74
|
+
disabled: true)
|
|
75
|
+
end
|
|
76
|
+
# @!endgroup
|
|
77
|
+
|
|
66
78
|
def default
|
|
67
79
|
render SdrViewComponents::Elements::ButtonComponent.new(label: 'Default Button')
|
|
68
80
|
end
|
|
@@ -89,6 +89,26 @@ module SdrViewComponents
|
|
|
89
89
|
end
|
|
90
90
|
# @!endgroup
|
|
91
91
|
|
|
92
|
+
# @!group Disabled State
|
|
93
|
+
def enabled
|
|
94
|
+
render SdrViewComponents::Elements::ButtonFormComponent.new(
|
|
95
|
+
link: '/action',
|
|
96
|
+
label: 'Enabled Button',
|
|
97
|
+
variant: :primary,
|
|
98
|
+
disabled: false
|
|
99
|
+
)
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
def disabled
|
|
103
|
+
render SdrViewComponents::Elements::ButtonFormComponent.new(
|
|
104
|
+
link: '/action',
|
|
105
|
+
label: 'Disabled Button',
|
|
106
|
+
variant: :primary,
|
|
107
|
+
disabled: true
|
|
108
|
+
)
|
|
109
|
+
end
|
|
110
|
+
# @!endgroup
|
|
111
|
+
|
|
92
112
|
def default
|
|
93
113
|
render SdrViewComponents::Elements::ButtonFormComponent.new(link: '/', label: 'Form Button')
|
|
94
114
|
end
|
|
@@ -79,6 +79,18 @@ module SdrViewComponents
|
|
|
79
79
|
end
|
|
80
80
|
# @!endgroup
|
|
81
81
|
|
|
82
|
+
# @!group Disabled State
|
|
83
|
+
def enabled
|
|
84
|
+
render SdrViewComponents::Elements::ButtonLinkComponent.new(link: '/example', label: 'Enabled Link Button',
|
|
85
|
+
variant: :primary, disabled: false)
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
def disabled
|
|
89
|
+
render SdrViewComponents::Elements::ButtonLinkComponent.new(link: '/example', label: 'Disabled Link Button',
|
|
90
|
+
variant: :primary, disabled: true)
|
|
91
|
+
end
|
|
92
|
+
# @!endgroup
|
|
93
|
+
|
|
82
94
|
def default
|
|
83
95
|
render SdrViewComponents::Elements::ButtonLinkComponent.new(link: '/example', label: 'Default Link Button')
|
|
84
96
|
end
|
|
@@ -12,6 +12,18 @@ module SdrViewComponents
|
|
|
12
12
|
render SdrViewComponents::Elements::IconButtonComponent.new(icon: :download, label: 'Download file')
|
|
13
13
|
end
|
|
14
14
|
# @!endgroup
|
|
15
|
+
|
|
16
|
+
# @!group Disabled State
|
|
17
|
+
def enabled
|
|
18
|
+
render SdrViewComponents::Elements::IconButtonComponent.new(icon: :delete, label: 'Delete item',
|
|
19
|
+
disabled: false)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def disabled
|
|
23
|
+
render SdrViewComponents::Elements::IconButtonComponent.new(icon: :delete, label: 'Delete item',
|
|
24
|
+
disabled: true)
|
|
25
|
+
end
|
|
26
|
+
# @!endgroup
|
|
15
27
|
end
|
|
16
28
|
end
|
|
17
29
|
end
|
data/spec/components/previews/sdr_view_components/elements/icon_button_link_component_preview.rb
CHANGED
|
@@ -10,6 +10,26 @@ module SdrViewComponents
|
|
|
10
10
|
link: '/example'
|
|
11
11
|
)
|
|
12
12
|
end
|
|
13
|
+
|
|
14
|
+
# @!group Disabled State
|
|
15
|
+
def enabled
|
|
16
|
+
render SdrViewComponents::Elements::IconButtonLinkComponent.new(
|
|
17
|
+
icon: :download,
|
|
18
|
+
label: 'Download item',
|
|
19
|
+
link: '/example',
|
|
20
|
+
disabled: false
|
|
21
|
+
)
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def disabled
|
|
25
|
+
render SdrViewComponents::Elements::IconButtonLinkComponent.new(
|
|
26
|
+
icon: :download,
|
|
27
|
+
label: 'Download item',
|
|
28
|
+
link: '/example',
|
|
29
|
+
disabled: true
|
|
30
|
+
)
|
|
31
|
+
end
|
|
32
|
+
# @!endgroup
|
|
13
33
|
end
|
|
14
34
|
end
|
|
15
35
|
end
|
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.
|
|
4
|
+
version: 0.9.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Aaron Collier
|
|
@@ -373,7 +373,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
373
373
|
- !ruby/object:Gem::Version
|
|
374
374
|
version: '0'
|
|
375
375
|
requirements: []
|
|
376
|
-
rubygems_version: 4.0.
|
|
376
|
+
rubygems_version: 4.0.6
|
|
377
377
|
specification_version: 4
|
|
378
378
|
summary: Rails gem for providing SDR-specific ViewComponents.
|
|
379
379
|
test_files: []
|