primer_view_components 0.0.88 → 0.0.91
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 +44 -0
- data/app/assets/javascripts/primer_view_components.js +1 -1
- data/app/assets/javascripts/primer_view_components.js.map +1 -1
- data/app/assets/styles/primer_view_components.css +0 -0
- data/app/assets/styles/primer_view_components.css.map +1 -0
- data/app/components/primer/alpha/auto_complete.rb +2 -2
- data/app/components/primer/alpha/hidden_text_expander.rb +57 -0
- data/app/components/primer/alpha/layout.rb +34 -32
- data/app/components/primer/alpha/segmented-control-element.js +5 -4
- data/app/components/primer/alpha/tab_nav.rb +20 -20
- data/app/components/primer/alpha/tab_panels.rb +2 -2
- data/app/components/primer/alpha/tool-tip-element.d.ts +1 -3
- data/app/components/primer/alpha/tool-tip-element.js +13 -19
- data/app/components/primer/alpha/tool-tip-element.ts +14 -22
- data/app/components/primer/alpha/tooltip.rb +72 -53
- data/app/components/primer/alpha/underline_nav.rb +16 -16
- data/app/components/primer/alpha/underline_panels.rb +3 -3
- data/app/components/primer/base_component.rb +1 -1
- data/app/components/primer/beta/auto_complete/item.rb +2 -2
- data/app/components/primer/beta/auto_complete.rb +2 -2
- data/app/components/primer/beta/avatar_stack.rb +9 -9
- data/app/components/primer/beta/blankslate.rb +2 -2
- data/app/components/primer/beta/border_box/header.rb +4 -2
- data/app/components/primer/beta/border_box.rb +13 -13
- data/app/components/primer/beta/breadcrumbs.rb +3 -3
- data/app/components/primer/beta/button_group.rb +9 -9
- data/app/components/primer/beta/close_button.rb +41 -0
- data/app/components/primer/beta/counter.rb +113 -0
- data/app/components/primer/{details_component.html.erb → beta/details.html.erb} +0 -0
- data/app/components/primer/beta/details.rb +70 -0
- data/app/components/primer/beta/flash.rb +1 -1
- data/app/components/primer/beta/heading.rb +46 -0
- data/app/components/primer/beta/truncate.rb +17 -17
- data/app/components/primer/blankslate_component.rb +1 -1
- data/app/components/primer/button_component.rb +8 -8
- data/app/components/primer/close_button.rb +2 -34
- data/app/components/primer/counter_component.rb +2 -106
- data/app/components/primer/details_component.rb +2 -63
- data/app/components/primer/dropdown.html.erb +1 -1
- data/app/components/primer/dropdown.rb +15 -15
- data/app/components/primer/dropdown_menu_component.rb +1 -1
- data/app/components/primer/heading_component.rb +2 -39
- data/app/components/primer/hidden_text_expander.rb +2 -48
- data/app/components/primer/icon_button.html.erb +8 -2
- data/app/components/primer/icon_button.rb +7 -0
- data/app/components/primer/image_crop.rb +1 -1
- data/app/components/primer/label_component.rb +2 -1
- data/app/components/primer/layout_component.rb +4 -4
- data/app/components/primer/link_component.rb +1 -1
- data/app/components/primer/menu_component.rb +5 -5
- data/app/components/primer/navigation/tab_component.rb +12 -12
- data/app/components/primer/popover_component.rb +10 -10
- data/app/components/primer/primer.pcss +1 -0
- data/app/components/primer/subhead_component.rb +10 -10
- data/app/components/primer/timeline_item_component.rb +3 -3
- data/app/lib/primer/join_style_arguments_helper.rb +1 -1
- data/app/lib/primer/view_helper.rb +1 -1
- data/lib/primer/view_components/linters/argument_mappers/close_button.rb +2 -2
- data/lib/primer/view_components/linters/close_button_component_migration_counter.rb +2 -2
- data/lib/primer/view_components/linters/flash_migration_counter.rb +1 -1
- data/lib/primer/view_components/linters/helpers/deprecated_components_helpers.rb +5 -0
- data/lib/primer/view_components/version.rb +1 -1
- data/lib/rubocop/cop/primer/component_name_migration.rb +5 -0
- data/lib/tasks/docs.rake +5 -5
- data/static/arguments.yml +87 -87
- data/static/audited_at.json +5 -0
- data/static/constants.json +54 -44
- data/static/statuses.json +11 -6
- metadata +11 -3
@@ -2,82 +2,101 @@
|
|
2
2
|
|
3
3
|
module Primer
|
4
4
|
module Alpha
|
5
|
-
# `Tooltip` only appears on mouse hover or keyboard focus and contain a label or description text.
|
6
|
-
# Use tooltips
|
7
|
-
#
|
8
|
-
# When using a tooltip, follow the provided guidelines to avoid accessibility issues.
|
9
|
-
#
|
10
|
-
# - Tooltip text should be brief and to the point. The tooltip content must be a string.
|
11
|
-
# - Tooltips should contain only **non-essential text**. Tooltips can easily be missed and are not accessible on touch devices so never
|
12
|
-
# use tooltips to convey critical information.
|
5
|
+
# `Tooltip` only appears on mouse hover or keyboard focus and contain a label or description text. Use tooltips sparingly and as a last resort.
|
6
|
+
# Use tooltips as a last resort. Please consider [Tooltips alternatives](https://primer.style/design/accessibility/tooltip-alternatives).
|
13
7
|
#
|
8
|
+
# When using a tooltip, follow the provided guidelines to avoid accessibility issues:
|
9
|
+
# - Tooltips should contain only **non-essential text**. Tooltips can easily be missed and are not accessible on touch devices so never use tooltips to convey critical information.
|
10
|
+
# - `Tooltip` should be rendered through the API of <%= link_to_component(Primer::ButtonComponent)%>, <%= link_to_component(Primer::LinkComponent)%>, or <%= link_to_component(Primer::IconButton)%>. Avoid using `Tooltip` a standalone component unless absolutely necessary (and **only** on interactive elements).
|
14
11
|
# @accessibility
|
15
|
-
# -
|
16
|
-
#
|
17
|
-
# -
|
12
|
+
# - Tooltip text must be brief and concise whether it is a label or a description.
|
13
|
+
# - Tooltip can only hold string content.
|
14
|
+
# - **Never set tooltips on static, non-interactive elements** like `span` or `div`. Tooltips should only be used on interactive elements like buttons or links to avoid excluding keyboard-only users
|
15
|
+
# and screen reader users. Use of tooltip through <%= link_to_component(Primer::ButtonComponent) %>, <%= link_to_component(Primer::LinkComponent) %>, or <%= link_to_component(Primer::IconButton) %> will guarantee this.
|
16
|
+
# - If you must use `Tooltip` as a standalone component, place it adjacent after the trigger element in the DOM. This allows screen reader users to navigate to and copy the tooltip
|
18
17
|
# content.
|
19
|
-
# ### Which
|
20
|
-
#
|
21
|
-
#
|
22
|
-
#
|
23
|
-
# - When there is already a visible label text on the trigger element, the tooltip is likely intended to supplement the existing text, so set `type: :description`.
|
18
|
+
# ### Which type should I set?
|
19
|
+
# Semantically, a tooltip will either act an accessible name or an accessible description for the element that it is associated with resulting in either a
|
20
|
+
# `aria-labelledby` or an `aria-describedby` association. The `type` drastically changes semantics and screen reader behavior so follow these guidelines carefully:
|
21
|
+
# - When there is already a visible label text on the trigger element, the tooltip is likely intended be supplementary, so set `type: :description`.
|
24
22
|
# The majority of tooltips will fall under this category.
|
25
23
|
# - When there is no visible text on the trigger element and the tooltip content is appropriate as a label for the element, set `type: :label`.
|
26
|
-
#
|
24
|
+
# `label` type is usually only appropriate for an icon-only control.
|
27
25
|
class Tooltip < Primer::Component
|
28
26
|
DIRECTION_DEFAULT = :s
|
29
27
|
DIRECTION_OPTIONS = [DIRECTION_DEFAULT, :n, :e, :w, :ne, :nw, :se, :sw].freeze
|
30
28
|
|
31
29
|
TYPE_FALLBACK = :description
|
32
30
|
TYPE_OPTIONS = [:label, :description].freeze
|
33
|
-
# @example As a description for
|
31
|
+
# @example As a supplementary description for a button
|
34
32
|
# @description
|
35
|
-
#
|
36
|
-
#
|
33
|
+
# In this example, the button has a visible label text, "Save". `type: :description` is set because the tooltip content is supplementary.
|
34
|
+
# A screen reader user who encounters this button will hear the accessible name, "Save" followed by the accessible description, "This will immediately impact all organization members".
|
37
35
|
# @code
|
38
|
-
# <%= render(Primer::
|
39
|
-
#
|
40
|
-
#
|
36
|
+
# <%= render(Primer::ButtonComponent.new(id: "save-button")) do |c| %>
|
37
|
+
# <% c.with_tooltip(text: "This will immediately impact all organization members", type: :description, direction: :ne) %>
|
38
|
+
# Save
|
39
|
+
# <% end %>
|
40
|
+
# @example As a label for an `IconButton`
|
41
41
|
# @description
|
42
|
-
#
|
42
|
+
# An `IconButton` of `tag: :button` and `tag: :a` will render a tooltip using the `aria-label` content by default. While tooltips should generally be avoided, a tooltip on an `IconButton`
|
43
|
+
# has usability benefits because it provides a textual label for sighted users.
|
44
|
+
# A screen reader user who encounters the following button will hear the accessible name, "Bold".
|
43
45
|
# @code
|
44
|
-
# <%= render(Primer::
|
45
|
-
#
|
46
|
-
#
|
47
|
-
# @example As a description for a button with visible label
|
46
|
+
# <%= render(Primer::IconButton.new(id: "bold-button-0", icon: :bold, "aria-label": "Bold")) %>
|
47
|
+
# @example As a supplementary description for an `IconButton`
|
48
48
|
# @description
|
49
|
-
# If
|
49
|
+
# If you want to provide a description for the `IconButton`, set both `aria-label` and `aria-description` text. The tooltip will use the `aria-description` text.
|
50
|
+
# A screen reader user who encounters the following button will hear the accessible name "Search", followed by the accessible description "Use keywords like 'repo:' and 'org:' in your query".
|
50
51
|
# @code
|
51
|
-
# <%= render(Primer::
|
52
|
-
#
|
52
|
+
# <%= render(Primer::IconButton.new(id: "search-button", icon: :search, "aria-label": "Search", "aria-description": "Use keywords like 'repo:' and 'org:' in your query")) %>
|
53
|
+
#
|
53
54
|
# @example With direction
|
54
55
|
# @description
|
55
56
|
# Set direction of tooltip with `direction`. The tooltip is responsive and will automatically adjust direction to avoid cutting off.
|
56
57
|
# @code
|
57
|
-
# <%= render(Primer::ButtonComponent.new(id: "North", m: 2))
|
58
|
-
#
|
59
|
-
#
|
60
|
-
#
|
61
|
-
# <%= render(Primer::ButtonComponent.new(id: "
|
62
|
-
#
|
63
|
-
#
|
64
|
-
#
|
65
|
-
# <%= render(Primer::ButtonComponent.new(id: "
|
66
|
-
#
|
67
|
-
#
|
68
|
-
#
|
69
|
-
# <%= render(Primer::ButtonComponent.new(id: "
|
70
|
-
#
|
71
|
-
#
|
72
|
-
#
|
73
|
-
#
|
58
|
+
# <%= render(Primer::ButtonComponent.new(id: "North", m: 2)) do |c| %>
|
59
|
+
# <% c.with_tooltip(text: "This is a North-facing tooltip, and is responsive.", type: :description, direction: :n) %>
|
60
|
+
# North
|
61
|
+
# <% end %>
|
62
|
+
# <%= render(Primer::ButtonComponent.new(id: "South", m: 2)) do |c| %>
|
63
|
+
# <% c.with_tooltip(text: "This is a South-facing tooltip, and is responsive.", type: :description, direction: :s) %>
|
64
|
+
# South
|
65
|
+
# <% end %>
|
66
|
+
# <%= render(Primer::ButtonComponent.new(id: "East", m: 2)) do |c| %>
|
67
|
+
# <% c.with_tooltip(text: "This is a East-facing tooltip, and is responsive.", type: :description, direction: :e) %>
|
68
|
+
# East
|
69
|
+
# <% end %>
|
70
|
+
# <%= render(Primer::ButtonComponent.new(id: "West", m: 2)) do |c| %>
|
71
|
+
# <% c.with_tooltip(text: "This is a West-facing tooltip, and is responsive.", type: :description, direction: :w) %>
|
72
|
+
# West
|
73
|
+
# <% end %>
|
74
|
+
# <%= render(Primer::ButtonComponent.new(id: "Northwest", m: 2)) do |c| %>
|
75
|
+
# <% c.with_tooltip(text: "This is a Northwest-facing tooltip, and is responsive.", type: :description, direction: :nw) %>
|
76
|
+
# Northwest
|
77
|
+
# <% end %>
|
78
|
+
# <%= render(Primer::ButtonComponent.new(id: "Southwest", m: 2)) do |c| %>
|
79
|
+
# <% c.with_tooltip(text: "This is a Southwest-facing tooltip, and is responsive.", type: :description, direction: :sw) %>
|
80
|
+
# Southwest
|
81
|
+
# <% end %>
|
82
|
+
# <%= render(Primer::ButtonComponent.new(id: "Northeast", m: 2)) do |c| %>
|
83
|
+
# <% c.with_tooltip(text: "This is a Northeast-facing tooltip, and is responsive.", type: :description, direction: :ne) %>
|
84
|
+
# Northeast
|
85
|
+
# <% end %>
|
86
|
+
# <%= render(Primer::ButtonComponent.new(id: "Southeast", m: 2)) do |c| %>
|
87
|
+
# <% c.with_tooltip(text: "This is a Southeast-facing tooltip, and is responsive.", type: :description, direction: :se) %>
|
88
|
+
# Southeast
|
89
|
+
# <% end %>
|
90
|
+
# @example Directly using `Tooltip`
|
74
91
|
# @description
|
75
|
-
# When
|
92
|
+
# When you have a valid tooltip usecase for an interactive element that is not one of the supported components, you may need to use the `Tooltip` component directly.
|
93
|
+
# The tooltip should be placed directly adjacent after the element you are associating it with.
|
94
|
+
# The tooltip is absolutely positioned so ensure there is a wrapper with `position: relative` to avoid positioning issues.
|
76
95
|
# @code
|
77
|
-
# <
|
78
|
-
#
|
96
|
+
# <div style="position: relative;">
|
97
|
+
# <button type="button" id="test-button">Test</button>
|
79
98
|
# <%= render(Primer::Alpha::Tooltip.new(for_id: "test-button", type: :description, text: "This tooltip should take up the full width", direction: :ne)) %>
|
80
|
-
# </
|
99
|
+
# </div>
|
81
100
|
# @param for_id [String] The ID of the element that the tooltip should be attached to.
|
82
101
|
# @param type [Symbol] <%= one_of(Primer::Alpha::Tooltip::TYPE_OPTIONS) %>
|
83
102
|
# @param direction [Symbol] <%= one_of(Primer::Alpha::Tooltip::DIRECTION_OPTIONS) %>
|
@@ -88,8 +107,8 @@ module Primer
|
|
88
107
|
|
89
108
|
@text = text
|
90
109
|
@system_arguments = system_arguments
|
110
|
+
@system_arguments[:hidden] = true
|
91
111
|
@system_arguments[:tag] = :"tool-tip"
|
92
|
-
@system_arguments[:style] = join_style_arguments(@system_arguments[:style], "visibility: hidden")
|
93
112
|
@system_arguments[:for] = for_id
|
94
113
|
@system_arguments[:position] = :absolute
|
95
114
|
@system_arguments[:"data-direction"] = fetch_or_fallback(DIRECTION_OPTIONS, direction, DIRECTION_DEFAULT).to_s
|
@@ -53,60 +53,60 @@ module Primer
|
|
53
53
|
# `<nav>` is a landmark and should be reserved for main navigation links. See <%= link_to_accessibility %>.
|
54
54
|
# @code
|
55
55
|
# <%= render(Primer::Alpha::UnderlineNav.new(label: "Default with nav element")) do |component| %>
|
56
|
-
# <% component.
|
57
|
-
# <% component.
|
58
|
-
# <% component.
|
56
|
+
# <% component.with_tab(href: "#", selected: true) { "Item 1" } %>
|
57
|
+
# <% component.with_tab(href: "#") { "Item 2" } %>
|
58
|
+
# <% component.with_actions do %>
|
59
59
|
# <%= render(Primer::ButtonComponent.new) { "Button!" } %>
|
60
60
|
# <% end %>
|
61
61
|
# <% end %>
|
62
62
|
#
|
63
63
|
# @example With `<div>`
|
64
64
|
# <%= render(Primer::Alpha::UnderlineNav.new(tag: :div, label: "With div element")) do |component| %>
|
65
|
-
# <% component.
|
66
|
-
# <% component.
|
67
|
-
# <% component.
|
65
|
+
# <% component.with_tab(href: "#", selected: true) { "Item 1" } %>
|
66
|
+
# <% component.with_tab(href: "#") { "Item 2" } %>
|
67
|
+
# <% component.with_actions do %>
|
68
68
|
# <%= render(Primer::ButtonComponent.new) { "Button!" } %>
|
69
69
|
# <% end %>
|
70
70
|
# <% end %>
|
71
71
|
#
|
72
72
|
# @example With icons and counters
|
73
73
|
# <%= render(Primer::Alpha::UnderlineNav.new(label: "With icons and counters")) do |component| %>
|
74
|
-
# <% component.
|
74
|
+
# <% component.with_tab(href: "#", selected: true) do |t| %>
|
75
75
|
# <% t.icon(icon: :star) %>
|
76
76
|
# <% t.text { "Item 1" } %>
|
77
77
|
# <% end %>
|
78
|
-
# <% component.
|
78
|
+
# <% component.with_tab(href: "#") do |t| %>
|
79
79
|
# <% t.icon(icon: :star) %>
|
80
80
|
# <% t.text { "Item 2" } %>
|
81
81
|
# <% t.counter(count: 10) %>
|
82
82
|
# <% end %>
|
83
|
-
# <% component.
|
83
|
+
# <% component.with_tab(href: "#") do |t| %>
|
84
84
|
# <% t.text { "Item 3" } %>
|
85
85
|
# <% t.counter(count: 10) %>
|
86
86
|
# <% end %>
|
87
|
-
# <% component.
|
87
|
+
# <% component.with_actions do %>
|
88
88
|
# <%= render(Primer::ButtonComponent.new) { "Button!" } %>
|
89
89
|
# <% end %>
|
90
90
|
# <% end %>
|
91
91
|
#
|
92
92
|
# @example Align right
|
93
93
|
# <%= render(Primer::Alpha::UnderlineNav.new(label: "Align right", align: :right)) do |component| %>
|
94
|
-
# <% component.
|
94
|
+
# <% component.with_tab(href: "#", selected: true) do |t| %>
|
95
95
|
# <% t.text { "Item 1" } %>
|
96
96
|
# <% end %>
|
97
|
-
# <% component.
|
97
|
+
# <% component.with_tab(href: "#") do |t| %>
|
98
98
|
# <% t.text { "Item 2" } %>
|
99
99
|
# <% end %>
|
100
|
-
# <% component.
|
100
|
+
# <% component.with_actions do %>
|
101
101
|
# <%= render(Primer::ButtonComponent.new) { "Button!" } %>
|
102
102
|
# <% end %>
|
103
103
|
# <% end %>
|
104
104
|
#
|
105
105
|
# @example Customizing the body
|
106
106
|
# <%= render(Primer::Alpha::UnderlineNav.new(label: "Default", body_arguments: { classes: "custom-class", border: true, border_color: :accent_emphasis })) do |c| %>
|
107
|
-
# <% c.
|
108
|
-
# <% c.
|
109
|
-
# <% c.
|
107
|
+
# <% c.with_tab(selected: true, href: "#") { "Tab 1" }%>
|
108
|
+
# <% c.with_tab(href: "#") { "Tab 2" } %>
|
109
|
+
# <% c.with_tab(href: "#") { "Tab 3" } %>
|
110
110
|
# <% end %>
|
111
111
|
#
|
112
112
|
# @param tag [Symbol] <%= one_of(Primer::Alpha::UnderlineNav::TAG_OPTIONS) %>
|
@@ -38,19 +38,19 @@ module Primer
|
|
38
38
|
|
39
39
|
# @example Default
|
40
40
|
# <%= render(Primer::Alpha::UnderlinePanels.new(label: "With panels")) do |component| %>
|
41
|
-
# <% component.
|
41
|
+
# <% component.with_tab(id: "tab-1", selected: true) do |t| %>
|
42
42
|
# <% t.text { "Tab 1" } %>
|
43
43
|
# <% t.panel do %>
|
44
44
|
# Panel 1
|
45
45
|
# <% end %>
|
46
46
|
# <% end %>
|
47
|
-
# <% component.
|
47
|
+
# <% component.with_tab(id: "tab-2") do |t| %>
|
48
48
|
# <% t.text { "Tab 2" } %>
|
49
49
|
# <% t.panel do %>
|
50
50
|
# Panel 2
|
51
51
|
# <% end %>
|
52
52
|
# <% end %>
|
53
|
-
# <% component.
|
53
|
+
# <% component.with_actions do %>
|
54
54
|
# <%= render(Primer::ButtonComponent.new) { "Button!" } %>
|
55
55
|
# <% end %>
|
56
56
|
# <% end %>
|
@@ -22,11 +22,11 @@ module Primer
|
|
22
22
|
|
23
23
|
# The trailing visual rendered after the link.
|
24
24
|
#
|
25
|
-
# @param kwargs [Hash] The arguments accepted by <%= link_to_component(Primer::OcticonComponent) %>, <%= link_to_component(Primer::LabelComponent) %>, or <%= link_to_component(Primer::
|
25
|
+
# @param kwargs [Hash] The arguments accepted by <%= link_to_component(Primer::OcticonComponent) %>, <%= link_to_component(Primer::LabelComponent) %>, or <%= link_to_component(Primer::Beta::Counter) %>
|
26
26
|
renders_one :trailing_visual, types: {
|
27
27
|
icon: Primer::OcticonComponent,
|
28
28
|
label: Primer::LabelComponent,
|
29
|
-
counter: Primer::
|
29
|
+
counter: Primer::Beta::Counter
|
30
30
|
}
|
31
31
|
|
32
32
|
# Optional description
|
@@ -138,12 +138,12 @@ module Primer
|
|
138
138
|
#
|
139
139
|
# @example With custom classes for the input
|
140
140
|
# <%= render(Primer::Beta::AutoComplete.new(label_text: "Fruits", src: "/auto_complete", input_id: "fruits-input--custom-input", list_id: "fruits-popup--custom-input")) do |c| %>
|
141
|
-
# <% c.
|
141
|
+
# <% c.with_input(classes: "custom-class") %>
|
142
142
|
# <% end %>
|
143
143
|
#
|
144
144
|
# @example With custom classes for the results
|
145
145
|
# <%= render(Primer::Beta::AutoComplete.new(label_text: "Fruits", src: "/auto_complete", input_id: "fruits-input--custom-results", list_id: "fruits-popup--custom-results")) do |c| %>
|
146
|
-
# <% c.
|
146
|
+
# <% c.with_results(classes: "custom-class") %>
|
147
147
|
# <% end %>
|
148
148
|
#
|
149
149
|
# @param label_text [String] The label of the input.
|
@@ -21,23 +21,23 @@ module Primer
|
|
21
21
|
|
22
22
|
# @example Default
|
23
23
|
# <%= render(Primer::Beta::AvatarStack.new) do |c| %>
|
24
|
-
# <% c.
|
25
|
-
# <% c.
|
26
|
-
# <% c.
|
24
|
+
# <% c.with_avatar(src: "http://placekitten.com/200/200", alt: "@kittenuser") %>
|
25
|
+
# <% c.with_avatar(src: "http://placekitten.com/200/200", alt: "@kittenuser") %>
|
26
|
+
# <% c.with_avatar(src: "http://placekitten.com/200/200", alt: "@kittenuser") %>
|
27
27
|
# <% end %>
|
28
28
|
#
|
29
29
|
# @example Align right
|
30
30
|
# <%= render(Primer::Beta::AvatarStack.new(align: :right)) do |c| %>
|
31
|
-
# <% c.
|
32
|
-
# <% c.
|
33
|
-
# <% c.
|
31
|
+
# <% c.with_avatar(src: "http://placekitten.com/200/200", alt: "@kittenuser") %>
|
32
|
+
# <% c.with_avatar(src: "http://placekitten.com/200/200", alt: "@kittenuser") %>
|
33
|
+
# <% c.with_avatar(src: "http://placekitten.com/200/200", alt: "@kittenuser") %>
|
34
34
|
# <% end %>
|
35
35
|
#
|
36
36
|
# @example With tooltip
|
37
37
|
# <%= render(Primer::Beta::AvatarStack.new(tooltipped: true, body_arguments: { label: 'This is a tooltip!' })) do |c| %>
|
38
|
-
# <% c.
|
39
|
-
# <% c.
|
40
|
-
# <% c.
|
38
|
+
# <% c.with_avatar(src: "http://placekitten.com/200/200", alt: "@kittenuser") %>
|
39
|
+
# <% c.with_avatar(src: "http://placekitten.com/200/200", alt: "@kittenuser") %>
|
40
|
+
# <% c.with_avatar(src: "http://placekitten.com/200/200", alt: "@kittenuser") %>
|
41
41
|
# <% end %>
|
42
42
|
#
|
43
43
|
# @param tag [Symbol] <%= one_of(Primer::Beta::AvatarStack::TAG_OPTIONS) %>
|
@@ -46,14 +46,14 @@ module Primer
|
|
46
46
|
|
47
47
|
# Required heading.
|
48
48
|
#
|
49
|
-
# @param tag [String] <%= one_of(Primer::
|
49
|
+
# @param tag [String] <%= one_of(Primer::Beta::Heading::TAG_OPTIONS) %>
|
50
50
|
# @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
|
51
51
|
renders_one :heading, lambda { |tag:, **system_arguments|
|
52
52
|
deny_tag_argument(**system_arguments)
|
53
53
|
system_arguments[:tag] = tag
|
54
54
|
system_arguments[:classes] = class_names("blankslate-heading", system_arguments[:classes])
|
55
55
|
|
56
|
-
Primer::
|
56
|
+
Primer::Beta::Heading.new(**system_arguments)
|
57
57
|
}
|
58
58
|
|
59
59
|
# Optional description.
|
@@ -5,8 +5,10 @@ module Primer
|
|
5
5
|
class BorderBox
|
6
6
|
# `BorderBox::Header` is used inside `BorderBox` to render its header slot.
|
7
7
|
#
|
8
|
-
# @accessibility When using `header.
|
8
|
+
# @accessibility When using `header.with_title`, set `tag` to one of `h1`, `h2`, `h3`, etc. based on what is appropriate for the page context. <%= link_to_heading_practices %>
|
9
9
|
class Header < Primer::Component
|
10
|
+
status :beta
|
11
|
+
|
10
12
|
TITLE_TAG_FALLBACK = :h2
|
11
13
|
TITLE_TAG_OPTIONS = [:h1, TITLE_TAG_FALLBACK, :h3, :h4, :h5, :h6].freeze
|
12
14
|
|
@@ -32,7 +34,7 @@ module Primer
|
|
32
34
|
#
|
33
35
|
# @example with title
|
34
36
|
# <%= render(Primer::Beta::BorderBox::Header.new) do |h| %>
|
35
|
-
# <% h.
|
37
|
+
# <% h.with_title(tag: :h3) do %>I am a title<% end %>
|
36
38
|
# <% end %>
|
37
39
|
#
|
38
40
|
# @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
|
@@ -72,55 +72,55 @@ module Primer
|
|
72
72
|
|
73
73
|
# @example Header with title, body, rows, and footer
|
74
74
|
# <%= render(Primer::Beta::BorderBox.new) do |component| %>
|
75
|
-
# <% component.
|
75
|
+
# <% component.with_header do |h| %>
|
76
76
|
# <% h.title(tag: :h2) do %>
|
77
77
|
# Header
|
78
78
|
# <% end %>
|
79
79
|
# <% end %>
|
80
|
-
# <% component.
|
80
|
+
# <% component.with_body do %>
|
81
81
|
# Body
|
82
82
|
# <% end %>
|
83
|
-
# <% component.
|
83
|
+
# <% component.with_row do %>
|
84
84
|
# <% if true %>
|
85
85
|
# Row one
|
86
86
|
# <% end %>
|
87
87
|
# <% end %>
|
88
|
-
# <% component.
|
88
|
+
# <% component.with_row do %>
|
89
89
|
# Row two
|
90
90
|
# <% end %>
|
91
|
-
# <% component.
|
91
|
+
# <% component.with_footer do %>
|
92
92
|
# Footer
|
93
93
|
# <% end %>
|
94
94
|
# <% end %>
|
95
95
|
#
|
96
96
|
# @example Padding density
|
97
97
|
# <%= render(Primer::Beta::BorderBox.new(padding: :condensed)) do |component| %>
|
98
|
-
# <% component.
|
98
|
+
# <% component.with_header do %>
|
99
99
|
# Header
|
100
100
|
# <% end %>
|
101
|
-
# <% component.
|
101
|
+
# <% component.with_body do %>
|
102
102
|
# Body
|
103
103
|
# <% end %>
|
104
|
-
# <% component.
|
104
|
+
# <% component.with_row do %>
|
105
105
|
# Row two
|
106
106
|
# <% end %>
|
107
|
-
# <% component.
|
107
|
+
# <% component.with_footer do %>
|
108
108
|
# Footer
|
109
109
|
# <% end %>
|
110
110
|
# <% end %>
|
111
111
|
#
|
112
112
|
# @example Row colors
|
113
113
|
# <%= render(Primer::Beta::BorderBox.new) do |component| %>
|
114
|
-
# <% component.
|
114
|
+
# <% component.with_row do %>
|
115
115
|
# Default
|
116
116
|
# <% end %>
|
117
|
-
# <% component.
|
117
|
+
# <% component.with_row(scheme: :neutral) do %>
|
118
118
|
# Neutral
|
119
119
|
# <% end %>
|
120
|
-
# <% component.
|
120
|
+
# <% component.with_row(scheme: :info) do %>
|
121
121
|
# Info
|
122
122
|
# <% end %>
|
123
|
-
# <% component.
|
123
|
+
# <% component.with_row(scheme: :warning) do %>
|
124
124
|
# Warning
|
125
125
|
# <% end %>
|
126
126
|
# <% end %>
|
@@ -33,9 +33,9 @@ module Primer
|
|
33
33
|
|
34
34
|
# @example Basic
|
35
35
|
# <%= render(Primer::Beta::Breadcrumbs.new) do |component| %>
|
36
|
-
# <% component.
|
37
|
-
# <% component.
|
38
|
-
# <% component.
|
36
|
+
# <% component.with_item(href: "/") do %>Home<% end %>
|
37
|
+
# <% component.with_item(href: "/about") do %>About<% end %>
|
38
|
+
# <% component.with_item(href: "/about/team") do %>Team<% end %>
|
39
39
|
# <% end %>
|
40
40
|
#
|
41
41
|
# @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
|
@@ -19,20 +19,20 @@ module Primer
|
|
19
19
|
# @example Default
|
20
20
|
#
|
21
21
|
# <%= render(Primer::Beta::ButtonGroup.new) do |component| %>
|
22
|
-
# <% component.
|
23
|
-
# <% component.
|
24
|
-
# <% component.
|
25
|
-
# <% component.
|
26
|
-
# <% component.
|
22
|
+
# <% component.with_button { "Default" } %>
|
23
|
+
# <% component.with_button(scheme: :primary) { "Primary" } %>
|
24
|
+
# <% component.with_button(scheme: :danger) { "Danger" } %>
|
25
|
+
# <% component.with_button(scheme: :outline) { "Outline" } %>
|
26
|
+
# <% component.with_button(classes: "custom-class") { "Custom class" } %>
|
27
27
|
# <% end %>
|
28
28
|
#
|
29
29
|
# @example Sizes
|
30
30
|
#
|
31
31
|
# <%= render(Primer::Beta::ButtonGroup.new(size: :small)) do |component| %>
|
32
|
-
# <% component.
|
33
|
-
# <% component.
|
34
|
-
# <% component.
|
35
|
-
# <% component.
|
32
|
+
# <% component.with_button { "Default" } %>
|
33
|
+
# <% component.with_button(scheme: :primary) { "Primary" } %>
|
34
|
+
# <% component.with_button(scheme: :danger) { "Danger" } %>
|
35
|
+
# <% component.with_button(scheme: :outline) { "Outline" } %>
|
36
36
|
# <% end %>
|
37
37
|
#
|
38
38
|
# @param variant [Symbol] DEPRECATED. <%= one_of(Primer::ButtonComponent::SIZE_OPTIONS) %>
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Primer
|
4
|
+
module Beta
|
5
|
+
# Use `CloseButton` to render an `×` without default button styles.
|
6
|
+
#
|
7
|
+
# @accessibility
|
8
|
+
# `CloseButton` has a default `aria-label` of "Close" to provides assistive technologies with an accessible label.
|
9
|
+
# You may choose to override this label with something more descriptive via [system_arguments][0].
|
10
|
+
# [0]: https://primer.style/view-components/system-arguments#html-attributes
|
11
|
+
class CloseButton < Primer::Component
|
12
|
+
status :beta
|
13
|
+
|
14
|
+
DEFAULT_TYPE = :button
|
15
|
+
TYPE_OPTIONS = [DEFAULT_TYPE, :submit].freeze
|
16
|
+
|
17
|
+
# @example Default
|
18
|
+
# <%= render(Primer::Beta::CloseButton.new) %>
|
19
|
+
#
|
20
|
+
# @param type [Symbol] <%= one_of(Primer::Beta::CloseButton::TYPE_OPTIONS) %>
|
21
|
+
# @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
|
22
|
+
def initialize(type: DEFAULT_TYPE, **system_arguments)
|
23
|
+
@system_arguments = deny_tag_argument(**system_arguments)
|
24
|
+
@system_arguments[:tag] = :button
|
25
|
+
@system_arguments[:block] = false
|
26
|
+
@system_arguments[:type] = fetch_or_fallback(TYPE_OPTIONS, type, DEFAULT_TYPE)
|
27
|
+
@system_arguments[:classes] = class_names(
|
28
|
+
"close-button",
|
29
|
+
system_arguments[:classes]
|
30
|
+
)
|
31
|
+
@system_arguments[:"aria-label"] ||= "Close"
|
32
|
+
end
|
33
|
+
|
34
|
+
def call
|
35
|
+
render(Primer::Beta::BaseButton.new(**@system_arguments)) do
|
36
|
+
render(Primer::OcticonComponent.new("x"))
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|