primer_view_components 0.0.49 → 0.0.53
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/CHANGELOG.md +158 -0
- data/app/components/primer/base_component.rb +2 -2
- data/app/components/primer/beta/avatar_stack.rb +9 -9
- data/app/components/primer/beta/truncate.html.erb +5 -0
- data/app/components/primer/beta/truncate.rb +110 -0
- data/app/components/primer/border_box_component.rb +27 -1
- data/app/components/primer/clipboard_copy.html.erb +2 -2
- data/app/components/primer/clipboard_copy.rb +1 -1
- data/app/components/primer/dropdown.rb +7 -7
- data/app/components/primer/icon_button.rb +1 -1
- data/app/components/primer/label_component.rb +13 -12
- data/app/components/primer/navigation/tab_component.rb +1 -1
- data/app/components/primer/progress_bar_component.rb +0 -3
- data/app/components/primer/tab_nav_component.rb +1 -1
- data/app/lib/primer/fetch_or_fallback_helper.rb +2 -0
- data/app/lib/primer/octicon/cache.rb +1 -1
- data/app/lib/primer/tabbed_component_helper.rb +1 -1
- data/app/lib/primer/view_helper.rb +1 -0
- data/lib/primer/classify/cache.rb +0 -5
- data/lib/primer/classify/flex.rb +1 -1
- data/lib/primer/classify/functional_colors.rb +1 -1
- data/lib/primer/classify/utilities.rb +19 -2
- data/lib/primer/classify/utilities.yml +16 -0
- data/lib/primer/classify/validation.rb +18 -0
- data/lib/primer/classify.rb +4 -18
- data/lib/primer/view_components/constants.rb +1 -1
- data/lib/primer/view_components/linters/argument_mappers/base.rb +63 -2
- data/lib/primer/view_components/linters/argument_mappers/button.rb +7 -11
- data/lib/primer/view_components/linters/argument_mappers/clipboard_copy.rb +2 -6
- data/lib/primer/view_components/linters/argument_mappers/close_button.rb +43 -0
- data/lib/primer/view_components/linters/argument_mappers/flash.rb +32 -0
- data/lib/primer/view_components/linters/argument_mappers/helpers/erb_block.rb +67 -0
- data/lib/primer/view_components/linters/argument_mappers/label.rb +5 -12
- data/lib/primer/view_components/linters/argument_mappers/system_arguments.rb +6 -5
- data/lib/primer/view_components/linters/autocorrectable.rb +6 -4
- data/lib/primer/view_components/linters/{helpers.rb → base_linter.rb} +69 -29
- data/lib/primer/view_components/linters/button_component_migration_counter.rb +4 -3
- data/lib/primer/view_components/linters/clipboard_copy_component_migration_counter.rb +3 -4
- data/lib/primer/view_components/linters/close_button_component_migration_counter.rb +123 -0
- data/lib/primer/view_components/linters/flash_component_migration_counter.rb +18 -3
- data/lib/primer/view_components/linters/label_component_migration_counter.rb +2 -3
- data/lib/primer/view_components/version.rb +1 -1
- data/lib/rubocop/config/default.yml +5 -0
- data/lib/rubocop/cop/primer/deprecated_arguments.rb +173 -0
- data/lib/rubocop/cop/primer/no_tag_memoize.rb +1 -0
- data/lib/rubocop/cop/primer/primer_octicon.rb +178 -0
- data/lib/rubocop/cop/primer/system_argument_instead_of_class.rb +12 -16
- data/lib/rubocop/cop/primer.rb +1 -2
- data/lib/tasks/coverage.rake +4 -0
- data/lib/tasks/docs.rake +3 -2
- data/lib/tasks/utilities.rake +7 -3
- data/lib/yard/docs_helper.rb +6 -3
- data/static/arguments.yml +7 -4
- data/static/classes.yml +8 -0
- data/static/constants.json +13 -1
- data/static/statuses.json +3 -1
- metadata +32 -9
@@ -42,7 +42,7 @@ module Primer
|
|
42
42
|
# @param type [Symbol] <%= one_of(Primer::BaseButton::TYPE_OPTIONS) %>
|
43
43
|
# @param box [Boolean] Whether the button is in a <%= link_to_component(Primer::BorderBoxComponent) %>. If `true`, the button will have the `Box-btn-octicon` class.
|
44
44
|
# @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
|
45
|
-
def initialize(scheme: DEFAULT_SCHEME,
|
45
|
+
def initialize(icon:, scheme: DEFAULT_SCHEME, box: false, **system_arguments)
|
46
46
|
@icon = icon
|
47
47
|
|
48
48
|
@system_arguments = system_arguments
|
@@ -2,6 +2,9 @@
|
|
2
2
|
|
3
3
|
module Primer
|
4
4
|
# Use `Label` to add contextual metadata to a design.
|
5
|
+
#
|
6
|
+
# @accessibility
|
7
|
+
# Use `aria-label` if the `Label` or the context around it don't explain the label.
|
5
8
|
class LabelComponent < Primer::Component
|
6
9
|
status :beta
|
7
10
|
|
@@ -29,27 +32,25 @@ module Primer
|
|
29
32
|
VARIANT_OPTIONS = VARIANT_MAPPINGS.keys << nil
|
30
33
|
|
31
34
|
# @example Schemes
|
32
|
-
# <%= render(Primer::LabelComponent.new
|
33
|
-
# <%= render(Primer::LabelComponent.new(
|
34
|
-
# <%= render(Primer::LabelComponent.new(
|
35
|
-
# <%= render(Primer::LabelComponent.new(
|
36
|
-
# <%= render(Primer::LabelComponent.new(
|
37
|
-
# <%= render(Primer::LabelComponent.new(
|
38
|
-
# <%= render(Primer::LabelComponent.new(
|
35
|
+
# <%= render(Primer::LabelComponent.new) { "Default" } %>
|
36
|
+
# <%= render(Primer::LabelComponent.new( scheme: :primary)) { "Primary" } %>
|
37
|
+
# <%= render(Primer::LabelComponent.new( scheme: :secondary)) { "Secondary" } %>
|
38
|
+
# <%= render(Primer::LabelComponent.new( scheme: :info)) { "Info" } %>
|
39
|
+
# <%= render(Primer::LabelComponent.new( scheme: :success)) { "Success" } %>
|
40
|
+
# <%= render(Primer::LabelComponent.new( scheme: :warning)) { "Warning" } %>
|
41
|
+
# <%= render(Primer::LabelComponent.new( scheme: :danger)) { "Danger" } %>
|
39
42
|
#
|
40
43
|
# @example Variants
|
41
|
-
# <%= render(Primer::LabelComponent.new
|
42
|
-
# <%= render(Primer::LabelComponent.new(
|
44
|
+
# <%= render(Primer::LabelComponent.new) { "Default" } %>
|
45
|
+
# <%= render(Primer::LabelComponent.new( variant: :large)) { "Large" } %>
|
43
46
|
#
|
44
47
|
# @param tag [Symbol] <%= one_of(Primer::LabelComponent::TAG_OPTIONS) %>
|
45
|
-
# @param title [String] `title` attribute for the component element.
|
46
48
|
# @param scheme [Symbol] <%= one_of(Primer::LabelComponent::SCHEME_MAPPINGS.keys) %>
|
47
49
|
# @param variant [Symbol] <%= one_of(Primer::LabelComponent::VARIANT_OPTIONS) %>
|
48
50
|
# @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
|
49
|
-
def initialize(tag: DEFAULT_TAG,
|
51
|
+
def initialize(tag: DEFAULT_TAG, scheme: nil, variant: nil, **system_arguments)
|
50
52
|
@system_arguments = system_arguments
|
51
53
|
@system_arguments[:tag] = fetch_or_fallback(TAG_OPTIONS, tag, DEFAULT_TAG)
|
52
|
-
@system_arguments[:title] = title
|
53
54
|
@system_arguments[:classes] = class_names(
|
54
55
|
"Label",
|
55
56
|
system_arguments[:classes],
|
@@ -11,9 +11,6 @@ module Primer
|
|
11
11
|
# @param bg [Symbol] The background color
|
12
12
|
# @param kwargs [Hash] The same arguments as <%= link_to_system_arguments_docs %>.
|
13
13
|
renders_many :items, lambda { |percentage: 0, bg: :success_inverse, **system_arguments|
|
14
|
-
percentage = percentage
|
15
|
-
system_arguments = system_arguments
|
16
|
-
|
17
14
|
system_arguments[:tag] = :span
|
18
15
|
system_arguments[:bg] = bg
|
19
16
|
system_arguments[:style] = join_style_arguments(system_arguments[:style], "width: #{percentage}%;")
|
@@ -40,7 +40,7 @@ module Primer
|
|
40
40
|
|
41
41
|
# @example Default
|
42
42
|
# <%= render(Primer::TabNavComponent.new(label: "Default")) do |c| %>
|
43
|
-
# <% c.tab(selected: true, href: "#") { "Tab 1" }%>
|
43
|
+
# <% c.tab(selected: true, href: "#") { "Tab 1" } %>
|
44
44
|
# <% c.tab(href: "#") { "Tab 2" } %>
|
45
45
|
# <% c.tab(href: "#") { "Tab 3" } %>
|
46
46
|
# <% end %>
|
@@ -48,6 +48,7 @@ module Primer
|
|
48
48
|
end
|
49
49
|
end
|
50
50
|
|
51
|
+
# rubocop:disable Style/OptionalBooleanParameter
|
51
52
|
def fetch_or_fallback_boolean(given_value, fallback = false)
|
52
53
|
if [true, false].include?(given_value)
|
53
54
|
given_value
|
@@ -55,6 +56,7 @@ module Primer
|
|
55
56
|
fallback
|
56
57
|
end
|
57
58
|
end
|
59
|
+
# rubocop:enable Style/OptionalBooleanParameter
|
58
60
|
|
59
61
|
def silence_deprecations?
|
60
62
|
Rails.application.config.primer_view_components.silence_deprecations
|
@@ -6,7 +6,7 @@ module Primer
|
|
6
6
|
class Cache
|
7
7
|
LOOKUP = {} # rubocop:disable Style/MutableConstant
|
8
8
|
# Preload the top 20 used icons.
|
9
|
-
PRELOADED_ICONS = [:alert, :check, :"chevron-down", :
|
9
|
+
PRELOADED_ICONS = [:alert, :check, :"chevron-down", :paste, :clock, :"dot-fill", :info, :"kebab-horizontal", :link, :lock, :mail, :pencil, :plus, :question, :repo, :search, :"shield-lock", :star, :trash, :x].freeze
|
10
10
|
|
11
11
|
class << self
|
12
12
|
def get_key(symbol:, size:, width: nil, height: nil)
|
@@ -95,11 +95,6 @@ module Primer
|
|
95
95
|
values: Primer::Classify::Flex::ALIGN_SELF_VALUES
|
96
96
|
)
|
97
97
|
|
98
|
-
preload(
|
99
|
-
keys: [Primer::Classify::WIDTH_KEY, Primer::Classify::HEIGHT_KEY],
|
100
|
-
values: [:fit]
|
101
|
-
)
|
102
|
-
|
103
98
|
preload(
|
104
99
|
keys: Primer::Classify::BOX_SHADOW_KEY,
|
105
100
|
values: [true, :small, :medium, :large, :extra_large, :none]
|
data/lib/primer/classify/flex.rb
CHANGED
@@ -89,7 +89,7 @@ module Primer
|
|
89
89
|
def justify_content(value, breakpoint)
|
90
90
|
val = fetch_or_fallback(JUSTIFY_CONTENT_VALUES, value)
|
91
91
|
|
92
|
-
formatted_value = val.to_s.gsub(/(
|
92
|
+
formatted_value = val.to_s.gsub(/(flex_|space_)/, "")
|
93
93
|
"flex#{breakpoint}-justify-#{formatted_value}"
|
94
94
|
end
|
95
95
|
|
@@ -24,7 +24,9 @@ module Primer
|
|
24
24
|
"^v-align" => "vertical_align",
|
25
25
|
"^d" => "display",
|
26
26
|
"^wb" => "word_break",
|
27
|
-
"^v" => "visibility"
|
27
|
+
"^v" => "visibility",
|
28
|
+
"^width" => "w",
|
29
|
+
"^height" => "h"
|
28
30
|
}.freeze
|
29
31
|
|
30
32
|
class << self
|
@@ -83,7 +85,7 @@ module Primer
|
|
83
85
|
return { classes: classes } if ENV["RAILS_ENV"] == "production"
|
84
86
|
|
85
87
|
obj = {}
|
86
|
-
classes = classes.split
|
88
|
+
classes = classes.split
|
87
89
|
# Loop through all classes supplied and reject ones we find a match for
|
88
90
|
# So when we're at the end of the loop we have classes left with any non-system classes.
|
89
91
|
classes.reject! do |classname|
|
@@ -112,6 +114,21 @@ module Primer
|
|
112
114
|
obj
|
113
115
|
end
|
114
116
|
|
117
|
+
def classes_to_args(classes)
|
118
|
+
classes_to_hash(classes).map do |key, value|
|
119
|
+
val = case value
|
120
|
+
when Symbol
|
121
|
+
":#{value}"
|
122
|
+
when String
|
123
|
+
value.to_json
|
124
|
+
else
|
125
|
+
value
|
126
|
+
end
|
127
|
+
|
128
|
+
"#{key}: #{val}"
|
129
|
+
end.join(", ")
|
130
|
+
end
|
131
|
+
|
115
132
|
private
|
116
133
|
|
117
134
|
def find_selector(selector)
|
@@ -85,6 +85,22 @@
|
|
85
85
|
- float-md-none
|
86
86
|
- float-lg-none
|
87
87
|
- float-xl-none
|
88
|
+
:w:
|
89
|
+
:fit:
|
90
|
+
- width-fit
|
91
|
+
:full:
|
92
|
+
- width-full
|
93
|
+
:auto:
|
94
|
+
- width-auto
|
95
|
+
- width-sm-auto
|
96
|
+
- width-md-auto
|
97
|
+
- width-lg-auto
|
98
|
+
- width-xl-auto
|
99
|
+
:h:
|
100
|
+
:fit:
|
101
|
+
- height-fit
|
102
|
+
:full:
|
103
|
+
- height-full
|
88
104
|
:m:
|
89
105
|
0:
|
90
106
|
- m-0
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "utilities"
|
4
|
+
|
5
|
+
module Primer
|
6
|
+
class Classify
|
7
|
+
# :nodoc:
|
8
|
+
class Validation
|
9
|
+
INVALID_CLASS_NAME_PREFIXES = /bg-|color-|text-|box-shadow-|text-|box_shadow-/.freeze
|
10
|
+
|
11
|
+
class << self
|
12
|
+
def invalid?(class_name)
|
13
|
+
class_name.start_with?(INVALID_CLASS_NAME_PREFIXES) || Primer::Classify::Utilities.supported_selector?(class_name)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
data/lib/primer/classify.rb
CHANGED
@@ -7,6 +7,7 @@ require_relative "classify/functional_border_colors"
|
|
7
7
|
require_relative "classify/functional_text_colors"
|
8
8
|
require_relative "classify/grid"
|
9
9
|
require_relative "classify/utilities"
|
10
|
+
require_relative "classify/validation"
|
10
11
|
|
11
12
|
module Primer
|
12
13
|
# :nodoc:
|
@@ -14,14 +15,9 @@ module Primer
|
|
14
15
|
# Keys where we can simply translate { key: value } into ".key-value"
|
15
16
|
CONCAT_KEYS = %i[text box_shadow].freeze
|
16
17
|
|
17
|
-
INVALID_CLASS_NAME_PREFIXES =
|
18
|
-
(["bg-", "color-", "text-", "box-shadow-"] + CONCAT_KEYS.map { |k| "#{k}-" }).freeze
|
19
|
-
|
20
18
|
COLOR_KEY = :color
|
21
19
|
BG_KEY = :bg
|
22
20
|
TEXT_KEYS = %i[font_family font_style font_weight text_align text_transform].freeze
|
23
|
-
WIDTH_KEY = :width
|
24
|
-
HEIGHT_KEY = :height
|
25
21
|
BOX_SHADOW_KEY = :box_shadow
|
26
22
|
CONTAINER_KEY = :container
|
27
23
|
|
@@ -94,8 +90,6 @@ module Primer
|
|
94
90
|
BORDER_RADIUS_KEY,
|
95
91
|
COLOR_KEY,
|
96
92
|
BG_KEY,
|
97
|
-
WIDTH_KEY,
|
98
|
-
HEIGHT_KEY,
|
99
93
|
BOX_SHADOW_KEY,
|
100
94
|
CONTAINER_KEY
|
101
95
|
]
|
@@ -113,7 +107,7 @@ module Primer
|
|
113
107
|
extracted_results[:style] = [
|
114
108
|
extracted_results.delete(:styles),
|
115
109
|
style
|
116
|
-
].compact.join
|
110
|
+
].compact.join.presence
|
117
111
|
|
118
112
|
extracted_results
|
119
113
|
end
|
@@ -125,8 +119,8 @@ module Primer
|
|
125
119
|
|
126
120
|
if force_system_arguments? && !ENV["PRIMER_WARNINGS_DISABLED"]
|
127
121
|
invalid_class_names =
|
128
|
-
classes.split
|
129
|
-
memo << class_name if
|
122
|
+
classes.split.each_with_object([]) do |class_name, memo|
|
123
|
+
memo << class_name if Primer::Classify::Validation.invalid?(class_name)
|
130
124
|
end
|
131
125
|
|
132
126
|
raise ArgumentError, "Use System Arguments (https://primer.style/view-components/system-arguments) instead of Primer CSS class #{'name'.pluralize(invalid_class_names.length)} #{invalid_class_names.to_sentence}. This warning will not be raised in production. Set PRIMER_WARNINGS_DISABLED=1 to disable this warning." if invalid_class_names.any?
|
@@ -202,12 +196,6 @@ module Primer
|
|
202
196
|
memo[:classes] << Primer::Classify::Flex.classes(key, val, breakpoint)
|
203
197
|
elsif Primer::Classify::Grid::KEYS.include?(key)
|
204
198
|
memo[:classes] << Primer::Classify::Grid.classes(key, val, breakpoint)
|
205
|
-
elsif key == WIDTH_KEY || key == HEIGHT_KEY
|
206
|
-
if val == :fit
|
207
|
-
memo[:classes] << "#{key}-#{val}"
|
208
|
-
else
|
209
|
-
memo[key] = val
|
210
|
-
end
|
211
199
|
elsif TEXT_KEYS.include?(key)
|
212
200
|
memo[:classes] << "text-#{val.to_s.dasherize}"
|
213
201
|
elsif TYPOGRAPHY_KEYS.include?(key)
|
@@ -224,8 +212,6 @@ module Primer
|
|
224
212
|
else
|
225
213
|
"color-shadow-#{val.to_s.dasherize}"
|
226
214
|
end
|
227
|
-
else
|
228
|
-
memo[:classes] << "#{key.to_s.dasherize}#{breakpoint}-#{val.to_s.dasherize}"
|
229
215
|
end
|
230
216
|
end
|
231
217
|
|
@@ -1,8 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require "primer/view_components/constants"
|
4
|
+
require "primer/classify/utilities"
|
5
|
+
require "primer/classify/validation"
|
3
6
|
require_relative "conversion_error"
|
4
7
|
require_relative "system_arguments"
|
5
|
-
|
8
|
+
require_relative "helpers/erb_block"
|
6
9
|
|
7
10
|
module ERBLint
|
8
11
|
module Linters
|
@@ -11,6 +14,7 @@ module ERBLint
|
|
11
14
|
# Override attribute_to_args in a child class to customize its mapping behavior.
|
12
15
|
class Base
|
13
16
|
DEFAULT_TAG = nil
|
17
|
+
ATTRIBUTES = [].freeze
|
14
18
|
|
15
19
|
def initialize(tag)
|
16
20
|
@tag = tag
|
@@ -26,13 +30,70 @@ module ERBLint
|
|
26
30
|
args[:tag] = ":#{@tag.name}" unless self.class::DEFAULT_TAG.nil? || @tag.name == self.class::DEFAULT_TAG
|
27
31
|
|
28
32
|
@tag.attributes.each do |attribute|
|
29
|
-
|
33
|
+
attr_name = attribute.name
|
34
|
+
|
35
|
+
if self.class::ATTRIBUTES.include?(attr_name)
|
36
|
+
args.merge!(attribute_to_args(attribute))
|
37
|
+
elsif attr_name == "class"
|
38
|
+
args.merge!(map_classes(attribute))
|
39
|
+
else
|
40
|
+
# Assume the attribute is a system argument.
|
41
|
+
args.merge!(SystemArguments.new(attribute).to_args)
|
42
|
+
end
|
30
43
|
end
|
31
44
|
|
32
45
|
args
|
33
46
|
end
|
34
47
|
|
35
48
|
def attribute_to_args(attribute); end
|
49
|
+
|
50
|
+
def map_classes(classes_node)
|
51
|
+
erb_helper.raise_if_erb_block(classes_node)
|
52
|
+
|
53
|
+
system_arguments = system_arguments_to_args(classes_node.value)
|
54
|
+
args = classes_to_args(system_arguments[:classes]&.split || [])
|
55
|
+
|
56
|
+
invalid_classes = args[:classes].select { |class_name| Primer::Classify::Validation.invalid?(class_name) }
|
57
|
+
|
58
|
+
raise ConversionError, "Cannot convert #{'class'.pluralize(invalid_classes.size)} #{invalid_classes.join(',')}" if invalid_classes.present?
|
59
|
+
|
60
|
+
# Using splat to order the arguments in Component's args -> System Args -> custom classes
|
61
|
+
res = {
|
62
|
+
**args.except(:classes),
|
63
|
+
**system_arguments.except(:classes)
|
64
|
+
}
|
65
|
+
|
66
|
+
if args[:classes].present?
|
67
|
+
res = {
|
68
|
+
**res,
|
69
|
+
classes: args[:classes].join(" ").to_json
|
70
|
+
}
|
71
|
+
end
|
72
|
+
|
73
|
+
res
|
74
|
+
end
|
75
|
+
|
76
|
+
# Override this with your component's mappings, it should return a hash with the component's arguments,
|
77
|
+
# including a `classes` key that will contain all classes that the mapper couldn't handle.
|
78
|
+
# @returns { classes: Array, ... }
|
79
|
+
def classes_to_args(classes)
|
80
|
+
{ classes: classes }
|
81
|
+
end
|
82
|
+
|
83
|
+
def system_arguments_to_args(classes)
|
84
|
+
system_arguments = Primer::Classify::Utilities.classes_to_hash(classes)
|
85
|
+
|
86
|
+
# need to transform symbols to strings with leading `:`
|
87
|
+
system_arguments.transform_values do |v|
|
88
|
+
v.is_a?(Symbol) ? ":#{v}" : v
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
private
|
93
|
+
|
94
|
+
def erb_helper
|
95
|
+
@erb_helper ||= Helpers::ErbBlock.new
|
96
|
+
end
|
36
97
|
end
|
37
98
|
end
|
38
99
|
end
|
@@ -7,8 +7,6 @@ module ERBLint
|
|
7
7
|
module ArgumentMappers
|
8
8
|
# Maps classes in a button element to arguments for the Button component.
|
9
9
|
class Button < Base
|
10
|
-
require "pry"
|
11
|
-
|
12
10
|
SCHEME_MAPPINGS = Primer::ViewComponents::Constants.get(
|
13
11
|
component: "Primer::ButtonComponent",
|
14
12
|
constant: "SCHEME_MAPPINGS",
|
@@ -30,28 +28,26 @@ module ERBLint
|
|
30
28
|
constant: "DEFAULT_TAG"
|
31
29
|
).freeze
|
32
30
|
|
31
|
+
ATTRIBUTES = %w[disabled type].freeze
|
32
|
+
|
33
33
|
def attribute_to_args(attribute)
|
34
34
|
attr_name = attribute.name
|
35
35
|
|
36
|
-
|
37
|
-
|
38
|
-
elsif attr_name == "disabled"
|
36
|
+
case attr_name
|
37
|
+
when "disabled"
|
39
38
|
{ disabled: true }
|
40
|
-
|
39
|
+
when "type"
|
41
40
|
# button is the default type, so we don't need to do anything.
|
42
41
|
return {} if attribute.value == "button"
|
43
42
|
|
44
43
|
raise ConversionError, "Button component does not support type \"#{attribute.value}\"" unless TYPE_OPTIONS.include?(attribute.value)
|
45
44
|
|
46
45
|
{ type: ":#{attribute.value}" }
|
47
|
-
else
|
48
|
-
# Assume the attribute is a system argument.
|
49
|
-
SystemArguments.new(attribute).to_args
|
50
46
|
end
|
51
47
|
end
|
52
48
|
|
53
49
|
def classes_to_args(classes)
|
54
|
-
classes.
|
50
|
+
classes.each_with_object({ classes: [] }) do |class_name, acc|
|
55
51
|
next if class_name == "btn"
|
56
52
|
|
57
53
|
if SCHEME_MAPPINGS[class_name] && acc[:scheme].nil?
|
@@ -63,7 +59,7 @@ module ERBLint
|
|
63
59
|
elsif class_name == "BtnGroup-item"
|
64
60
|
acc[:group_item] = true
|
65
61
|
else
|
66
|
-
|
62
|
+
acc[:classes] << class_name
|
67
63
|
end
|
68
64
|
end
|
69
65
|
end
|