primer_view_components 0.0.11 → 0.0.16
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +39 -1
- data/README.md +3 -1
- data/app/components/primer/avatar_component.rb +11 -11
- data/app/components/primer/base_component.rb +101 -9
- data/app/components/primer/blankslate_component.html.erb +5 -5
- data/app/components/primer/blankslate_component.rb +31 -6
- data/app/components/primer/border_box_component.html.erb +5 -5
- data/app/components/primer/border_box_component.rb +34 -34
- data/app/components/primer/box_component.rb +5 -5
- data/app/components/primer/breadcrumb_component.html.erb +2 -2
- data/app/components/primer/breadcrumb_component.rb +12 -12
- data/app/components/primer/button_component.rb +9 -9
- data/app/components/primer/counter_component.rb +16 -15
- data/app/components/primer/details_component.html.erb +1 -1
- data/app/components/primer/details_component.rb +15 -15
- data/app/components/primer/dropdown_menu_component.html.erb +1 -1
- data/app/components/primer/dropdown_menu_component.rb +6 -6
- data/app/components/primer/flash_component.html.erb +2 -2
- data/app/components/primer/flash_component.rb +13 -13
- data/app/components/primer/flex_component.rb +5 -5
- data/app/components/primer/flex_item_component.rb +5 -5
- data/app/components/primer/heading_component.rb +4 -4
- data/app/components/primer/label_component.rb +22 -16
- data/app/components/primer/layout_component.html.erb +1 -1
- data/app/components/primer/layout_component.rb +6 -6
- data/app/components/primer/link_component.rb +8 -8
- data/app/components/primer/octicon_component.rb +10 -10
- data/app/components/primer/popover_component.html.erb +1 -1
- data/app/components/primer/popover_component.rb +26 -26
- data/app/components/primer/progress_bar_component.html.erb +2 -2
- data/app/components/primer/progress_bar_component.rb +14 -14
- data/app/components/primer/spinner_component.html.erb +1 -1
- data/app/components/primer/spinner_component.rb +12 -11
- data/app/components/primer/state_component.rb +8 -8
- data/app/components/primer/subhead_component.html.erb +4 -4
- data/app/components/primer/subhead_component.rb +26 -26
- data/app/components/primer/text_component.rb +5 -5
- data/app/components/primer/timeline_item_component.html.erb +4 -4
- data/app/components/primer/timeline_item_component.rb +28 -28
- data/app/components/primer/underline_nav_component.html.erb +1 -1
- data/app/components/primer/underline_nav_component.rb +5 -5
- data/lib/primer/classify.rb +7 -6
- data/lib/primer/view_components/version.rb +1 -1
- metadata +6 -6
@@ -3,14 +3,14 @@
|
|
3
3
|
module Primer
|
4
4
|
# A basic wrapper component for most layout related needs.
|
5
5
|
class BoxComponent < Primer::Component
|
6
|
-
# @param
|
7
|
-
def initialize(**
|
8
|
-
@
|
9
|
-
@
|
6
|
+
# @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
|
7
|
+
def initialize(**system_arguments)
|
8
|
+
@system_arguments = system_arguments
|
9
|
+
@system_arguments[:tag] = :div
|
10
10
|
end
|
11
11
|
|
12
12
|
def call
|
13
|
-
render(Primer::BaseComponent.new(**@
|
13
|
+
render(Primer::BaseComponent.new(**@system_arguments)) { content }
|
14
14
|
end
|
15
15
|
end
|
16
16
|
end
|
@@ -1,8 +1,8 @@
|
|
1
|
-
<%= render Primer::BaseComponent.new(**@
|
1
|
+
<%= render Primer::BaseComponent.new(**@system_arguments) do %>
|
2
2
|
<ol>
|
3
3
|
<% items.each do |item| %>
|
4
4
|
<%# The <li> and <a> need to be on the same line to prevent unwanted whitespace %>
|
5
|
-
<%= render Primer::BaseComponent.new(**item.
|
5
|
+
<%= render Primer::BaseComponent.new(**item.system_arguments) do %><%- if item.href.present? %><a href="<%= item.href %>"><%= item.content %></a><%- else %><%= item.content %><%- end %><%- end %>
|
6
6
|
<% end %>
|
7
7
|
</ol>
|
8
8
|
<% end %>
|
@@ -14,11 +14,11 @@ module Primer
|
|
14
14
|
# <% component.slot(:item, selected: true) do %>Team<% end %>
|
15
15
|
# <% end %>
|
16
16
|
#
|
17
|
-
# @param
|
18
|
-
def initialize(**
|
19
|
-
@
|
20
|
-
@
|
21
|
-
@
|
17
|
+
# @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
|
18
|
+
def initialize(**system_arguments)
|
19
|
+
@system_arguments = system_arguments
|
20
|
+
@system_arguments[:tag] = :nav
|
21
|
+
@system_arguments[:aria] = { label: "Breadcrumb" }
|
22
22
|
end
|
23
23
|
|
24
24
|
def render?
|
@@ -27,18 +27,18 @@ module Primer
|
|
27
27
|
|
28
28
|
# _Note: if both `href` and `selected: true` are passed in, `href` will be ignored and the item will not be rendered as a link._
|
29
29
|
class BreadcrumbItem < Primer::Slot
|
30
|
-
attr_reader :href, :
|
30
|
+
attr_reader :href, :system_arguments
|
31
31
|
|
32
32
|
# @param href [String] The URL to link to.
|
33
33
|
# @param selected [Boolean] Whether or not the item is selected and not rendered as a link.
|
34
|
-
# @param
|
35
|
-
def initialize(href: nil, selected: false, **
|
36
|
-
@href, @
|
34
|
+
# @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
|
35
|
+
def initialize(href: nil, selected: false, **system_arguments)
|
36
|
+
@href, @system_arguments = href, system_arguments
|
37
37
|
|
38
38
|
@href = nil if selected
|
39
|
-
@
|
40
|
-
@
|
41
|
-
@
|
39
|
+
@system_arguments[:tag] = :li
|
40
|
+
@system_arguments[:"aria-current"] = "page" if selected
|
41
|
+
@system_arguments[:classes] = "breadcrumb-item #{@system_arguments[:classes]}"
|
42
42
|
end
|
43
43
|
end
|
44
44
|
end
|
@@ -48,20 +48,20 @@ module Primer
|
|
48
48
|
tag: DEFAULT_TAG,
|
49
49
|
type: DEFAULT_TYPE,
|
50
50
|
group_item: false,
|
51
|
-
**
|
51
|
+
**system_arguments
|
52
52
|
)
|
53
|
-
@
|
54
|
-
@
|
53
|
+
@system_arguments = system_arguments
|
54
|
+
@system_arguments[:tag] = fetch_or_fallback(TAG_OPTIONS, tag, DEFAULT_TAG)
|
55
55
|
|
56
|
-
if @
|
57
|
-
@
|
56
|
+
if @system_arguments[:tag] == :a
|
57
|
+
@system_arguments[:role] = :button
|
58
58
|
else
|
59
|
-
@
|
59
|
+
@system_arguments[:type] = type
|
60
60
|
end
|
61
61
|
|
62
|
-
@
|
62
|
+
@system_arguments[:classes] = class_names(
|
63
63
|
"btn",
|
64
|
-
|
64
|
+
system_arguments[:classes],
|
65
65
|
BUTTON_TYPE_MAPPINGS[fetch_or_fallback(BUTTON_TYPE_OPTIONS, button_type, DEFAULT_BUTTON_TYPE)],
|
66
66
|
VARIANT_MAPPINGS[fetch_or_fallback(VARIANT_OPTIONS, variant, DEFAULT_VARIANT)],
|
67
67
|
"BtnGroup-item" => group_item
|
@@ -69,7 +69,7 @@ module Primer
|
|
69
69
|
end
|
70
70
|
|
71
71
|
def call
|
72
|
-
render(Primer::BaseComponent.new(**@
|
72
|
+
render(Primer::BaseComponent.new(**@system_arguments)) { content }
|
73
73
|
end
|
74
74
|
end
|
75
75
|
end
|
@@ -16,11 +16,11 @@ module Primer
|
|
16
16
|
#
|
17
17
|
# @param count [Integer, Float::INFINITY, nil] The number to be displayed (e.x. # of issues, pull requests)
|
18
18
|
# @param scheme [Symbol] Color scheme. One of `SCHEME_MAPPINGS.keys`.
|
19
|
-
# @param limit [Integer] Maximum value to display. (e.x. if count == 6,000 and limit == 5000, counter will display "5,000+")
|
19
|
+
# @param limit [Integer, nil] Maximum value to display. Pass `nil` for no limit. (e.x. if `count` == 6,000 and `limit` == 5000, counter will display "5,000+")
|
20
20
|
# @param hide_if_zero [Boolean] If true, a `hidden` attribute is added to the counter if `count` is zero.
|
21
21
|
# @param text [String] Text to display instead of count.
|
22
22
|
# @param round [Boolean] Whether to apply our standard rounding logic to value.
|
23
|
-
# @param
|
23
|
+
# @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
|
24
24
|
def initialize(
|
25
25
|
count: 0,
|
26
26
|
scheme: DEFAULT_SCHEME,
|
@@ -28,23 +28,24 @@ module Primer
|
|
28
28
|
hide_if_zero: false,
|
29
29
|
text: "",
|
30
30
|
round: false,
|
31
|
-
**
|
31
|
+
**system_arguments
|
32
32
|
)
|
33
|
-
@count, @limit, @hide_if_zero, @text, @round, @
|
33
|
+
@count, @limit, @hide_if_zero, @text, @round, @system_arguments = count, limit, hide_if_zero, text, round, system_arguments
|
34
34
|
|
35
|
-
@
|
36
|
-
@
|
37
|
-
@
|
38
|
-
|
35
|
+
@has_limit = !@limit.nil?
|
36
|
+
@system_arguments[:title] = title
|
37
|
+
@system_arguments[:tag] = :span
|
38
|
+
@system_arguments[:classes] = class_names(
|
39
|
+
@system_arguments[:classes],
|
39
40
|
SCHEME_MAPPINGS[fetch_or_fallback(SCHEME_MAPPINGS.keys, scheme, DEFAULT_SCHEME)]
|
40
41
|
)
|
41
42
|
if count == 0 && hide_if_zero
|
42
|
-
@
|
43
|
+
@system_arguments[:hidden] = true
|
43
44
|
end
|
44
45
|
end
|
45
46
|
|
46
47
|
def call
|
47
|
-
render(Primer::BaseComponent.new(**@
|
48
|
+
render(Primer::BaseComponent.new(**@system_arguments)) { value }
|
48
49
|
end
|
49
50
|
|
50
51
|
private
|
@@ -58,8 +59,8 @@ module Primer
|
|
58
59
|
"Infinity"
|
59
60
|
else
|
60
61
|
count = @count.to_i
|
61
|
-
str = number_with_delimiter([count, @limit].min)
|
62
|
-
str += "+" if count > @limit
|
62
|
+
str = number_with_delimiter(@has_limit ? [count, @limit].min : count)
|
63
|
+
str += "+" if (@has_limit && count > @limit)
|
63
64
|
str
|
64
65
|
end
|
65
66
|
end
|
@@ -73,16 +74,16 @@ module Primer
|
|
73
74
|
"∞"
|
74
75
|
else
|
75
76
|
if @round
|
76
|
-
count = [@count.to_i, @limit].min
|
77
|
+
count = @has_limit ? [@count.to_i, @limit].min : @count.to_i
|
77
78
|
precision = count.between?(100_000, 999_999) ? 0 : 1
|
78
79
|
units = {thousand: "k", million: "m", billion: "b"}
|
79
80
|
str = number_to_human(count, precision: precision, significant: false, units: units, format: "%n%u")
|
80
81
|
else
|
81
82
|
@count = @count.to_i
|
82
|
-
str = number_with_delimiter([@count, @limit].min)
|
83
|
+
str = number_with_delimiter(@has_limit ? [@count, @limit].min : @count)
|
83
84
|
end
|
84
85
|
|
85
|
-
str += "+" if @count.to_i > @limit
|
86
|
+
str += "+" if (@has_limit && @count.to_i > @limit)
|
86
87
|
str
|
87
88
|
end
|
88
89
|
end
|
@@ -19,11 +19,11 @@ module Primer
|
|
19
19
|
with_slot :body, class_name: "Body"
|
20
20
|
with_slot :summary, class_name: "Summary"
|
21
21
|
|
22
|
-
def initialize(overlay: NO_OVERLAY, reset: false, **
|
23
|
-
@
|
24
|
-
@
|
25
|
-
@
|
26
|
-
|
22
|
+
def initialize(overlay: NO_OVERLAY, reset: false, **system_arguments)
|
23
|
+
@system_arguments = system_arguments
|
24
|
+
@system_arguments[:tag] = :details
|
25
|
+
@system_arguments[:classes] = class_names(
|
26
|
+
system_arguments[:classes],
|
27
27
|
OVERLAY_MAPPINGS[fetch_or_fallback(OVERLAY_MAPPINGS.keys, overlay, NO_OVERLAY)],
|
28
28
|
"details-reset" => reset
|
29
29
|
)
|
@@ -34,29 +34,29 @@ module Primer
|
|
34
34
|
end
|
35
35
|
|
36
36
|
class Summary < Primer::Slot
|
37
|
-
def initialize(button: true, **
|
37
|
+
def initialize(button: true, **system_arguments)
|
38
38
|
@button = button
|
39
39
|
|
40
|
-
@
|
41
|
-
@
|
42
|
-
@
|
40
|
+
@system_arguments = system_arguments
|
41
|
+
@system_arguments[:tag] = :summary
|
42
|
+
@system_arguments[:role] = "button"
|
43
43
|
end
|
44
44
|
|
45
45
|
def component
|
46
|
-
return Primer::BaseComponent.new(**@
|
46
|
+
return Primer::BaseComponent.new(**@system_arguments) unless @button
|
47
47
|
|
48
|
-
Primer::ButtonComponent.new(**@
|
48
|
+
Primer::ButtonComponent.new(**@system_arguments)
|
49
49
|
end
|
50
50
|
end
|
51
51
|
|
52
52
|
class Body < Primer::Slot
|
53
|
-
def initialize(**
|
54
|
-
@
|
55
|
-
@
|
53
|
+
def initialize(**system_arguments)
|
54
|
+
@system_arguments = system_arguments
|
55
|
+
@system_arguments[:tag] ||= :div
|
56
56
|
end
|
57
57
|
|
58
58
|
def component
|
59
|
-
Primer::BaseComponent.new(**@
|
59
|
+
Primer::BaseComponent.new(**@system_arguments)
|
60
60
|
end
|
61
61
|
end
|
62
62
|
end
|
@@ -11,14 +11,14 @@ module Primer
|
|
11
11
|
DIRECTION_DEFAULT = :se
|
12
12
|
DIRECTION_OPTIONS = [DIRECTION_DEFAULT, :sw, :w, :e, :ne, :s]
|
13
13
|
|
14
|
-
def initialize(direction: DIRECTION_DEFAULT, scheme: SCHEME_DEFAULT, header: nil, **
|
15
|
-
@header, @direction, @
|
14
|
+
def initialize(direction: DIRECTION_DEFAULT, scheme: SCHEME_DEFAULT, header: nil, **system_arguments)
|
15
|
+
@header, @direction, @system_arguments = header, direction, system_arguments
|
16
16
|
|
17
|
-
@
|
18
|
-
@
|
17
|
+
@system_arguments[:tag] = "details-menu"
|
18
|
+
@system_arguments[:role] = "menu"
|
19
19
|
|
20
|
-
@
|
21
|
-
@
|
20
|
+
@system_arguments[:classes] = class_names(
|
21
|
+
@system_arguments[:classes],
|
22
22
|
"dropdown-menu",
|
23
23
|
"dropdown-menu-#{fetch_or_fallback(DIRECTION_OPTIONS, direction, DIRECTION_DEFAULT)}",
|
24
24
|
SCHEME_MAPPINGS[fetch_or_fallback(SCHEME_MAPPINGS.keys, scheme, SCHEME_DEFAULT)]
|
@@ -1,4 +1,4 @@
|
|
1
|
-
<%= render Primer::BaseComponent.new(**@
|
1
|
+
<%= render Primer::BaseComponent.new(**@system_arguments) do %>
|
2
2
|
<%= render(Primer::OcticonComponent.new(icon: @icon)) if @icon %>
|
3
3
|
<%= content %>
|
4
4
|
<% if @dismissible %>
|
@@ -7,7 +7,7 @@
|
|
7
7
|
</button>
|
8
8
|
<% end %>
|
9
9
|
<% if actions.present? %>
|
10
|
-
<%= render Primer::BaseComponent.new(**actions.
|
10
|
+
<%= render Primer::BaseComponent.new(**actions.system_arguments) do %>
|
11
11
|
<%= actions.content %>
|
12
12
|
<% end %>
|
13
13
|
<% end %>
|
@@ -42,31 +42,31 @@ module Primer
|
|
42
42
|
# @param dismissible [Boolean] Whether the component can be dismissed with an X button.
|
43
43
|
# @param icon [String] Name of Octicon icon to use.
|
44
44
|
# @param variant [Symbol] <%= one_of(Primer::FlashComponent::VARIANT_MAPPINGS.keys) %>
|
45
|
-
# @param
|
46
|
-
def initialize(full: false, spacious: false, dismissible: false, icon: nil, variant: DEFAULT_VARIANT, **
|
45
|
+
# @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
|
46
|
+
def initialize(full: false, spacious: false, dismissible: false, icon: nil, variant: DEFAULT_VARIANT, **system_arguments)
|
47
47
|
@icon = icon
|
48
48
|
@dismissible = dismissible
|
49
|
-
@
|
50
|
-
@
|
51
|
-
@
|
52
|
-
@
|
49
|
+
@system_arguments = system_arguments
|
50
|
+
@system_arguments[:tag] = :div
|
51
|
+
@system_arguments[:classes] = class_names(
|
52
|
+
@system_arguments[:classes],
|
53
53
|
"flash",
|
54
54
|
VARIANT_MAPPINGS[fetch_or_fallback(VARIANT_MAPPINGS.keys, variant, DEFAULT_VARIANT)],
|
55
55
|
"flash-full": full
|
56
56
|
)
|
57
|
-
@
|
57
|
+
@system_arguments[:mb] ||= spacious ? 4 : nil
|
58
58
|
end
|
59
59
|
|
60
60
|
class Actions < ViewComponent::Slot
|
61
61
|
include ClassNameHelper
|
62
62
|
|
63
|
-
attr_reader :
|
63
|
+
attr_reader :system_arguments
|
64
64
|
|
65
|
-
# @param
|
66
|
-
def initialize(**
|
67
|
-
@
|
68
|
-
@
|
69
|
-
@
|
65
|
+
# @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
|
66
|
+
def initialize(**system_arguments)
|
67
|
+
@system_arguments = system_arguments
|
68
|
+
@system_arguments[:tag] = :div
|
69
|
+
@system_arguments[:classes] = class_names(@system_arguments[:classes], "flash-action")
|
70
70
|
end
|
71
71
|
end
|
72
72
|
end
|
@@ -37,7 +37,7 @@ module Primer
|
|
37
37
|
flex_wrap: FLEX_WRAP_DEFAULT,
|
38
38
|
align_items: ALIGN_ITEMS_DEFAULT,
|
39
39
|
direction: nil,
|
40
|
-
**
|
40
|
+
**system_arguments
|
41
41
|
)
|
42
42
|
@align_items = fetch_or_fallback(ALIGN_ITEMS_OPTIONS, align_items, ALIGN_ITEMS_DEFAULT)
|
43
43
|
@justify_content = fetch_or_fallback(JUSTIFY_CONTENT_OPTIONS, justify_content, JUSTIFY_CONTENT_DEFAULT)
|
@@ -51,13 +51,13 @@ module Primer
|
|
51
51
|
DEFAULT_DIRECTION
|
52
52
|
end
|
53
53
|
|
54
|
-
@
|
55
|
-
@
|
56
|
-
@
|
54
|
+
@system_arguments = system_arguments.merge({ direction: @direction }.compact)
|
55
|
+
@system_arguments[:classes] = class_names(@system_arguments[:classes], component_class_names)
|
56
|
+
@system_arguments[:display] = fetch_or_fallback(INLINE_OPTIONS, inline, INLINE_DEFAULT) ? :inline_flex : :flex
|
57
57
|
end
|
58
58
|
|
59
59
|
def call
|
60
|
-
render(Primer::BoxComponent.new(**@
|
60
|
+
render(Primer::BoxComponent.new(**@system_arguments)) { content }
|
61
61
|
end
|
62
62
|
|
63
63
|
private
|
@@ -5,17 +5,17 @@ module Primer
|
|
5
5
|
FLEX_AUTO_DEFAULT = false
|
6
6
|
FLEX_AUTO_ALLOWED_VALUES = [FLEX_AUTO_DEFAULT, true]
|
7
7
|
|
8
|
-
def initialize(flex_auto: FLEX_AUTO_DEFAULT, **
|
9
|
-
@
|
10
|
-
@
|
8
|
+
def initialize(flex_auto: FLEX_AUTO_DEFAULT, **system_arguments)
|
9
|
+
@system_arguments = system_arguments
|
10
|
+
@system_arguments[:classes] =
|
11
11
|
class_names(
|
12
|
-
@
|
12
|
+
@system_arguments[:classes],
|
13
13
|
"flex-auto" => fetch_or_fallback(FLEX_AUTO_ALLOWED_VALUES, flex_auto, FLEX_AUTO_DEFAULT)
|
14
14
|
)
|
15
15
|
end
|
16
16
|
|
17
17
|
def call
|
18
|
-
render(Primer::BoxComponent.new(**@
|
18
|
+
render(Primer::BoxComponent.new(**@system_arguments)) { content }
|
19
19
|
end
|
20
20
|
end
|
21
21
|
end
|
@@ -2,13 +2,13 @@
|
|
2
2
|
|
3
3
|
module Primer
|
4
4
|
class HeadingComponent < Primer::Component
|
5
|
-
def initialize(**
|
6
|
-
@
|
7
|
-
@
|
5
|
+
def initialize(**system_arguments)
|
6
|
+
@system_arguments = system_arguments
|
7
|
+
@system_arguments[:tag] ||= :h1
|
8
8
|
end
|
9
9
|
|
10
10
|
def call
|
11
|
-
render(Primer::BaseComponent.new(**@
|
11
|
+
render(Primer::BaseComponent.new(**@system_arguments)) { content }
|
12
12
|
end
|
13
13
|
end
|
14
14
|
end
|
@@ -3,12 +3,18 @@
|
|
3
3
|
module Primer
|
4
4
|
# Use labels to add contextual metadata to a design.
|
5
5
|
class LabelComponent < Primer::Component
|
6
|
-
|
7
|
-
|
6
|
+
NEW_SCHEME_MAPPINGS = {
|
7
|
+
primary: "Label--primary",
|
8
|
+
secondary: "Label--secondary",
|
9
|
+
info: "Label--info",
|
10
|
+
success: "Label--success",
|
11
|
+
warning: "Label--warning",
|
12
|
+
danger: "Label--danger",
|
13
|
+
}
|
14
|
+
|
15
|
+
DEPRECATED_SCHEME_MAPPINGS = {
|
8
16
|
gray: "Label--gray",
|
9
17
|
dark_gray: "Label--gray-darker",
|
10
|
-
|
11
|
-
# colored
|
12
18
|
yellow: "Label--yellow",
|
13
19
|
orange: "Label--orange",
|
14
20
|
red: "Label--red",
|
@@ -16,11 +22,11 @@ module Primer
|
|
16
22
|
blue: "Label--blue",
|
17
23
|
purple: "Label--purple",
|
18
24
|
pink: "Label--pink",
|
19
|
-
|
20
|
-
# Deprecated
|
21
25
|
outline: "Label--outline",
|
22
26
|
green_outline: "Label--outline-green",
|
23
27
|
}.freeze
|
28
|
+
|
29
|
+
SCHEME_MAPPINGS = NEW_SCHEME_MAPPINGS.merge(DEPRECATED_SCHEME_MAPPINGS)
|
24
30
|
SCHEME_OPTIONS = SCHEME_MAPPINGS.keys << nil
|
25
31
|
|
26
32
|
VARIANT_MAPPINGS = {
|
@@ -42,24 +48,24 @@ module Primer
|
|
42
48
|
# <%= render(Primer::LabelComponent.new(title: "Label: Label", variant: :large)) { "Large" } %>
|
43
49
|
#
|
44
50
|
# @param title [String] `title` attribute for the component element.
|
45
|
-
# @param scheme [Symbol] <%= one_of(Primer::LabelComponent::
|
51
|
+
# @param scheme [Symbol] <%= one_of(Primer::LabelComponent::DEPRECATED_SCHEME_MAPPINGS.keys) %>
|
46
52
|
# @param variant [Symbol] <%= one_of(Primer::LabelComponent::VARIANT_OPTIONS) %>
|
47
|
-
# @param
|
48
|
-
def initialize(title:, scheme: nil, variant: nil, **
|
49
|
-
@
|
50
|
-
@
|
51
|
-
@
|
52
|
-
@
|
53
|
-
@
|
53
|
+
# @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
|
54
|
+
def initialize(title:, scheme: nil, variant: nil, **system_arguments)
|
55
|
+
@system_arguments = system_arguments
|
56
|
+
@system_arguments[:bg] = :blue if scheme.nil?
|
57
|
+
@system_arguments[:tag] ||= :span
|
58
|
+
@system_arguments[:title] = title
|
59
|
+
@system_arguments[:classes] = class_names(
|
54
60
|
"Label",
|
55
|
-
|
61
|
+
system_arguments[:classes],
|
56
62
|
SCHEME_MAPPINGS[fetch_or_fallback(SCHEME_OPTIONS, scheme)],
|
57
63
|
VARIANT_MAPPINGS[fetch_or_fallback(VARIANT_OPTIONS, variant)]
|
58
64
|
)
|
59
65
|
end
|
60
66
|
|
61
67
|
def call
|
62
|
-
render(Primer::BaseComponent.new(**@
|
68
|
+
render(Primer::BaseComponent.new(**@system_arguments)) { content }
|
63
69
|
end
|
64
70
|
end
|
65
71
|
end
|