primer_view_components 0.0.8 → 0.0.13
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 +66 -37
- data/README.md +2 -161
- data/app/components/primer/avatar_component.rb +22 -11
- data/app/components/primer/base_component.rb +56 -11
- data/app/components/primer/blankslate_component.html.erb +2 -2
- data/app/components/primer/blankslate_component.rb +71 -116
- data/app/components/primer/border_box_component.html.erb +5 -5
- data/app/components/primer/border_box_component.rb +45 -33
- data/app/components/primer/box_component.rb +6 -4
- data/app/components/primer/breadcrumb_component.html.erb +2 -2
- data/app/components/primer/breadcrumb_component.rb +23 -30
- data/app/components/primer/button_component.rb +28 -11
- data/app/components/primer/component.rb +1 -0
- data/app/components/primer/counter_component.rb +14 -9
- data/app/components/primer/details_component.html.erb +1 -1
- data/app/components/primer/details_component.rb +18 -18
- 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 +43 -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 +25 -8
- data/app/components/primer/layout_component.html.erb +1 -1
- data/app/components/primer/layout_component.rb +23 -6
- data/app/components/primer/link_component.rb +17 -7
- data/app/components/primer/octicon_component.rb +23 -5
- data/app/components/primer/popover_component.html.erb +1 -1
- data/app/components/primer/popover_component.rb +61 -23
- data/app/components/primer/progress_bar_component.html.erb +2 -2
- data/app/components/primer/progress_bar_component.rb +40 -30
- data/app/components/primer/slot.rb +1 -0
- data/app/components/primer/spinner_component.html.erb +6 -0
- data/app/components/primer/spinner_component.rb +39 -0
- data/app/components/primer/state_component.rb +26 -14
- data/app/components/primer/subhead_component.html.erb +4 -4
- data/app/components/primer/subhead_component.rb +68 -43
- data/app/components/primer/text_component.rb +10 -4
- data/app/components/primer/timeline_item_component.html.erb +4 -4
- data/app/components/primer/timeline_item_component.rb +48 -24
- data/app/components/primer/underline_nav_component.html.erb +1 -1
- data/app/components/primer/underline_nav_component.rb +5 -5
- data/app/components/primer/view_components.rb +1 -0
- data/lib/primer/classify.rb +2 -4
- data/lib/primer/view_components/version.rb +1 -1
- metadata +22 -6
@@ -1,6 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Primer
|
4
|
+
# Use buttons for actions (e.g. in forms). Use links for destinations, or moving from one page to another.
|
4
5
|
class ButtonComponent < Primer::Component
|
5
6
|
DEFAULT_BUTTON_TYPE = :default
|
6
7
|
BUTTON_TYPE_MAPPINGS = {
|
@@ -25,34 +26,50 @@ module Primer
|
|
25
26
|
DEFAULT_TYPE = :button
|
26
27
|
TYPE_OPTIONS = [DEFAULT_TYPE, :reset, :submit].freeze
|
27
28
|
|
29
|
+
# @example 50|Button types
|
30
|
+
# <%= render(Primer::ButtonComponent.new) { "Default" } %>
|
31
|
+
# <%= render(Primer::ButtonComponent.new(button_type: :primary)) { "Primary" } %>
|
32
|
+
# <%= render(Primer::ButtonComponent.new(button_type: :danger)) { "Danger" } %>
|
33
|
+
# <%= render(Primer::ButtonComponent.new(button_type: :outline)) { "Outline" } %>
|
34
|
+
#
|
35
|
+
# @example 50|Variants
|
36
|
+
# <%= render(Primer::ButtonComponent.new(variant: :small)) { "Small" } %>
|
37
|
+
# <%= render(Primer::ButtonComponent.new(variant: :medium)) { "Medium" } %>
|
38
|
+
# <%= render(Primer::ButtonComponent.new(variant: :large)) { "Large" } %>
|
39
|
+
#
|
40
|
+
# @param button_type [Symbol] <%= one_of(Primer::ButtonComponent::BUTTON_TYPE_OPTIONS) %>
|
41
|
+
# @param variant [Symbol] <%= one_of(Primer::ButtonComponent::VARIANT_OPTIONS) %>
|
42
|
+
# @param tag [Symbol] <%= one_of(Primer::ButtonComponent::TAG_OPTIONS) %>
|
43
|
+
# @param type [Symbol] <%= one_of(Primer::ButtonComponent::TYPE_OPTIONS) %>
|
44
|
+
# @param group_item [Boolean] Whether button is part of a ButtonGroup.
|
28
45
|
def initialize(
|
29
46
|
button_type: DEFAULT_BUTTON_TYPE,
|
30
47
|
variant: DEFAULT_VARIANT,
|
31
48
|
tag: DEFAULT_TAG,
|
32
49
|
type: DEFAULT_TYPE,
|
33
50
|
group_item: false,
|
34
|
-
**
|
51
|
+
**system_arguments
|
35
52
|
)
|
36
|
-
@
|
37
|
-
@
|
53
|
+
@system_arguments = system_arguments
|
54
|
+
@system_arguments[:tag] = fetch_or_fallback(TAG_OPTIONS, tag, DEFAULT_TAG)
|
38
55
|
|
39
|
-
if @
|
40
|
-
@
|
56
|
+
if @system_arguments[:tag] == :a
|
57
|
+
@system_arguments[:role] = :button
|
41
58
|
else
|
42
|
-
@
|
59
|
+
@system_arguments[:type] = type
|
43
60
|
end
|
44
61
|
|
45
|
-
@
|
62
|
+
@system_arguments[:classes] = class_names(
|
46
63
|
"btn",
|
47
|
-
|
48
|
-
BUTTON_TYPE_MAPPINGS[fetch_or_fallback(BUTTON_TYPE_OPTIONS, button_type
|
49
|
-
VARIANT_MAPPINGS[fetch_or_fallback(VARIANT_OPTIONS, variant
|
64
|
+
system_arguments[:classes],
|
65
|
+
BUTTON_TYPE_MAPPINGS[fetch_or_fallback(BUTTON_TYPE_OPTIONS, button_type, DEFAULT_BUTTON_TYPE)],
|
66
|
+
VARIANT_MAPPINGS[fetch_or_fallback(VARIANT_OPTIONS, variant, DEFAULT_VARIANT)],
|
50
67
|
"BtnGroup-item" => group_item
|
51
68
|
)
|
52
69
|
end
|
53
70
|
|
54
71
|
def call
|
55
|
-
render(Primer::BaseComponent.new(**@
|
72
|
+
render(Primer::BaseComponent.new(**@system_arguments)) { content }
|
56
73
|
end
|
57
74
|
end
|
58
75
|
end
|
@@ -1,6 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Primer
|
4
|
+
# Use Primer::CounterComponent to add a count to navigational elements and buttons.
|
4
5
|
class CounterComponent < Primer::Component
|
5
6
|
DEFAULT_SCHEME = :default
|
6
7
|
SCHEME_MAPPINGS = {
|
@@ -9,13 +10,17 @@ module Primer
|
|
9
10
|
:light_gray => "Counter Counter--gray-light",
|
10
11
|
}.freeze
|
11
12
|
|
13
|
+
#
|
14
|
+
# @example 34|Default
|
15
|
+
# <%= render(Primer::CounterComponent.new(count: 25)) %>
|
16
|
+
#
|
12
17
|
# @param count [Integer, Float::INFINITY, nil] The number to be displayed (e.x. # of issues, pull requests)
|
13
18
|
# @param scheme [Symbol] Color scheme. One of `SCHEME_MAPPINGS.keys`.
|
14
19
|
# @param limit [Integer] Maximum value to display. (e.x. if count == 6,000 and limit == 5000, counter will display "5,000+")
|
15
20
|
# @param hide_if_zero [Boolean] If true, a `hidden` attribute is added to the counter if `count` is zero.
|
16
21
|
# @param text [String] Text to display instead of count.
|
17
22
|
# @param round [Boolean] Whether to apply our standard rounding logic to value.
|
18
|
-
# @param
|
23
|
+
# @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
|
19
24
|
def initialize(
|
20
25
|
count: 0,
|
21
26
|
scheme: DEFAULT_SCHEME,
|
@@ -23,23 +28,23 @@ module Primer
|
|
23
28
|
hide_if_zero: false,
|
24
29
|
text: "",
|
25
30
|
round: false,
|
26
|
-
**
|
31
|
+
**system_arguments
|
27
32
|
)
|
28
|
-
@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
|
29
34
|
|
30
|
-
@
|
31
|
-
@
|
32
|
-
@
|
33
|
-
@
|
35
|
+
@system_arguments[:title] = title
|
36
|
+
@system_arguments[:tag] = :span
|
37
|
+
@system_arguments[:classes] = class_names(
|
38
|
+
@system_arguments[:classes],
|
34
39
|
SCHEME_MAPPINGS[fetch_or_fallback(SCHEME_MAPPINGS.keys, scheme, DEFAULT_SCHEME)]
|
35
40
|
)
|
36
41
|
if count == 0 && hide_if_zero
|
37
|
-
@
|
42
|
+
@system_arguments[:hidden] = true
|
38
43
|
end
|
39
44
|
end
|
40
45
|
|
41
46
|
def call
|
42
|
-
render(Primer::BaseComponent.new(**@
|
47
|
+
render(Primer::BaseComponent.new(**@system_arguments)) { value }
|
43
48
|
end
|
44
49
|
|
45
50
|
private
|
@@ -9,9 +9,9 @@ module Primer
|
|
9
9
|
class DetailsComponent < Primer::Component
|
10
10
|
include ViewComponent::Slotable
|
11
11
|
|
12
|
-
|
12
|
+
NO_OVERLAY = :none
|
13
13
|
OVERLAY_MAPPINGS = {
|
14
|
-
|
14
|
+
NO_OVERLAY => "",
|
15
15
|
:default => "details-overlay",
|
16
16
|
:dark => "details-overlay details-overlay-dark",
|
17
17
|
}.freeze
|
@@ -19,12 +19,12 @@ module Primer
|
|
19
19
|
with_slot :body, class_name: "Body"
|
20
20
|
with_slot :summary, class_name: "Summary"
|
21
21
|
|
22
|
-
def initialize(overlay:
|
23
|
-
@
|
24
|
-
@
|
25
|
-
@
|
26
|
-
|
27
|
-
OVERLAY_MAPPINGS[fetch_or_fallback(OVERLAY_MAPPINGS.keys, overlay
|
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
|
+
OVERLAY_MAPPINGS[fetch_or_fallback(OVERLAY_MAPPINGS.keys, overlay, NO_OVERLAY)],
|
28
28
|
"details-reset" => reset
|
29
29
|
)
|
30
30
|
end
|
@@ -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 %>
|
@@ -1,6 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Primer
|
4
|
+
# Use the Flash component to inform users of successful or pending actions.
|
4
5
|
class FlashComponent < Primer::Component
|
5
6
|
include ViewComponent::Slotable
|
6
7
|
|
@@ -13,30 +14,59 @@ module Primer
|
|
13
14
|
:danger => "flash-error",
|
14
15
|
:success => "flash-success"
|
15
16
|
}.freeze
|
16
|
-
|
17
|
-
|
17
|
+
# @example 280|Variants
|
18
|
+
# <%= render(Primer::FlashComponent.new) { "This is a flash message!" } %>
|
19
|
+
# <%= render(Primer::FlashComponent.new(variant: :warning)) { "This is a warning flash message!" } %>
|
20
|
+
# <%= render(Primer::FlashComponent.new(variant: :danger)) { "This is a danger flash message!" } %>
|
21
|
+
# <%= render(Primer::FlashComponent.new(variant: :success)) { "This is a success flash message!" } %>
|
22
|
+
#
|
23
|
+
# @example 80|Full width
|
24
|
+
# <%= render(Primer::FlashComponent.new(full: true)) { "This is a full width flash message!" } %>
|
25
|
+
#
|
26
|
+
# @example 80|Dismissible
|
27
|
+
# <%= render(Primer::FlashComponent.new(dismissible: true)) { "This is a dismissible flash message!" } %>
|
28
|
+
#
|
29
|
+
# @example 80|Icon
|
30
|
+
# <%= render(Primer::FlashComponent.new(icon: "people")) { "This is a flash message with an icon!" } %>
|
31
|
+
#
|
32
|
+
# @example 80|With actions
|
33
|
+
# <%= render(Primer::FlashComponent.new) do |component| %>
|
34
|
+
# This is a flash message with actions!
|
35
|
+
# <% component.slot(:actions) do %>
|
36
|
+
# <%= render(Primer::ButtonComponent.new(variant: :small)) { "Take action" } %>
|
37
|
+
# <% end %>
|
38
|
+
# <% end %>
|
39
|
+
#
|
40
|
+
# @param full [Boolean] Whether the component should take up the full width of the screen.
|
41
|
+
# @param spacious [Boolean] Whether to add margin to the bottom of the component.
|
42
|
+
# @param dismissible [Boolean] Whether the component can be dismissed with an X button.
|
43
|
+
# @param icon [String] Name of Octicon icon to use.
|
44
|
+
# @param variant [Symbol] <%= one_of(Primer::FlashComponent::VARIANT_MAPPINGS.keys) %>
|
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)
|
18
47
|
@icon = icon
|
19
48
|
@dismissible = dismissible
|
20
|
-
@
|
21
|
-
@
|
22
|
-
@
|
23
|
-
@
|
49
|
+
@system_arguments = system_arguments
|
50
|
+
@system_arguments[:tag] = :div
|
51
|
+
@system_arguments[:classes] = class_names(
|
52
|
+
@system_arguments[:classes],
|
24
53
|
"flash",
|
25
|
-
VARIANT_MAPPINGS[fetch_or_fallback(VARIANT_MAPPINGS.keys, variant
|
54
|
+
VARIANT_MAPPINGS[fetch_or_fallback(VARIANT_MAPPINGS.keys, variant, DEFAULT_VARIANT)],
|
26
55
|
"flash-full": full
|
27
56
|
)
|
28
|
-
@
|
57
|
+
@system_arguments[:mb] ||= spacious ? 4 : nil
|
29
58
|
end
|
30
59
|
|
31
60
|
class Actions < ViewComponent::Slot
|
32
61
|
include ClassNameHelper
|
33
62
|
|
34
|
-
attr_reader :
|
63
|
+
attr_reader :system_arguments
|
35
64
|
|
36
|
-
|
37
|
-
|
38
|
-
@
|
39
|
-
@
|
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")
|
40
70
|
end
|
41
71
|
end
|
42
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
|
@@ -1,6 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Primer
|
4
|
+
# Use labels to add contextual metadata to a design.
|
4
5
|
class LabelComponent < Primer::Component
|
5
6
|
SCHEME_MAPPINGS = {
|
6
7
|
# gray
|
@@ -28,21 +29,37 @@ module Primer
|
|
28
29
|
}.freeze
|
29
30
|
VARIANT_OPTIONS = VARIANT_MAPPINGS.keys << nil
|
30
31
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
32
|
+
# @example 40|Schemes
|
33
|
+
# <%= render(Primer::LabelComponent.new(title: "Label: Label")) { "default" } %>
|
34
|
+
# <%= render(Primer::LabelComponent.new(title: "Label: Label", scheme: :gray)) { "gray" } %>
|
35
|
+
# <%= render(Primer::LabelComponent.new(title: "Label: Label", scheme: :dark_gray)) { "dark_gray" } %>
|
36
|
+
# <%= render(Primer::LabelComponent.new(title: "Label: Label", scheme: :yellow)) { "yellow" } %>
|
37
|
+
# <%= render(Primer::LabelComponent.new(title: "Label: Label", scheme: :green)) { "green" } %>
|
38
|
+
# <%= render(Primer::LabelComponent.new(title: "Label: Label", scheme: :purple)) { "purple" } %>
|
39
|
+
#
|
40
|
+
# @example 40|Variants
|
41
|
+
# <%= render(Primer::LabelComponent.new(title: "Label: Label")) { "Default" } %>
|
42
|
+
# <%= render(Primer::LabelComponent.new(title: "Label: Label", variant: :large)) { "Large" } %>
|
43
|
+
#
|
44
|
+
# @param title [String] `title` attribute for the component element.
|
45
|
+
# @param scheme [Symbol] <%= one_of(Primer::LabelComponent::SCHEME_OPTIONS) %>
|
46
|
+
# @param variant [Symbol] <%= one_of(Primer::LabelComponent::VARIANT_OPTIONS) %>
|
47
|
+
# @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
|
48
|
+
def initialize(title:, scheme: nil, variant: nil, **system_arguments)
|
49
|
+
@system_arguments = system_arguments
|
50
|
+
@system_arguments[:bg] = :blue if scheme.nil?
|
51
|
+
@system_arguments[:tag] ||= :span
|
52
|
+
@system_arguments[:title] = title
|
53
|
+
@system_arguments[:classes] = class_names(
|
37
54
|
"Label",
|
38
|
-
|
55
|
+
system_arguments[:classes],
|
39
56
|
SCHEME_MAPPINGS[fetch_or_fallback(SCHEME_OPTIONS, scheme)],
|
40
57
|
VARIANT_MAPPINGS[fetch_or_fallback(VARIANT_OPTIONS, variant)]
|
41
58
|
)
|
42
59
|
end
|
43
60
|
|
44
61
|
def call
|
45
|
-
render(Primer::BaseComponent.new(**@
|
62
|
+
render(Primer::BaseComponent.new(**@system_arguments)) { content }
|
46
63
|
end
|
47
64
|
end
|
48
65
|
end
|