primer_view_components 0.0.53 → 0.0.57

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.
Files changed (45) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +87 -0
  3. data/app/components/primer/alpha/tab_nav.html.erb +11 -0
  4. data/app/components/primer/alpha/tab_nav.rb +130 -0
  5. data/app/components/primer/{tab_nav_component.html.erb → alpha/tab_panels.html.erb} +3 -8
  6. data/app/components/primer/alpha/tab_panels.rb +82 -0
  7. data/app/components/primer/alpha/underline_nav.html.erb +15 -0
  8. data/app/components/primer/alpha/underline_nav.rb +137 -0
  9. data/app/components/primer/{underline_nav_component.html.erb → alpha/underline_panels.html.erb} +3 -8
  10. data/app/components/primer/alpha/underline_panels.rb +86 -0
  11. data/app/components/primer/base_component.rb +1 -1
  12. data/app/components/primer/{breadcrumb_component.html.erb → beta/breadcrumbs.html.erb} +2 -1
  13. data/app/components/primer/beta/breadcrumbs.rb +61 -0
  14. data/app/components/primer/navigation/tab_component.rb +7 -5
  15. data/app/components/primer/octicon_component.rb +6 -1
  16. data/app/components/primer/tab_container_component.rb +1 -1
  17. data/app/lib/primer/class_name_helper.rb +14 -13
  18. data/app/lib/primer/octicon/cache.rb +10 -2
  19. data/app/lib/primer/tab_nav_helper.rb +35 -0
  20. data/app/lib/primer/tabbed_component_helper.rb +4 -4
  21. data/app/lib/primer/underline_nav_helper.rb +44 -0
  22. data/lib/primer/classify/cache.rb +0 -6
  23. data/lib/primer/classify/utilities.rb +6 -2
  24. data/lib/primer/classify/utilities.yml +35 -0
  25. data/lib/primer/classify/validation.rb +1 -1
  26. data/lib/primer/classify.rb +0 -5
  27. data/lib/primer/view_components/engine.rb +1 -1
  28. data/lib/primer/view_components/linters/argument_mappers/button.rb +4 -1
  29. data/lib/primer/view_components/linters/flash_component_migration_counter.rb +5 -0
  30. data/lib/primer/view_components/version.rb +1 -1
  31. data/lib/rubocop/cop/primer/base_cop.rb +28 -0
  32. data/lib/rubocop/cop/primer/deprecated_arguments.rb +105 -15
  33. data/lib/rubocop/cop/primer/primer_octicon.rb +18 -1
  34. data/lib/rubocop/cop/primer/system_argument_instead_of_class.rb +1 -15
  35. data/lib/tasks/docs.rake +7 -6
  36. data/lib/tasks/utilities.rake +2 -0
  37. data/static/arguments.yml +75 -64
  38. data/static/classes.yml +2 -0
  39. data/static/constants.json +31 -29
  40. data/static/statuses.json +7 -5
  41. metadata +29 -9
  42. data/app/components/primer/breadcrumb_component.rb +0 -57
  43. data/app/components/primer/tab_nav_component.rb +0 -151
  44. data/app/components/primer/underline_nav_component.rb +0 -187
  45. data/lib/primer/classify/functional_text_colors.rb +0 -64
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4df5bb105c8b48aed71b4652afbf6814257fcb2c344085b328c27f8f109a80c1
4
- data.tar.gz: 72ff93288cac5eb1cabdc7cb8031c488452499203d768fcf3795bbe18cb31a43
3
+ metadata.gz: d48950fcd237f0cbc66a756cd503bad481125489a4be1dceaaca10d9585b1f9a
4
+ data.tar.gz: a08fd9afa611ef57ec975550b9522fdf7923475a77e80a5e726cb7ec593c289f
5
5
  SHA512:
6
- metadata.gz: 3af26e886cc8998ef3d449471400319615c0e820ce7265316e6de6fda2b55340f7f7a82d3c7c78f5c4e393f60d7638126bd8e8a88675735bfe570d2958ee2484
7
- data.tar.gz: aff9d0ca813126c33daab60f57bb01915ea8b779f17df99e648ec236f0da12bb9b16f54af24dfa871a50253663d71813533386457424f09f46a5458d5556a5b2
6
+ metadata.gz: 405f72cbcdf10628d38d31e13e9c9522ce1210c8ad563afddf25bffb76eb3003d58a65d97878f496d6c9e92e82dcc657b22460dd3170bae314cc4c8ef6e6db0d
7
+ data.tar.gz: f6b22b60183ddecf413911bdbd05492a8694974f6445c355eafe08e3ba010784e5fbaf72cae66706c27a2cc1aa6c5a5605160711eeb3c3e0df33c71f8d83b2a3
data/CHANGELOG.md CHANGED
@@ -30,6 +30,85 @@ The category for changes related to documentation, testing and tooling. Also, fo
30
30
 
31
31
  ## main
32
32
 
33
+ ## 0.0.57
34
+
35
+ ### Bug fixes
36
+
37
+ * Don't suggest empty colors for Octicons when autocorrecting.
38
+
39
+ *Manuel Puyol*
40
+
41
+ ## 0.0.56
42
+
43
+ ### Updates
44
+
45
+ * `Octicon` linter will autocorrect colors.
46
+
47
+ *Manuel Puyol*
48
+
49
+ * `Button` linter will autocorrect when button uses `href`, `name`, `value` or `tabindex`.
50
+
51
+ *Manuel Puyol*
52
+
53
+ * `Flash` linter won't autocorrect flashes with ERB in their content.
54
+
55
+ *Manuel Puyol*
56
+
57
+ * Eager load components.
58
+
59
+ *Cameron Dutro*
60
+
61
+ ### Misc
62
+
63
+ * Refactor some of the rubocop valid_node? logic into BaseCop class.
64
+
65
+ *Jon Rohan*
66
+
67
+ * Fix validation checker to use Utilities for color-* classes.
68
+
69
+ *Jon Rohan*
70
+
71
+ ## 0.0.55
72
+
73
+ ### Breaking changes
74
+
75
+ * `Primer::Breadcrumbs` requires `href`s for all items and no longer accepts the `selected` argument.
76
+
77
+ *Joel Hawksley*
78
+
79
+ * Split `TabNav` into `TabNav` and `TabPanels`.
80
+
81
+ *Kate Higa*
82
+
83
+ ### New
84
+
85
+ * Use the allocation_stats gem to count object allocations in our benchmarks.
86
+ * Improve performance of Octicon cache key construction.
87
+
88
+ *Cameron Dutro*
89
+
90
+ * Update `@primer/css` to `17.7.0` which includes a new argument for `word_break`
91
+
92
+ *Jon Rohan*
93
+
94
+ ### Misc
95
+
96
+ * Clean up extra constants in `UnderlineNav`.
97
+
98
+ *Kate Higa*
99
+
100
+ ## 0.0.54
101
+
102
+ ### Breaking changes
103
+
104
+ * Rename `BreadcrumbComponent` to `Beta::Breadcrumbs`.
105
+
106
+ *Joel Hawksley*
107
+
108
+ * Split `UnderlineNavComponent` into `Alpha::UnderlineNav` and `Alpha::UnderlinePanels`.
109
+
110
+ *Kate Higa*
111
+
33
112
  ## 0.0.53
34
113
 
35
114
  ### New
@@ -44,6 +123,10 @@ The category for changes related to documentation, testing and tooling. Also, fo
44
123
 
45
124
  *Manuel Puyol*
46
125
 
126
+ * Deprecating background and border color presentational arguments
127
+
128
+ *Jon Rohan*
129
+
47
130
  * Map the `for` argument when autofixing `ClipboardCopy` migrations.
48
131
 
49
132
  *Kristján Oddsson*
@@ -52,6 +135,10 @@ The category for changes related to documentation, testing and tooling. Also, fo
52
135
 
53
136
  *Manuel Puyol*
54
137
 
138
+ * Moving text color variables to Utilities class
139
+
140
+ *Jon Rohan*
141
+
55
142
  ### Bug fixes
56
143
 
57
144
  * Linters won't convert HTML special elements.
@@ -0,0 +1,11 @@
1
+ <%= render Primer::BaseComponent.new(**@system_arguments) do %>
2
+ <%= extra if @align == :left %>
3
+
4
+ <%= render Primer::BaseComponent.new(**@body_arguments) do %>
5
+ <% tabs.each do |tab| %>
6
+ <%= tab %>
7
+ <% end %>
8
+ <% end %>
9
+
10
+ <%= extra if @align == :right %>
11
+ <% end %>
@@ -0,0 +1,130 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Primer
4
+ module Alpha
5
+ # Use `TabNav` to style navigation with a tab-based selected state, typically used for navigation placed at the top of the page.
6
+ # For panel navigation, use <%= link_to_component(Primer::Alpha::TabPanels) %> instead.
7
+ #
8
+ # @accessibility
9
+ # - By default, `TabNav` renders links within a `<nav>` element. `<nav>` has an
10
+ # implicit landmark role of `navigation` which should be reserved for main links.
11
+ # For all other set of links, set tag to `:div`.
12
+ # - See <%= link_to_component(Primer::Navigation::TabComponent) %> for additional
13
+ # accessibility considerations.
14
+ class TabNav < Primer::Component
15
+ include Primer::TabbedComponentHelper
16
+ include Primer::TabNavHelper
17
+
18
+ status :alpha
19
+
20
+ BODY_TAG_DEFAULT = :ul
21
+
22
+ TAG_DEFAULT = :nav
23
+ TAG_OPTIONS = [TAG_DEFAULT, :div].freeze
24
+
25
+ # Tabs to be rendered. For more information, refer to <%= link_to_component(Primer::Navigation::TabComponent) %>.
26
+ #
27
+ # @param selected [Boolean] Whether the tab is selected.
28
+ # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
29
+ renders_many :tabs, lambda { |selected: false, **system_arguments|
30
+ system_arguments[:classes] = tab_nav_tab_classes(system_arguments[:classes])
31
+ Primer::Navigation::TabComponent.new(
32
+ list: true,
33
+ selected: selected,
34
+ **system_arguments
35
+ )
36
+ }
37
+
38
+ # Renders extra content to the `TabNav`. This will be rendered after the tabs.
39
+ #
40
+ # @param align [Symbol] <%= one_of(Primer::Alpha::TabNav::EXTRA_ALIGN_OPTIONS) %>
41
+ renders_one :extra, lambda { |align: EXTRA_ALIGN_DEFAULT, &block|
42
+ @align = fetch_or_fallback(EXTRA_ALIGN_OPTIONS, align, EXTRA_ALIGN_DEFAULT)
43
+
44
+ view_context.capture { block&.call }
45
+ }
46
+
47
+ # @example Default with `<nav>`
48
+ # @description
49
+ # `<nav>` is a landmark and should be reserved for main navigation links. See <%= link_to_accessibility %>.
50
+ # @code
51
+ # <%= render(Primer::Alpha::TabNav.new(label: "Default")) do |c| %>
52
+ # <% c.tab(selected: true, href: "#") { "Tab 1" } %>
53
+ # <% c.tab(href: "#") { "Tab 2" } %>
54
+ # <% c.tab(href: "#") { "Tab 3" } %>
55
+ # <% end %>
56
+ #
57
+ # @example Default with `<div>`
58
+ # <%= render(Primer::Alpha::TabNav.new(label: "Default")) do |c| %>
59
+ # <% c.tab(selected: true, href: "#") { "Tab 1" } %>
60
+ # <% c.tab(href: "#") { "Tab 2" } %>
61
+ # <% c.tab(href: "#") { "Tab 3" } %>
62
+ # <% end %>
63
+ #
64
+ # @example With icons and counters
65
+ # <%= render(Primer::Alpha::TabNav.new(label: "With icons and counters")) do |component| %>
66
+ # <% component.tab(href: "#", selected: true) do |t| %>
67
+ # <% t.icon(icon: :star) %>
68
+ # <% t.text { "Item 1" } %>
69
+ # <% end %>
70
+ # <% component.tab(href: "#") do |t| %>
71
+ # <% t.icon(icon: :star) %>
72
+ # <% t.text { "Item 2" } %>
73
+ # <% t.counter(count: 10) %>
74
+ # <% end %>
75
+ # <% component.tab(href: "#") do |t| %>
76
+ # <% t.text { "Item 3" } %>
77
+ # <% t.counter(count: 10) %>
78
+ # <% end %>
79
+ # <% end %>
80
+ #
81
+ # @example With extra content
82
+ # <%= render(Primer::Alpha::TabNav.new(label: "With extra content")) do |c| %>
83
+ # <% c.tab(selected: true, href: "#") { "Tab 1" }%>
84
+ # <% c.tab(href: "#") { "Tab 2" } %>
85
+ # <% c.tab(href: "#") { "Tab 3" } %>
86
+ # <% c.extra do %>
87
+ # <%= render(Primer::ButtonComponent.new(float: :right)) { "Button" } %>
88
+ # <% end %>
89
+ # <% end %>
90
+ #
91
+ # @example Adding extra content after the tabs
92
+ # <%= render(Primer::Alpha::TabNav.new(label: "Adding extra content after the tabs", display: :flex, body_arguments: { flex: 1 })) do |c| %>
93
+ # <% c.tab(selected: true, href: "#") { "Tab 1" }%>
94
+ # <% c.tab(href: "#") { "Tab 2" } %>
95
+ # <% c.tab(href: "#") { "Tab 3" } %>
96
+ # <% c.extra(align: :right) do %>
97
+ # <div>
98
+ # <%= render(Primer::ButtonComponent.new) { "Button" } %>
99
+ # </div>
100
+ # <% end %>
101
+ # <% end %>
102
+ #
103
+ # @example Customizing the body
104
+ # <%= render(Primer::Alpha::TabNav.new(label: "Default", body_arguments: { classes: "custom-class", border: true, border_color: :info })) do |c| %>
105
+ # <% c.tab(selected: true, href: "#") { "Tab 1" }%>
106
+ # <% c.tab(href: "#") { "Tab 2" } %>
107
+ # <% c.tab(href: "#") { "Tab 3" } %>
108
+ # <% end %>
109
+ #
110
+ # @param tag [Symbol] <%= one_of(Primer::Alpha::TabNav::TAG_OPTIONS) %>
111
+ # @param label [String] Sets an `aria-label` that helps assistive technology users understand the purpose of the links, and distinguish it from similar elements.
112
+ # @param body_arguments [Hash] <%= link_to_system_arguments_docs %> for the body wrapper.
113
+ # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
114
+ def initialize(label:, tag: TAG_DEFAULT, body_arguments: {}, **system_arguments)
115
+ @align = EXTRA_ALIGN_DEFAULT
116
+ @system_arguments = system_arguments
117
+ @body_arguments = body_arguments
118
+
119
+ @system_arguments[:tag] = fetch_or_fallback(TAG_OPTIONS, tag, TAG_DEFAULT)
120
+ @system_arguments[:classes] = tab_nav_classes(system_arguments[:classes])
121
+
122
+ @body_arguments = body_arguments
123
+ @body_arguments[:tag] = BODY_TAG_DEFAULT
124
+ @body_arguments[:classes] = tab_nav_body_classes(system_arguments[:classes])
125
+
126
+ aria_label_for_page_nav(label)
127
+ end
128
+ end
129
+ end
130
+ end
@@ -1,19 +1,14 @@
1
- <%= wrapper(**@wrapper_arguments) do %>
1
+ <%= tab_container_wrapper(with_panel: true, **@wrapper_arguments) do %>
2
2
  <%= render Primer::BaseComponent.new(**@system_arguments) do %>
3
3
  <%= extra if @align == :left %>
4
-
5
4
  <%= render Primer::BaseComponent.new(**@body_arguments) do %>
6
5
  <% tabs.each do |tab| %>
7
6
  <%= tab %>
8
7
  <% end %>
9
8
  <% end %>
10
-
11
9
  <%= extra if @align == :right %>
12
10
  <% end %>
13
-
14
- <% if @with_panel %>
15
- <% tabs.each do |tab| %>
16
- <%= tab.panel %>
17
- <% end %>
11
+ <% tabs.each do |tab| %>
12
+ <%= tab.panel %>
18
13
  <% end %>
19
14
  <% end %>
@@ -0,0 +1,82 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Primer
4
+ module Alpha
5
+ # Use `TabPanels` for tabs with panel navigation.
6
+ class TabPanels < Primer::Component
7
+ include Primer::TabbedComponentHelper
8
+ include Primer::TabNavHelper
9
+
10
+ status :alpha
11
+
12
+ BODY_TAG_DEFAULT = :ul
13
+
14
+ TAG_DEFAULT = :nav
15
+ TAG_OPTIONS = [TAG_DEFAULT, :div].freeze
16
+
17
+ # Tabs to be rendered. For more information, refer to <%= link_to_component(Primer::Navigation::TabComponent) %>.
18
+ #
19
+ # @param id [String] Unique ID of tab.
20
+ # @param selected [Boolean] Whether the tab is selected.
21
+ # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
22
+ renders_many :tabs, lambda { |id:, selected: false, **system_arguments|
23
+ system_arguments[:id] = id
24
+ system_arguments[:classes] = tab_nav_tab_classes(system_arguments[:classes])
25
+
26
+ Primer::Navigation::TabComponent.new(
27
+ selected: selected,
28
+ with_panel: true,
29
+ list: true,
30
+ panel_id: "panel-#{id}",
31
+ **system_arguments
32
+ )
33
+ }
34
+
35
+ # Renders extra content to the `TabPanels`. This will be rendered after the tabs.
36
+ #
37
+ # @param align [Symbol] <%= one_of(Primer::Alpha::TabNav::EXTRA_ALIGN_OPTIONS) %>
38
+ renders_one :extra, lambda { |align: EXTRA_ALIGN_DEFAULT, &block|
39
+ @align = fetch_or_fallback(EXTRA_ALIGN_OPTIONS, align, EXTRA_ALIGN_DEFAULT)
40
+
41
+ view_context.capture { block&.call }
42
+ }
43
+
44
+ # @example Default
45
+ # <%= render(Primer::Alpha::TabPanels.new(label: "With panels")) do |component| %>
46
+ # <% component.tab(id: "tab-1", selected: true) do |t| %>
47
+ # <% t.text { "Tab 1" } %>
48
+ # <% t.panel do %>
49
+ # Panel 1
50
+ # <% end %>
51
+ # <% end %>
52
+ # <% component.tab(id: "tab-2") do |t| %>
53
+ # <% t.text { "Tab 2" } %>
54
+ # <% t.panel do %>
55
+ # Panel 2
56
+ # <% end %>
57
+ # <% end %>
58
+ # <% end %>
59
+ #
60
+ # @param label [String] Sets an `aria-label` that helps assistive technology users understand the purpose of the tabs.
61
+ # @param align [Symbol] <%= one_of(Primer::TabNavHelper::EXTRA_ALIGN_OPTIONS) %> - Defaults to <%= Primer::TabNavHelper::EXTRA_ALIGN_DEFAULT %>
62
+ # @param body_arguments [Hash] <%= link_to_system_arguments_docs %> for the body wrapper.
63
+ # @param wrapper_arguments [Hash] <%= link_to_system_arguments_docs %> for the `TabContainer` wrapper.
64
+ # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
65
+ def initialize(label:, body_arguments: {}, wrapper_arguments: {}, **system_arguments)
66
+ @align = EXTRA_ALIGN_DEFAULT
67
+ @wrapper_arguments = wrapper_arguments
68
+
69
+ @system_arguments = system_arguments
70
+ @system_arguments[:tag] = :div
71
+ @system_arguments[:classes] = tab_nav_classes(@system_arguments[:classes])
72
+
73
+ @body_arguments = body_arguments
74
+ @body_arguments[:tag] = :ul
75
+ @body_arguments[:classes] = tab_nav_body_classes(@body_arguments[:classes])
76
+
77
+ @body_arguments[:role] = :tablist
78
+ @body_arguments[:"aria-label"] = label
79
+ end
80
+ end
81
+ end
82
+ end
@@ -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,137 @@
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
+ BODY_TAG_DEFAULT = :ul
21
+
22
+ TAG_DEFAULT = :nav
23
+ TAG_OPTIONS = [TAG_DEFAULT, :div].freeze
24
+
25
+ # Use the tabs to list page links.
26
+ #
27
+ # @param selected [Boolean] Whether the tab is selected.
28
+ # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
29
+ renders_many :tabs, lambda { |selected: false, **system_arguments|
30
+ system_arguments[:classes] = underline_nav_tab_classes(system_arguments[:classes])
31
+ Primer::Navigation::TabComponent.new(
32
+ list: true,
33
+ selected: selected,
34
+ icon_classes: "UnderlineNav-octicon",
35
+ **system_arguments
36
+ )
37
+ }
38
+
39
+ # Use actions for a call to action.
40
+ #
41
+ # @param tag [Symbol] (Primer::UnderlineNavHelper::ACTIONS_TAG_DEFAULT) <%= one_of(Primer::UnderlineNavHelper::ACTIONS_TAG_OPTIONS) %>
42
+ # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
43
+ renders_one :actions, lambda { |tag: ACTIONS_TAG_DEFAULT, **system_arguments|
44
+ system_arguments[:tag] = fetch_or_fallback(ACTIONS_TAG_OPTIONS, tag, ACTIONS_TAG_DEFAULT)
45
+ system_arguments[:classes] = underline_nav_action_classes(system_arguments[:classes])
46
+
47
+ Primer::BaseComponent.new(**system_arguments)
48
+ }
49
+
50
+ # @example Default with `<nav>`
51
+ # @description
52
+ # `<nav>` is a landmark and should be reserved for main navigation links. See <%= link_to_accessibility %>.
53
+ # @code
54
+ # <%= render(Primer::Alpha::UnderlineNav.new(label: "Default with nav element")) do |component| %>
55
+ # <% component.tab(href: "#", selected: true) { "Item 1" } %>
56
+ # <% component.tab(href: "#") { "Item 2" } %>
57
+ # <% component.actions do %>
58
+ # <%= render(Primer::ButtonComponent.new) { "Button!" } %>
59
+ # <% end %>
60
+ # <% end %>
61
+ #
62
+ # @example With `<div>`
63
+ # <%= render(Primer::Alpha::UnderlineNav.new(tag: :div, label: "With div element")) do |component| %>
64
+ # <% component.tab(href: "#", selected: true) { "Item 1" } %>
65
+ # <% component.tab(href: "#") { "Item 2" } %>
66
+ # <% component.actions do %>
67
+ # <%= render(Primer::ButtonComponent.new) { "Button!" } %>
68
+ # <% end %>
69
+ # <% end %>
70
+ #
71
+ # @example With icons and counters
72
+ # <%= render(Primer::Alpha::UnderlineNav.new(label: "With icons and counters")) do |component| %>
73
+ # <% component.tab(href: "#", selected: true) do |t| %>
74
+ # <% t.icon(icon: :star) %>
75
+ # <% t.text { "Item 1" } %>
76
+ # <% end %>
77
+ # <% component.tab(href: "#") do |t| %>
78
+ # <% t.icon(icon: :star) %>
79
+ # <% t.text { "Item 2" } %>
80
+ # <% t.counter(count: 10) %>
81
+ # <% end %>
82
+ # <% component.tab(href: "#") do |t| %>
83
+ # <% t.text { "Item 3" } %>
84
+ # <% t.counter(count: 10) %>
85
+ # <% end %>
86
+ # <% component.actions do %>
87
+ # <%= render(Primer::ButtonComponent.new) { "Button!" } %>
88
+ # <% end %>
89
+ # <% end %>
90
+ #
91
+ # @example Align right
92
+ # <%= render(Primer::Alpha::UnderlineNav.new(label: "Align right", align: :right)) do |component| %>
93
+ # <% component.tab(href: "#", selected: true) do |t| %>
94
+ # <% t.text { "Item 1" } %>
95
+ # <% end %>
96
+ # <% component.tab(href: "#") do |t| %>
97
+ # <% t.text { "Item 2" } %>
98
+ # <% end %>
99
+ # <% component.actions do %>
100
+ # <%= render(Primer::ButtonComponent.new) { "Button!" } %>
101
+ # <% end %>
102
+ # <% end %>
103
+ #
104
+ # @example Customizing the body
105
+ # <%= render(Primer::Alpha::UnderlineNav.new(label: "Default", body_arguments: { classes: "custom-class", border: true, border_color: :info })) do |c| %>
106
+ # <% c.tab(selected: true, href: "#") { "Tab 1" }%>
107
+ # <% c.tab(href: "#") { "Tab 2" } %>
108
+ # <% c.tab(href: "#") { "Tab 3" } %>
109
+ # <% end %>
110
+ #
111
+ # @param tag [Symbol] <%= one_of(Primer::Alpha::UnderlineNav::TAG_OPTIONS) %>
112
+ # @param label [String] Sets an `aria-label` that helps assistive technology users understand the purpose of the links, and distinguish it from similar elements.
113
+ # @param align [Symbol] <%= one_of(Primer::UnderlineNavHelper::ALIGN_OPTIONS) %> - Defaults to <%= Primer::UnderlineNavHelper::ALIGN_DEFAULT %>
114
+ # @param body_arguments [Hash] <%= link_to_system_arguments_docs %> for the body wrapper.
115
+ # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
116
+ def initialize(label:, tag: TAG_DEFAULT, align: ALIGN_DEFAULT, body_arguments: {}, **system_arguments)
117
+ @align = fetch_or_fallback(ALIGN_OPTIONS, align, ALIGN_DEFAULT)
118
+
119
+ @system_arguments = system_arguments
120
+ @system_arguments[:tag] = fetch_or_fallback(TAG_OPTIONS, tag, TAG_DEFAULT)
121
+ @system_arguments[:classes] = underline_nav_classes(@system_arguments[:classes], @align)
122
+
123
+ @body_arguments = body_arguments
124
+ @body_arguments[:tag] = :ul
125
+ @body_arguments[:classes] = underline_nav_body_classes(@body_arguments[:classes])
126
+
127
+ aria_label_for_page_nav(label)
128
+ end
129
+
130
+ private
131
+
132
+ def body
133
+ Primer::BaseComponent.new(**@body_arguments)
134
+ end
135
+ end
136
+ end
137
+ end