primer_view_components 0.0.21 → 0.0.26
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +77 -0
- data/app/assets/javascripts/primer_view_components.js +2 -0
- data/app/assets/javascripts/primer_view_components.js.map +1 -0
- data/app/components/primer/avatar_component.rb +3 -3
- data/app/components/primer/avatar_stack_component.rb +3 -3
- data/app/components/primer/base_component.rb +6 -2
- data/app/components/primer/blankslate_component.html.erb +2 -2
- data/app/components/primer/blankslate_component.rb +11 -7
- data/app/components/primer/border_box_component.html.erb +4 -18
- data/app/components/primer/border_box_component.rb +58 -67
- data/app/components/primer/box_component.rb +2 -2
- data/app/components/primer/breadcrumb_component.html.erb +1 -2
- data/app/components/primer/breadcrumb_component.rb +24 -13
- data/app/components/primer/button_component.rb +2 -2
- data/app/components/primer/button_group_component.rb +1 -1
- data/app/components/primer/button_marketing_component.rb +2 -2
- data/app/components/primer/component.rb +4 -0
- data/app/components/primer/counter_component.rb +1 -1
- data/app/components/primer/details_component.html.erb +2 -6
- data/app/components/primer/details_component.rb +21 -35
- data/app/components/primer/dropdown_component.html.erb +2 -2
- data/app/components/primer/dropdown_component.rb +4 -6
- data/app/components/primer/dropdown_menu_component.rb +4 -4
- data/app/components/primer/flash_component.html.erb +2 -2
- data/app/components/primer/flash_component.rb +5 -5
- data/app/components/primer/flex_component.rb +4 -4
- data/app/components/primer/flex_item_component.rb +1 -1
- data/app/components/primer/heading_component.rb +3 -1
- data/app/components/primer/label_component.rb +22 -26
- data/app/components/primer/layout_component.rb +2 -2
- data/app/components/primer/link_component.rb +2 -2
- data/app/components/primer/markdown_component.rb +8 -8
- data/app/components/primer/menu_component.rb +1 -1
- data/app/components/primer/octicon_component.rb +5 -3
- data/app/components/primer/popover_component.rb +3 -3
- data/app/components/primer/primer.js +1 -0
- data/app/components/primer/primer.ts +1 -0
- data/app/components/primer/progress_bar_component.html.erb +1 -1
- data/app/components/primer/progress_bar_component.rb +27 -31
- data/app/components/primer/spinner_component.rb +3 -3
- data/app/components/primer/state_component.rb +21 -10
- data/app/components/primer/subhead_component.html.erb +3 -15
- data/app/components/primer/subhead_component.rb +47 -59
- data/app/components/primer/tab_container_component.js +1 -0
- data/app/components/primer/tab_container_component.rb +41 -0
- data/app/components/primer/tab_container_component.ts +1 -0
- data/app/components/primer/tab_nav_component.html.erb +17 -0
- data/app/components/primer/tab_nav_component.rb +108 -0
- data/app/components/primer/text_component.rb +1 -1
- data/app/components/primer/timeline_item_component.rb +1 -1
- data/app/components/primer/tooltip_component.rb +5 -5
- data/app/components/primer/truncate_component.rb +4 -4
- data/app/components/primer/underline_nav_component.rb +2 -2
- data/{lib → app/lib}/primer/class_name_helper.rb +0 -0
- data/{lib → app/lib}/primer/classify.rb +0 -2
- data/{lib → app/lib}/primer/classify/cache.rb +0 -0
- data/{lib → app/lib}/primer/fetch_or_fallback_helper.rb +0 -0
- data/{lib → app/lib}/primer/join_style_arguments_helper.rb +0 -0
- data/app/lib/primer/view_helper.rb +22 -0
- data/app/lib/primer/view_helper/dsl.rb +34 -0
- data/lib/primer/view_components/engine.rb +10 -2
- data/lib/primer/view_components/version.rb +5 -1
- data/static/statuses.json +1 -1
- metadata +18 -8
- data/app/components/primer/view_components.rb +0 -60
@@ -1,8 +1,7 @@
|
|
1
1
|
<%= render Primer::BaseComponent.new(**@system_arguments) do %>
|
2
2
|
<ol>
|
3
3
|
<% items.each do |item| %>
|
4
|
-
|
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 %>
|
4
|
+
<%= item %>
|
6
5
|
<% end %>
|
7
6
|
</ol>
|
8
7
|
<% end %>
|
@@ -3,15 +3,20 @@
|
|
3
3
|
module Primer
|
4
4
|
# Use breadcrumbs to display page hierarchy within a section of the site. All of the items in the breadcrumb "trail" are links except for the final item, which is a plain string indicating the current page.
|
5
5
|
class BreadcrumbComponent < Primer::Component
|
6
|
-
include ViewComponent::
|
6
|
+
include ViewComponent::SlotableV2
|
7
7
|
|
8
|
-
|
8
|
+
# _Note: if both `href` and `selected: true` are passed in, `href` will be ignored and the item will not be rendered as a link._
|
9
|
+
#
|
10
|
+
# @param href [String] The URL to link to.
|
11
|
+
# @param selected [Boolean] Whether or not the item is selected and not rendered as a link.
|
12
|
+
# @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
|
13
|
+
renders_many :items, "ItemComponent"
|
9
14
|
|
10
|
-
# @example
|
15
|
+
# @example Basic
|
11
16
|
# <%= render(Primer::BreadcrumbComponent.new) do |component| %>
|
12
|
-
# <% component.
|
13
|
-
# <% component.
|
14
|
-
# <% component.
|
17
|
+
# <% component.item(href: "/") do %>Home<% end %>
|
18
|
+
# <% component.item(href: "/about") do %>About<% end %>
|
19
|
+
# <% component.item(selected: true) do %>Team<% end %>
|
15
20
|
# <% end %>
|
16
21
|
#
|
17
22
|
# @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
|
@@ -25,13 +30,9 @@ module Primer
|
|
25
30
|
items.any?
|
26
31
|
end
|
27
32
|
|
28
|
-
#
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
# @param href [String] The URL to link to.
|
33
|
-
# @param selected [Boolean] Whether or not the item is selected and not rendered as a link.
|
34
|
-
# @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
|
33
|
+
# This component is part of `Primer::BreadcrumbComponent` and should not be
|
34
|
+
# used as a standalone component.
|
35
|
+
class ItemComponent < Primer::Component
|
35
36
|
def initialize(href: nil, selected: false, **system_arguments)
|
36
37
|
@href = href
|
37
38
|
@system_arguments = system_arguments
|
@@ -41,6 +42,16 @@ module Primer
|
|
41
42
|
@system_arguments[:"aria-current"] = "page" if selected
|
42
43
|
@system_arguments[:classes] = "breadcrumb-item #{@system_arguments[:classes]}"
|
43
44
|
end
|
45
|
+
|
46
|
+
def call
|
47
|
+
render(Primer::BaseComponent.new(**@system_arguments)) do
|
48
|
+
if @href.present?
|
49
|
+
render(Primer::LinkComponent.new(href: @href)) { content }
|
50
|
+
else
|
51
|
+
content
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
44
55
|
end
|
45
56
|
end
|
46
57
|
end
|
@@ -26,13 +26,13 @@ module Primer
|
|
26
26
|
DEFAULT_TYPE = :button
|
27
27
|
TYPE_OPTIONS = [DEFAULT_TYPE, :reset, :submit].freeze
|
28
28
|
|
29
|
-
# @example
|
29
|
+
# @example Button types
|
30
30
|
# <%= render(Primer::ButtonComponent.new) { "Default" } %>
|
31
31
|
# <%= render(Primer::ButtonComponent.new(button_type: :primary)) { "Primary" } %>
|
32
32
|
# <%= render(Primer::ButtonComponent.new(button_type: :danger)) { "Danger" } %>
|
33
33
|
# <%= render(Primer::ButtonComponent.new(button_type: :outline)) { "Outline" } %>
|
34
34
|
#
|
35
|
-
# @example
|
35
|
+
# @example Variants
|
36
36
|
# <%= render(Primer::ButtonComponent.new(variant: :small)) { "Small" } %>
|
37
37
|
# <%= render(Primer::ButtonComponent.new(variant: :medium)) { "Medium" } %>
|
38
38
|
# <%= render(Primer::ButtonComponent.new(variant: :large)) { "Large" } %>
|
@@ -10,7 +10,7 @@ module Primer
|
|
10
10
|
# @param kwargs [Hash] The same arguments as <%= link_to_component(Primer::ButtonComponent) %>.
|
11
11
|
renders_many :buttons, ->(**kwargs) { Primer::ButtonComponent.new(group_item: true, **kwargs) }
|
12
12
|
|
13
|
-
# @example
|
13
|
+
# @example Default
|
14
14
|
# <%= render(Primer::ButtonGroupComponent.new) do |component|
|
15
15
|
# component.button { "Default" }
|
16
16
|
# component.button(button_type: :primary) { "Primary" }
|
@@ -25,7 +25,7 @@ module Primer
|
|
25
25
|
DEFAULT_TYPE = :button
|
26
26
|
TYPE_OPTIONS = [DEFAULT_TYPE, :submit].freeze
|
27
27
|
|
28
|
-
# @example
|
28
|
+
# @example Button types
|
29
29
|
# <%= render(Primer::ButtonMarketingComponent.new(mr: 2)) { "Default" } %>
|
30
30
|
# <%= render(Primer::ButtonMarketingComponent.new(button_type: :primary, mr: 2)) { "Primary" } %>
|
31
31
|
# <%= render(Primer::ButtonMarketingComponent.new(button_type: :outline)) { "Outline" } %>
|
@@ -33,7 +33,7 @@ module Primer
|
|
33
33
|
# <%= render(Primer::ButtonMarketingComponent.new(button_type: :transparent)) { "Transparent" } %>
|
34
34
|
# </div>
|
35
35
|
#
|
36
|
-
# @example
|
36
|
+
# @example Sizes
|
37
37
|
# <%= render(Primer::ButtonMarketingComponent.new(mr: 2)) { "Default" } %>
|
38
38
|
# <%= render(Primer::ButtonMarketingComponent.new(variant: :large)) { "Large" } %>
|
39
39
|
#
|
@@ -1,5 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require "octicons_helper/helper"
|
4
|
+
|
3
5
|
module Primer
|
4
6
|
# @private
|
5
7
|
class Component < ViewComponent::Base
|
@@ -7,6 +9,8 @@ module Primer
|
|
7
9
|
include FetchOrFallbackHelper
|
8
10
|
include OcticonsHelper
|
9
11
|
include JoinStyleArgumentsHelper
|
12
|
+
include ViewHelper::Dsl
|
13
|
+
include ViewHelper
|
10
14
|
|
11
15
|
# sourced from https://primer.style/doctocat/usage/front-matter#status
|
12
16
|
STATUSES = {
|
@@ -3,7 +3,7 @@
|
|
3
3
|
module Primer
|
4
4
|
# Use DetailsComponent to reveal content after clicking a button.
|
5
5
|
class DetailsComponent < Primer::Component
|
6
|
-
include ViewComponent::
|
6
|
+
include ViewComponent::SlotableV2
|
7
7
|
|
8
8
|
NO_OVERLAY = :none
|
9
9
|
OVERLAY_MAPPINGS = {
|
@@ -12,8 +12,26 @@ module Primer
|
|
12
12
|
:dark => "details-overlay details-overlay-dark"
|
13
13
|
}.freeze
|
14
14
|
|
15
|
-
|
16
|
-
|
15
|
+
# Use the Summary slot as a trigger to reveal the content.
|
16
|
+
#
|
17
|
+
# @param button [Boolean] Whether to render the Summary as a button or not.
|
18
|
+
# @param kwargs [Hash] The same arguments as <%= link_to_system_arguments_docs %>.
|
19
|
+
renders_one :summary, lambda { |button: true, **system_arguments|
|
20
|
+
system_arguments[:tag] = :summary
|
21
|
+
system_arguments[:role] = "button"
|
22
|
+
|
23
|
+
return Primer::BaseComponent.new(**system_arguments) unless button
|
24
|
+
|
25
|
+
Primer::ButtonComponent.new(**system_arguments)
|
26
|
+
}
|
27
|
+
|
28
|
+
# Use the Body slot as the main content to be shown when triggered by the Summary.
|
29
|
+
#
|
30
|
+
# @param kwargs [Hash] The same arguments as <%= link_to_system_arguments_docs %>.
|
31
|
+
renders_one :body, lambda { |**system_arguments|
|
32
|
+
system_arguments[:tag] ||= :div
|
33
|
+
Primer::BaseComponent.new(**system_arguments)
|
34
|
+
}
|
17
35
|
|
18
36
|
# @param overlay [Symbol] Dictates the type of overlay to render with. <%= one_of(Primer::DetailsComponent::OVERLAY_MAPPINGS.keys) %>
|
19
37
|
# @param reset [Boolean] Defatuls to false. If set to true, it will remove the default caret and remove style from the summary element
|
@@ -31,37 +49,5 @@ module Primer
|
|
31
49
|
def render?
|
32
50
|
summary.present? && body.present?
|
33
51
|
end
|
34
|
-
|
35
|
-
# Use the Summary slot as a trigger to reveal the content.
|
36
|
-
class Summary < Primer::Slot
|
37
|
-
# @param button [Boolean] Whether to render the Summary as a button or not.
|
38
|
-
# @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
|
39
|
-
def initialize(button: true, **system_arguments)
|
40
|
-
@button = button
|
41
|
-
|
42
|
-
@system_arguments = system_arguments
|
43
|
-
@system_arguments[:tag] = :summary
|
44
|
-
@system_arguments[:role] = "button"
|
45
|
-
end
|
46
|
-
|
47
|
-
def component
|
48
|
-
return Primer::BaseComponent.new(**@system_arguments) unless @button
|
49
|
-
|
50
|
-
Primer::ButtonComponent.new(**@system_arguments)
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
# Use the Body slot as the main content to be shown when triggered by the Summary.
|
55
|
-
class Body < Primer::Slot
|
56
|
-
# @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
|
57
|
-
def initialize(**system_arguments)
|
58
|
-
@system_arguments = system_arguments
|
59
|
-
@system_arguments[:tag] ||= :div
|
60
|
-
end
|
61
|
-
|
62
|
-
def component
|
63
|
-
Primer::BaseComponent.new(**@system_arguments)
|
64
|
-
end
|
65
|
-
end
|
66
52
|
end
|
67
53
|
end
|
@@ -1,9 +1,9 @@
|
|
1
1
|
<%= render(Primer::DetailsComponent.new(**@system_arguments)) do |c| %>
|
2
|
-
<% c.
|
2
|
+
<% c.summary(classes: @summary_classes) do %>
|
3
3
|
<%= button %>
|
4
4
|
<% end %>
|
5
5
|
|
6
|
-
<% c.
|
6
|
+
<% c.body do %>
|
7
7
|
<%= menu %>
|
8
8
|
<% end %>
|
9
9
|
<% end %>
|
@@ -1,7 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative "dropdown/menu_component"
|
4
|
-
|
5
3
|
module Primer
|
6
4
|
# Dropdowns are lightweight context menus for housing navigation and actions.
|
7
5
|
# They're great for instances where you don't need the full power (and code) of the select menu.
|
@@ -20,8 +18,8 @@ module Primer
|
|
20
18
|
# @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
|
21
19
|
renders_one :menu, Primer::Dropdown::MenuComponent
|
22
20
|
|
23
|
-
# @example
|
24
|
-
# <div
|
21
|
+
# @example Default
|
22
|
+
# <div>
|
25
23
|
# <%= render(Primer::DropdownComponent.new) do |c| %>
|
26
24
|
# <% c.button do %>
|
27
25
|
# Dropdown
|
@@ -37,8 +35,8 @@ module Primer
|
|
37
35
|
# <% end %>
|
38
36
|
# </div>
|
39
37
|
#
|
40
|
-
# @example
|
41
|
-
# <div
|
38
|
+
# @example With Direction
|
39
|
+
# <div>
|
42
40
|
# <%= render(Primer::DropdownComponent.new) do |c| %>
|
43
41
|
# <% c.button do %>
|
44
42
|
# Dropdown
|
@@ -18,14 +18,14 @@ module Primer
|
|
18
18
|
STATUSES[:deprecated]
|
19
19
|
end
|
20
20
|
|
21
|
-
# @example
|
22
|
-
# <div
|
21
|
+
# @example With a header
|
22
|
+
# <div>
|
23
23
|
# <%= render(Primer::DetailsComponent.new(overlay: :default, reset: true, position: :relative)) do |c| %>
|
24
|
-
# <% c.
|
24
|
+
# <% c.summary do %>
|
25
25
|
# Dropdown
|
26
26
|
# <% end %>
|
27
27
|
#
|
28
|
-
# <% c.
|
28
|
+
# <% c.body do %>
|
29
29
|
# <%= render(Primer::DropdownMenuComponent.new(header: "Options")) do %>
|
30
30
|
# <ul>
|
31
31
|
# <li><a class="dropdown-item" href="#url">Dropdown item</a></li>
|
@@ -1,9 +1,9 @@
|
|
1
1
|
<%= render Primer::BaseComponent.new(**@system_arguments) do %>
|
2
|
-
<%=
|
2
|
+
<%= primer(:octicon, icon: @icon) if @icon %>
|
3
3
|
<%= content %>
|
4
4
|
<% if @dismissible %>
|
5
5
|
<button class="flash-close js-flash-close" type="button" aria-label="Close">
|
6
|
-
<%=
|
6
|
+
<%= primer(:octicon, icon: "x") %>
|
7
7
|
</button>
|
8
8
|
<% end %>
|
9
9
|
|
@@ -22,22 +22,22 @@ module Primer
|
|
22
22
|
:danger => "flash-error",
|
23
23
|
:success => "flash-success"
|
24
24
|
}.freeze
|
25
|
-
# @example
|
25
|
+
# @example Variants
|
26
26
|
# <%= render(Primer::FlashComponent.new) { "This is a flash message!" } %>
|
27
27
|
# <%= render(Primer::FlashComponent.new(variant: :warning)) { "This is a warning flash message!" } %>
|
28
28
|
# <%= render(Primer::FlashComponent.new(variant: :danger)) { "This is a danger flash message!" } %>
|
29
29
|
# <%= render(Primer::FlashComponent.new(variant: :success)) { "This is a success flash message!" } %>
|
30
30
|
#
|
31
|
-
# @example
|
31
|
+
# @example Full width
|
32
32
|
# <%= render(Primer::FlashComponent.new(full: true)) { "This is a full width flash message!" } %>
|
33
33
|
#
|
34
|
-
# @example
|
34
|
+
# @example Dismissible
|
35
35
|
# <%= render(Primer::FlashComponent.new(dismissible: true)) { "This is a dismissible flash message!" } %>
|
36
36
|
#
|
37
|
-
# @example
|
37
|
+
# @example Icon
|
38
38
|
# <%= render(Primer::FlashComponent.new(icon: "people")) { "This is a flash message with an icon!" } %>
|
39
39
|
#
|
40
|
-
# @example
|
40
|
+
# @example With actions
|
41
41
|
# <%= render(Primer::FlashComponent.new) do |component| %>
|
42
42
|
# This is a flash message with actions!
|
43
43
|
# <% component.action do %>
|
@@ -35,28 +35,28 @@ module Primer
|
|
35
35
|
DEFAULT_DIRECTION = nil
|
36
36
|
ALLOWED_DIRECTIONS = [DEFAULT_DIRECTION, :column, :column_reverse, :row, :row_reverse].freeze
|
37
37
|
|
38
|
-
# @example
|
38
|
+
# @example Default
|
39
39
|
# <%= render(Primer::FlexComponent.new(bg: :gray)) do %>
|
40
40
|
# <%= render(Primer::BoxComponent.new(p: 5, bg: :gray_light, classes: "border")) { "Item 1" } %>
|
41
41
|
# <%= render(Primer::BoxComponent.new(p: 5, bg: :gray_light, classes: "border")) { "Item 2" } %>
|
42
42
|
# <%= render(Primer::BoxComponent.new(p: 5, bg: :gray_light, classes: "border")) { "Item 3" } %>
|
43
43
|
# <% end %>
|
44
44
|
#
|
45
|
-
# @example
|
45
|
+
# @example Justify center
|
46
46
|
# <%= render(Primer::FlexComponent.new(justify_content: :center, bg: :gray)) do %>
|
47
47
|
# <%= render(Primer::BoxComponent.new(p: 5, bg: :gray_light, classes: "border")) { "Item 1" } %>
|
48
48
|
# <%= render(Primer::BoxComponent.new(p: 5, bg: :gray_light, classes: "border")) { "Item 2" } %>
|
49
49
|
# <%= render(Primer::BoxComponent.new(p: 5, bg: :gray_light, classes: "border")) { "Item 3" } %>
|
50
50
|
# <% end %>
|
51
51
|
#
|
52
|
-
# @example
|
52
|
+
# @example Align end
|
53
53
|
# <%= render(Primer::FlexComponent.new(align_items: :end, bg: :gray)) do %>
|
54
54
|
# <%= render(Primer::BoxComponent.new(p: 5, bg: :gray_light, classes: "border")) { "Item 1" } %>
|
55
55
|
# <%= render(Primer::BoxComponent.new(p: 5, bg: :gray_light, classes: "border")) { "Item 2" } %>
|
56
56
|
# <%= render(Primer::BoxComponent.new(p: 5, bg: :gray_light, classes: "border")) { "Item 3" } %>
|
57
57
|
# <% end %>
|
58
58
|
#
|
59
|
-
# @example
|
59
|
+
# @example Direction column
|
60
60
|
# <%= render(Primer::FlexComponent.new(direction: :column, bg: :gray)) do %>
|
61
61
|
# <%= render(Primer::BoxComponent.new(p: 5, bg: :gray_light, classes: "border")) { "Item 1" } %>
|
62
62
|
# <%= render(Primer::BoxComponent.new(p: 5, bg: :gray_light, classes: "border")) { "Item 2" } %>
|
@@ -7,7 +7,7 @@ module Primer
|
|
7
7
|
FLEX_AUTO_DEFAULT = false
|
8
8
|
FLEX_AUTO_ALLOWED_VALUES = [FLEX_AUTO_DEFAULT, true].freeze
|
9
9
|
|
10
|
-
# @example
|
10
|
+
# @example Default
|
11
11
|
# <%= render(Primer::FlexComponent.new) do %>
|
12
12
|
# <%= render(Primer::FlexItemComponent.new) do %>
|
13
13
|
# Item 1
|
@@ -3,7 +3,9 @@
|
|
3
3
|
module Primer
|
4
4
|
# Use the Heading component to wrap a component that will create a heading element
|
5
5
|
class HeadingComponent < Primer::Component
|
6
|
-
|
6
|
+
view_helper :heading
|
7
|
+
|
8
|
+
# @example Default
|
7
9
|
# <%= render(Primer::HeadingComponent.new) { "H1 Text" } %>
|
8
10
|
# <%= render(Primer::HeadingComponent.new(tag: :h2)) { "H2 Text" } %>
|
9
11
|
# <%= render(Primer::HeadingComponent.new(tag: :h3)) { "H3 Text" } %>
|
@@ -3,30 +3,17 @@
|
|
3
3
|
module Primer
|
4
4
|
# Use labels to add contextual metadata to a design.
|
5
5
|
class LabelComponent < Primer::Component
|
6
|
-
|
6
|
+
SCHEME_MAPPINGS = {
|
7
7
|
primary: "Label--primary",
|
8
8
|
secondary: "Label--secondary",
|
9
9
|
info: "Label--info",
|
10
10
|
success: "Label--success",
|
11
11
|
warning: "Label--warning",
|
12
|
-
danger: "Label--danger"
|
13
|
-
|
14
|
-
|
15
|
-
DEPRECATED_SCHEME_MAPPINGS = {
|
16
|
-
gray: "Label--gray",
|
17
|
-
dark_gray: "Label--gray-darker",
|
18
|
-
yellow: "Label--yellow",
|
12
|
+
danger: "Label--danger",
|
13
|
+
# deprecated
|
19
14
|
orange: "Label--orange",
|
20
|
-
|
21
|
-
green: "Label--green",
|
22
|
-
blue: "Label--blue",
|
23
|
-
purple: "Label--purple",
|
24
|
-
pink: "Label--pink",
|
25
|
-
outline: "Label--outline",
|
26
|
-
green_outline: "Label--outline-green"
|
15
|
+
purple: "Label--purple"
|
27
16
|
}.freeze
|
28
|
-
|
29
|
-
SCHEME_MAPPINGS = NEW_SCHEME_MAPPINGS.merge(DEPRECATED_SCHEME_MAPPINGS)
|
30
17
|
SCHEME_OPTIONS = SCHEME_MAPPINGS.keys << nil
|
31
18
|
|
32
19
|
VARIANT_MAPPINGS = {
|
@@ -35,20 +22,25 @@ module Primer
|
|
35
22
|
}.freeze
|
36
23
|
VARIANT_OPTIONS = VARIANT_MAPPINGS.keys << nil
|
37
24
|
|
38
|
-
# @example
|
39
|
-
# <%= render(Primer::LabelComponent.new(title: "Label: Label")) { "
|
40
|
-
# <%= render(Primer::LabelComponent.new(title: "Label: Label", scheme: :
|
41
|
-
# <%= render(Primer::LabelComponent.new(title: "Label: Label", scheme: :
|
42
|
-
# <%= render(Primer::LabelComponent.new(title: "Label: Label", scheme: :
|
43
|
-
# <%= render(Primer::LabelComponent.new(title: "Label: Label", scheme: :
|
44
|
-
# <%= render(Primer::LabelComponent.new(title: "Label: Label", scheme: :
|
25
|
+
# @example Schemes
|
26
|
+
# <%= render(Primer::LabelComponent.new(title: "Label: Label")) { "Default" } %>
|
27
|
+
# <%= render(Primer::LabelComponent.new(title: "Label: Label", scheme: :primary)) { "Primary" } %>
|
28
|
+
# <%= render(Primer::LabelComponent.new(title: "Label: Label", scheme: :secondary)) { "Secondary" } %>
|
29
|
+
# <%= render(Primer::LabelComponent.new(title: "Label: Label", scheme: :info)) { "Info" } %>
|
30
|
+
# <%= render(Primer::LabelComponent.new(title: "Label: Label", scheme: :success)) { "Success" } %>
|
31
|
+
# <%= render(Primer::LabelComponent.new(title: "Label: Label", scheme: :warning)) { "Warning" } %>
|
32
|
+
# <%= render(Primer::LabelComponent.new(title: "Label: Label", scheme: :danger)) { "Danger" } %>
|
45
33
|
#
|
46
|
-
# @example
|
34
|
+
# @example Variants
|
47
35
|
# <%= render(Primer::LabelComponent.new(title: "Label: Label")) { "Default" } %>
|
48
36
|
# <%= render(Primer::LabelComponent.new(title: "Label: Label", variant: :large)) { "Large" } %>
|
49
37
|
#
|
38
|
+
# @example Deprecated schemes
|
39
|
+
# <%= render(Primer::LabelComponent.new(title: "Label: Label", scheme: :orange)) { "Orange" } %>
|
40
|
+
# <%= render(Primer::LabelComponent.new(title: "Label: Label", scheme: :purple)) { "Purple" } %>
|
41
|
+
#
|
50
42
|
# @param title [String] `title` attribute for the component element.
|
51
|
-
# @param scheme [Symbol] <%= one_of(Primer::LabelComponent::
|
43
|
+
# @param scheme [Symbol] <%= one_of(Primer::LabelComponent::SCHEME_MAPPINGS.keys) %>
|
52
44
|
# @param variant [Symbol] <%= one_of(Primer::LabelComponent::VARIANT_OPTIONS) %>
|
53
45
|
# @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
|
54
46
|
def initialize(title:, scheme: nil, variant: nil, **system_arguments)
|
@@ -67,5 +59,9 @@ module Primer
|
|
67
59
|
def call
|
68
60
|
render(Primer::BaseComponent.new(**@system_arguments)) { content }
|
69
61
|
end
|
62
|
+
|
63
|
+
def self.status
|
64
|
+
Primer::Component::STATUSES[:beta]
|
65
|
+
end
|
70
66
|
end
|
71
67
|
end
|