primer_view_components 0.0.50 → 0.0.54
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 +136 -0
- data/app/components/primer/alpha/underline_nav.html.erb +15 -0
- data/app/components/primer/alpha/underline_nav.rb +143 -0
- data/app/components/primer/{underline_nav_component.html.erb → alpha/underline_panels.html.erb} +3 -8
- data/app/components/primer/alpha/underline_panels.rb +86 -0
- data/app/components/primer/base_component.rb +2 -2
- data/app/components/primer/beta/avatar_stack.rb +9 -9
- data/app/components/primer/{breadcrumb_component.html.erb → beta/breadcrumbs.html.erb} +0 -0
- data/app/components/primer/beta/breadcrumbs.rb +59 -0
- 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.rb +1 -1
- data/app/components/primer/dropdown.rb +7 -7
- data/app/components/primer/icon_button.rb +1 -1
- data/app/components/primer/navigation/tab_component.rb +7 -5
- data/app/components/primer/progress_bar_component.rb +0 -3
- data/app/components/primer/tab_nav_component.html.erb +1 -1
- 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/tabbed_component_helper.rb +3 -3
- data/app/lib/primer/underline_nav_helper.rb +44 -0
- data/app/lib/primer/view_helper.rb +1 -0
- 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 +2 -2
- data/lib/primer/classify/validation.rb +18 -0
- data/lib/primer/classify.rb +5 -15
- data/lib/primer/view_components/constants.rb +1 -1
- data/lib/primer/view_components/linters/argument_mappers/base.rb +34 -8
- data/lib/primer/view_components/linters/argument_mappers/button.rb +5 -6
- data/lib/primer/view_components/linters/argument_mappers/clipboard_copy.rb +4 -3
- 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 +48 -5
- data/lib/primer/view_components/linters/argument_mappers/label.rb +3 -4
- data/lib/primer/view_components/linters/argument_mappers/system_arguments.rb +5 -7
- 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 +110 -3
- 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 +277 -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 +7 -5
- data/lib/tasks/utilities.rake +5 -3
- data/lib/yard/docs_helper.rb +6 -3
- data/static/arguments.yml +62 -37
- data/static/classes.yml +9 -0
- data/static/constants.json +38 -23
- data/static/statuses.json +8 -5
- metadata +37 -15
- data/app/components/primer/auto_complete/auto_component.d.ts +0 -1
- data/app/components/primer/auto_complete/auto_component.js +0 -1
- data/app/components/primer/breadcrumb_component.rb +0 -57
- data/app/components/primer/underline_nav_component.rb +0 -187
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c9b70049a9f24586f7b1239cdd97832cb9e813cc063ca475c77ae00ed448a6c4
|
4
|
+
data.tar.gz: 8df167c58fa86039a008d301969af68f7efa8e4345d49abf269cb09734ec1841
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7c87327784f69a03b4636e2952c98da1feb4b5c47776c8e46cd423ae562d25aa061c99f0ff3ebee605984816db3b3c6209fd7ddb5ed0577a1ed7b1ff8a68bbc8
|
7
|
+
data.tar.gz: c386eb3940ee79d8992b45168e18846863c6d503801674d13efe6ea8617cfc9d7a3957e3e324959c884d13bdd66113188ea23c9bcbf9dce00ff9eb54ce0deef3
|
data/CHANGELOG.md
CHANGED
@@ -30,8 +30,144 @@ The category for changes related to documentation, testing and tooling. Also, fo
|
|
30
30
|
|
31
31
|
## main
|
32
32
|
|
33
|
+
## 0.0.54
|
34
|
+
|
35
|
+
### Breaking changes
|
36
|
+
|
37
|
+
* Rename `BreadcrumbComponent` to `Beta::Breadcrumbs`.
|
38
|
+
|
39
|
+
*Joel Hawksley*
|
40
|
+
|
41
|
+
* Split `UnderlineNavComponent` into `Alpha::UnderlineNav` and `Alpha::UnderlinePanels`.
|
42
|
+
|
43
|
+
*Kate Higa*
|
44
|
+
|
45
|
+
## 0.0.53
|
46
|
+
|
47
|
+
### New
|
48
|
+
|
49
|
+
* Add autocorrection to `FlashComponent` linter when the context is basic text.
|
50
|
+
|
51
|
+
*Manuel Puyol*
|
52
|
+
|
53
|
+
### Updates
|
54
|
+
|
55
|
+
* Linters won't mark offenses when the ignore count is correct unless explicitly configured to do so.
|
56
|
+
|
57
|
+
*Manuel Puyol*
|
58
|
+
|
59
|
+
* Deprecating background and border color presentational arguments
|
60
|
+
|
61
|
+
*Jon Rohan*
|
62
|
+
|
63
|
+
* Map the `for` argument when autofixing `ClipboardCopy` migrations.
|
64
|
+
|
65
|
+
*Kristján Oddsson*
|
66
|
+
|
67
|
+
* Add autocorrection for `CloseButton` linter.
|
68
|
+
|
69
|
+
*Manuel Puyol*
|
70
|
+
|
71
|
+
### Bug fixes
|
72
|
+
|
73
|
+
* Linters won't convert HTML special elements.
|
74
|
+
|
75
|
+
*Manuel Puyol*
|
76
|
+
|
77
|
+
### Misc
|
78
|
+
|
79
|
+
* Only run CHANGELOG CI on pull requests.
|
80
|
+
|
81
|
+
*Manuel Puyol*
|
82
|
+
|
83
|
+
* Run CI actions on pushes to main.
|
84
|
+
|
85
|
+
*Cameron Dutro*
|
86
|
+
|
87
|
+
* Get to 100% code coverage.
|
88
|
+
|
89
|
+
*Cameron Dutro*
|
90
|
+
|
91
|
+
## 0.0.52
|
92
|
+
|
93
|
+
### New
|
94
|
+
|
95
|
+
* Adding `Primer::Beta::Truncate` component to reflect changes in primer/css component [Truncate](https://primer.style/css/components/truncate).
|
96
|
+
|
97
|
+
*Jon Rohan*
|
98
|
+
|
99
|
+
* Add cop to look for deprecated system arguments and suggest replacements.
|
100
|
+
|
101
|
+
*Jon Rohan*
|
102
|
+
|
103
|
+
* Add cop to use `primer_octicon` in favor of `octicon`.
|
104
|
+
|
105
|
+
*Manuel Puyol*
|
106
|
+
|
107
|
+
* Fix release script so it doesn't loop continuously.
|
108
|
+
|
109
|
+
*Cameron Dutro*
|
110
|
+
|
111
|
+
### Updates
|
112
|
+
|
113
|
+
* Promote `ClipboardCopy` to beta.
|
114
|
+
|
115
|
+
*Manuel Puyol*
|
116
|
+
|
117
|
+
* PrimerOcticon linter supports `aria-` and `data-` attributes.
|
118
|
+
|
119
|
+
*Manuel Puyol*
|
120
|
+
|
121
|
+
* Linters can:
|
122
|
+
* convert values with ERB interpolations.
|
123
|
+
* autocorrect cases with custom classes.
|
124
|
+
|
125
|
+
*Manuel Puyol*
|
126
|
+
|
127
|
+
* Add a `scheme` option to `BorderBoxComponent` rows.
|
128
|
+
|
129
|
+
*Cameron Dutro*
|
130
|
+
|
131
|
+
* Upgrade rubocop and support Ruby 3.0.
|
132
|
+
|
133
|
+
*Cameron Dutro*
|
134
|
+
|
135
|
+
* Linters will not autocorrect cases where a required argument is missing.
|
136
|
+
|
137
|
+
*Manuel Puyol*
|
138
|
+
|
139
|
+
### Misc
|
140
|
+
|
141
|
+
* Update benchmarks to run in every supported Ruby version.
|
142
|
+
|
143
|
+
*Manuel Puyol*
|
144
|
+
|
145
|
+
* Add a linter generator.
|
146
|
+
|
147
|
+
*Manuel Puyol*
|
148
|
+
|
149
|
+
## 0.0.51
|
150
|
+
|
151
|
+
### Breaking changes
|
152
|
+
|
153
|
+
* Rename `width` and `height` System Arguments to `w` and `h`, resolving conflict with HTML attribute names.
|
154
|
+
|
155
|
+
*Manuel Puyol*
|
156
|
+
|
157
|
+
### Updates
|
158
|
+
|
159
|
+
* `SystemArgumentInsteadOfClass` linter will check for arguments in ViewHelpers.
|
160
|
+
|
161
|
+
*Manuel Puyol*
|
162
|
+
|
33
163
|
## 0.0.50
|
34
164
|
|
165
|
+
### Updates
|
166
|
+
|
167
|
+
* Fix incorrect slots syntax in docs.
|
168
|
+
|
169
|
+
*Joel Hawksley*, *Blake Williams*
|
170
|
+
|
35
171
|
### New
|
36
172
|
|
37
173
|
* Add linter suggestions for `CloseButton` component.
|
@@ -0,0 +1,15 @@
|
|
1
|
+
<%= render Primer::BaseComponent.new(**@system_arguments) do %>
|
2
|
+
<% if @align == :right %>
|
3
|
+
<%= actions %>
|
4
|
+
<% end %>
|
5
|
+
|
6
|
+
<%= render body do %>
|
7
|
+
<% tabs.each do |tab| %>
|
8
|
+
<%= tab %>
|
9
|
+
<% end %>
|
10
|
+
<% end %>
|
11
|
+
|
12
|
+
<% if @align == :left %>
|
13
|
+
<%= actions %>
|
14
|
+
<% end %>
|
15
|
+
<% end %>
|
@@ -0,0 +1,143 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Primer
|
4
|
+
module Alpha
|
5
|
+
# Use `UnderlineNav` to style navigation links with a minimal
|
6
|
+
# underlined selected state, typically placed at the top
|
7
|
+
# of the page.
|
8
|
+
# For panel navigation, use <%= link_to_component(Primer::Alpha::UnderlinePanels) %> instead.
|
9
|
+
#
|
10
|
+
# @accessibility
|
11
|
+
# - By default, `UnderlineNav` renders links within a `<nav>` element. `<nav>` has an
|
12
|
+
# implicit landmark role of `navigation` which should be reserved for main links.
|
13
|
+
# For all other set of links, set tag to `:div`.
|
14
|
+
# - See <%= link_to_component(Primer::Navigation::TabComponent) %> for additional
|
15
|
+
# accessibility considerations.
|
16
|
+
class UnderlineNav < Primer::Component
|
17
|
+
include Primer::TabbedComponentHelper
|
18
|
+
include Primer::UnderlineNavHelper
|
19
|
+
|
20
|
+
ALIGN_DEFAULT = :left
|
21
|
+
ALIGN_OPTIONS = [ALIGN_DEFAULT, :right].freeze
|
22
|
+
|
23
|
+
BODY_TAG_DEFAULT = :ul
|
24
|
+
|
25
|
+
TAG_DEFAULT = :nav
|
26
|
+
TAG_OPTIONS = [TAG_DEFAULT, :div].freeze
|
27
|
+
|
28
|
+
ACTIONS_TAG_DEFAULT = :div
|
29
|
+
ACTIONS_TAG_OPTIONS = [ACTIONS_TAG_DEFAULT, :span].freeze
|
30
|
+
|
31
|
+
# Use the tabs to list page links.
|
32
|
+
#
|
33
|
+
# @param selected [Boolean] Whether the tab is selected.
|
34
|
+
# @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
|
35
|
+
renders_many :tabs, lambda { |selected: false, **system_arguments|
|
36
|
+
system_arguments[:classes] = underline_nav_tab_classes(system_arguments[:classes])
|
37
|
+
Primer::Navigation::TabComponent.new(
|
38
|
+
list: true,
|
39
|
+
selected: selected,
|
40
|
+
icon_classes: "UnderlineNav-octicon",
|
41
|
+
**system_arguments
|
42
|
+
)
|
43
|
+
}
|
44
|
+
|
45
|
+
# Use actions for a call to action.
|
46
|
+
#
|
47
|
+
# @param tag [Symbol] (Primer::UnderlineNavHelper::ACTIONS_TAG_DEFAULT) <%= one_of(Primer::UnderlineNavHelper::ACTIONS_TAG_OPTIONS) %>
|
48
|
+
# @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
|
49
|
+
renders_one :actions, lambda { |tag: ACTIONS_TAG_DEFAULT, **system_arguments|
|
50
|
+
system_arguments[:tag] = fetch_or_fallback(ACTIONS_TAG_OPTIONS, tag, ACTIONS_TAG_DEFAULT)
|
51
|
+
system_arguments[:classes] = underline_nav_action_classes(system_arguments[:classes])
|
52
|
+
|
53
|
+
Primer::BaseComponent.new(**system_arguments)
|
54
|
+
}
|
55
|
+
|
56
|
+
# @example Default with `<nav>`
|
57
|
+
# @description
|
58
|
+
# `<nav>` is a landmark and should be reserved for main navigation links. See <%= link_to_accessibility %>.
|
59
|
+
# @code
|
60
|
+
# <%= render(Primer::Alpha::UnderlineNav.new(label: "Default with nav element")) do |component| %>
|
61
|
+
# <% component.tab(href: "#", selected: true) { "Item 1" } %>
|
62
|
+
# <% component.tab(href: "#") { "Item 2" } %>
|
63
|
+
# <% component.actions do %>
|
64
|
+
# <%= render(Primer::ButtonComponent.new) { "Button!" } %>
|
65
|
+
# <% end %>
|
66
|
+
# <% end %>
|
67
|
+
#
|
68
|
+
# @example With `<div>`
|
69
|
+
# <%= render(Primer::Alpha::UnderlineNav.new(tag: :div, label: "With div element")) do |component| %>
|
70
|
+
# <% component.tab(href: "#", selected: true) { "Item 1" } %>
|
71
|
+
# <% component.tab(href: "#") { "Item 2" } %>
|
72
|
+
# <% component.actions do %>
|
73
|
+
# <%= render(Primer::ButtonComponent.new) { "Button!" } %>
|
74
|
+
# <% end %>
|
75
|
+
# <% end %>
|
76
|
+
#
|
77
|
+
# @example With icons and counters
|
78
|
+
# <%= render(Primer::Alpha::UnderlineNav.new(label: "With icons and counters")) do |component| %>
|
79
|
+
# <% component.tab(href: "#", selected: true) do |t| %>
|
80
|
+
# <% t.icon(icon: :star) %>
|
81
|
+
# <% t.text { "Item 1" } %>
|
82
|
+
# <% end %>
|
83
|
+
# <% component.tab(href: "#") do |t| %>
|
84
|
+
# <% t.icon(icon: :star) %>
|
85
|
+
# <% t.text { "Item 2" } %>
|
86
|
+
# <% t.counter(count: 10) %>
|
87
|
+
# <% end %>
|
88
|
+
# <% component.tab(href: "#") do |t| %>
|
89
|
+
# <% t.text { "Item 3" } %>
|
90
|
+
# <% t.counter(count: 10) %>
|
91
|
+
# <% end %>
|
92
|
+
# <% component.actions do %>
|
93
|
+
# <%= render(Primer::ButtonComponent.new) { "Button!" } %>
|
94
|
+
# <% end %>
|
95
|
+
# <% end %>
|
96
|
+
#
|
97
|
+
# @example Align right
|
98
|
+
# <%= render(Primer::Alpha::UnderlineNav.new(label: "Align right", align: :right)) do |component| %>
|
99
|
+
# <% component.tab(href: "#", selected: true) do |t| %>
|
100
|
+
# <% t.text { "Item 1" } %>
|
101
|
+
# <% end %>
|
102
|
+
# <% component.tab(href: "#") do |t| %>
|
103
|
+
# <% t.text { "Item 2" } %>
|
104
|
+
# <% end %>
|
105
|
+
# <% component.actions do %>
|
106
|
+
# <%= render(Primer::ButtonComponent.new) { "Button!" } %>
|
107
|
+
# <% end %>
|
108
|
+
# <% end %>
|
109
|
+
#
|
110
|
+
# @example Customizing the body
|
111
|
+
# <%= render(Primer::Alpha::UnderlineNav.new(label: "Default", body_arguments: { classes: "custom-class", border: true, border_color: :info })) do |c| %>
|
112
|
+
# <% c.tab(selected: true, href: "#") { "Tab 1" }%>
|
113
|
+
# <% c.tab(href: "#") { "Tab 2" } %>
|
114
|
+
# <% c.tab(href: "#") { "Tab 3" } %>
|
115
|
+
# <% end %>
|
116
|
+
#
|
117
|
+
# @param tag [Symbol] <%= one_of(Primer::Alpha::UnderlineNav::TAG_OPTIONS) %>
|
118
|
+
# @param label [String] Sets an `aria-label` that helps assistive technology users understand the purpose of the links, and distinguish it from similar elements.
|
119
|
+
# @param align [Symbol] <%= one_of(Primer::UnderlineNavHelper::ALIGN_OPTIONS) %> - Defaults to <%= Primer::UnderlineNavHelper::ALIGN_DEFAULT %>
|
120
|
+
# @param body_arguments [Hash] <%= link_to_system_arguments_docs %> for the body wrapper.
|
121
|
+
# @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
|
122
|
+
def initialize(label:, tag: TAG_DEFAULT, align: ALIGN_DEFAULT, body_arguments: {}, **system_arguments)
|
123
|
+
@align = fetch_or_fallback(ALIGN_OPTIONS, align, ALIGN_DEFAULT)
|
124
|
+
|
125
|
+
@system_arguments = system_arguments
|
126
|
+
@system_arguments[:tag] = fetch_or_fallback(TAG_OPTIONS, tag, TAG_DEFAULT)
|
127
|
+
@system_arguments[:classes] = underline_nav_classes(@system_arguments[:classes], @align)
|
128
|
+
|
129
|
+
@body_arguments = body_arguments
|
130
|
+
@body_arguments[:tag] = :ul
|
131
|
+
@body_arguments[:classes] = underline_nav_body_classes(@body_arguments[:classes])
|
132
|
+
|
133
|
+
@system_arguments[:tag] == :nav ? @system_arguments[:"aria-label"] = label : @body_arguments[:"aria-label"] = label
|
134
|
+
end
|
135
|
+
|
136
|
+
private
|
137
|
+
|
138
|
+
def body
|
139
|
+
Primer::BaseComponent.new(**@body_arguments)
|
140
|
+
end
|
141
|
+
end
|
142
|
+
end
|
143
|
+
end
|
data/app/components/primer/{underline_nav_component.html.erb → alpha/underline_panels.html.erb}
RENAMED
@@ -1,23 +1,18 @@
|
|
1
|
-
<%= wrapper(**@wrapper_arguments) do %>
|
1
|
+
<%= wrapper(with_panel: true, **@wrapper_arguments) do %>
|
2
2
|
<%= render Primer::BaseComponent.new(**@system_arguments) do %>
|
3
3
|
<% if @align == :right %>
|
4
4
|
<%= actions %>
|
5
5
|
<% end %>
|
6
|
-
|
7
6
|
<%= render body do %>
|
8
7
|
<% tabs.each do |tab| %>
|
9
8
|
<%= tab %>
|
10
9
|
<% end %>
|
11
10
|
<% end %>
|
12
|
-
|
13
11
|
<% if @align == :left %>
|
14
12
|
<%= actions %>
|
15
13
|
<% end %>
|
16
14
|
<% end %>
|
17
|
-
|
18
|
-
|
19
|
-
<% tabs.each do |tab| %>
|
20
|
-
<%= tab.panel %>
|
21
|
-
<% end %>
|
15
|
+
<% tabs.each do |tab| %>
|
16
|
+
<%= tab.panel %>
|
22
17
|
<% end %>
|
23
18
|
<% end %>
|
@@ -0,0 +1,86 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Primer
|
4
|
+
module Alpha
|
5
|
+
# Use `UnderlinePanels` to style tabs with an associated panel and an underlined selected state.
|
6
|
+
class UnderlinePanels < Primer::Component
|
7
|
+
include Primer::TabbedComponentHelper
|
8
|
+
include Primer::UnderlineNavHelper
|
9
|
+
# Use to render a button and an associated panel slot. See the example below or refer to <%= link_to_component(Primer::Navigation::TabComponent) %>.
|
10
|
+
#
|
11
|
+
# @param id [String] Unique ID of tab.
|
12
|
+
# @param selected [Boolean] Whether the tab is selected.
|
13
|
+
# @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
|
14
|
+
renders_many :tabs, lambda { |id:, selected: false, **system_arguments|
|
15
|
+
system_arguments[:id] = id
|
16
|
+
system_arguments[:classes] = underline_nav_tab_classes(system_arguments[:classes])
|
17
|
+
|
18
|
+
Primer::Navigation::TabComponent.new(
|
19
|
+
selected: selected,
|
20
|
+
with_panel: true,
|
21
|
+
list: true,
|
22
|
+
icon_classes: "UnderlineNav-octicon",
|
23
|
+
panel_id: "panel-#{id}",
|
24
|
+
**system_arguments
|
25
|
+
)
|
26
|
+
}
|
27
|
+
|
28
|
+
# Use actions for a call to action.
|
29
|
+
#
|
30
|
+
# @param tag [Symbol] (Primer::UnderlineNavHelper::ACTIONS_TAG_DEFAULT) <%= one_of(Primer::UnderlineNavHelper::ACTIONS_TAG_OPTIONS) %>
|
31
|
+
# @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
|
32
|
+
renders_one :actions, lambda { |tag: ACTIONS_TAG_DEFAULT, **system_arguments|
|
33
|
+
system_arguments[:tag] = fetch_or_fallback(ACTIONS_TAG_OPTIONS, tag, ACTIONS_TAG_DEFAULT)
|
34
|
+
system_arguments[:classes] = underline_nav_action_classes(system_arguments[:classes])
|
35
|
+
|
36
|
+
Primer::BaseComponent.new(**system_arguments)
|
37
|
+
}
|
38
|
+
|
39
|
+
# @example Default
|
40
|
+
# <%= render(Primer::Alpha::UnderlinePanels.new(label: "With panels")) do |component| %>
|
41
|
+
# <% component.tab(id: "tab-1", selected: true) do |t| %>
|
42
|
+
# <% t.text { "Tab 1" } %>
|
43
|
+
# <% t.panel do %>
|
44
|
+
# Panel 1
|
45
|
+
# <% end %>
|
46
|
+
# <% end %>
|
47
|
+
# <% component.tab(id: "tab-2") do |t| %>
|
48
|
+
# <% t.text { "Tab 2" } %>
|
49
|
+
# <% t.panel do %>
|
50
|
+
# Panel 2
|
51
|
+
# <% end %>
|
52
|
+
# <% end %>
|
53
|
+
# <% component.actions do %>
|
54
|
+
# <%= render(Primer::ButtonComponent.new) { "Button!" } %>
|
55
|
+
# <% end %>
|
56
|
+
# <% end %>
|
57
|
+
#
|
58
|
+
# @param label [String] Sets an `aria-label` that helps assistive technology users understand the purpose of the tabs.
|
59
|
+
# @param align [Symbol] <%= one_of(Primer::UnderlineNavHelper::ALIGN_OPTIONS) %> - Defaults to <%= Primer::UnderlineNavHelper::ALIGN_DEFAULT %>
|
60
|
+
# @param body_arguments [Hash] <%= link_to_system_arguments_docs %> for the body wrapper.
|
61
|
+
# @param wrapper_arguments [Hash] <%= link_to_system_arguments_docs %> for the `TabContainer` wrapper.
|
62
|
+
# @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
|
63
|
+
def initialize(label:, align: ALIGN_DEFAULT, body_arguments: {}, wrapper_arguments: {}, **system_arguments)
|
64
|
+
@align = fetch_or_fallback(ALIGN_OPTIONS, align, ALIGN_DEFAULT)
|
65
|
+
@wrapper_arguments = wrapper_arguments
|
66
|
+
|
67
|
+
@system_arguments = system_arguments
|
68
|
+
@system_arguments[:tag] = :div
|
69
|
+
@system_arguments[:classes] = underline_nav_classes(@system_arguments[:classes], @align)
|
70
|
+
|
71
|
+
@body_arguments = body_arguments
|
72
|
+
@body_arguments[:tag] = :ul
|
73
|
+
@body_arguments[:classes] = underline_nav_body_classes(@body_arguments[:classes])
|
74
|
+
|
75
|
+
@body_arguments[:role] = :tablist
|
76
|
+
@body_arguments[:"aria-label"] = label
|
77
|
+
end
|
78
|
+
|
79
|
+
private
|
80
|
+
|
81
|
+
def body
|
82
|
+
Primer::BaseComponent.new(**@body_arguments)
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
@@ -93,8 +93,8 @@ module Primer
|
|
93
93
|
# | Name | Type | Description |
|
94
94
|
# | :- | :- | :- |
|
95
95
|
# | `display` | Symbol | <%= one_of(Primer::Classify::Utilities.mappings(:display)) %> |
|
96
|
-
# | `
|
97
|
-
# | `
|
96
|
+
# | `w` | Symbol | <%= one_of(Primer::Classify::Utilities.mappings(:w)) %> Also supports integer values. |
|
97
|
+
# | `h` | Symbol | <%= one_of(Primer::Classify::Utilities.mappings(:h)) %> Also supports integer values. |
|
98
98
|
# | `hide` | Symbol | Hide the element at a specific breakpoint. <%= one_of(Primer::Classify::Utilities.mappings(:hide)) %> |
|
99
99
|
# | `visibility` | Symbol | Visibility. <%= one_of(Primer::Classify::Utilities.mappings(:visibility)) %> |
|
100
100
|
# | `vertical_align` | Symbol | <%= one_of(Primer::Classify::Utilities.mappings(:vertical_align)) %> |
|
@@ -21,23 +21,23 @@ module Primer
|
|
21
21
|
|
22
22
|
# @example Default
|
23
23
|
# <%= render(Primer::Beta::AvatarStack.new) do |c| %>
|
24
|
-
#
|
25
|
-
#
|
26
|
-
#
|
24
|
+
# <% c.avatar(src: "http://placekitten.com/200/200", alt: "@kittenuser") %>
|
25
|
+
# <% c.avatar(src: "http://placekitten.com/200/200", alt: "@kittenuser") %>
|
26
|
+
# <% c.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
|
-
#
|
32
|
-
#
|
33
|
-
#
|
31
|
+
# <% c.avatar(src: "http://placekitten.com/200/200", alt: "@kittenuser") %>
|
32
|
+
# <% c.avatar(src: "http://placekitten.com/200/200", alt: "@kittenuser") %>
|
33
|
+
# <% c.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
|
-
#
|
39
|
-
#
|
40
|
-
#
|
38
|
+
# <% c.avatar(src: "http://placekitten.com/200/200", alt: "@kittenuser") %>
|
39
|
+
# <% c.avatar(src: "http://placekitten.com/200/200", alt: "@kittenuser") %>
|
40
|
+
# <% c.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) %>
|