primer_view_components 0.0.53 → 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 +16 -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/{breadcrumb_component.html.erb → beta/breadcrumbs.html.erb} +0 -0
- data/app/components/primer/beta/breadcrumbs.rb +59 -0
- data/app/components/primer/navigation/tab_component.rb +6 -4
- data/app/components/primer/tab_nav_component.html.erb +1 -1
- data/app/lib/primer/tabbed_component_helper.rb +2 -2
- data/app/lib/primer/underline_nav_helper.rb +44 -0
- data/lib/primer/view_components/version.rb +1 -1
- data/lib/rubocop/cop/primer/deprecated_arguments.rb +104 -0
- data/lib/tasks/docs.rake +4 -3
- data/static/arguments.yml +55 -37
- data/static/classes.yml +1 -0
- data/static/constants.json +25 -22
- data/static/statuses.json +5 -4
- metadata +13 -12
- 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,6 +30,18 @@ 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
|
+
|
33
45
|
## 0.0.53
|
34
46
|
|
35
47
|
### New
|
@@ -44,6 +56,10 @@ The category for changes related to documentation, testing and tooling. Also, fo
|
|
44
56
|
|
45
57
|
*Manuel Puyol*
|
46
58
|
|
59
|
+
* Deprecating background and border color presentational arguments
|
60
|
+
|
61
|
+
*Jon Rohan*
|
62
|
+
|
47
63
|
* Map the `for` argument when autofixing `ClipboardCopy` migrations.
|
48
64
|
|
49
65
|
*Kristján Oddsson*
|
@@ -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
|
File without changes
|
@@ -0,0 +1,59 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Primer
|
4
|
+
module Beta
|
5
|
+
# Use `Breadcrumb` 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.
|
6
|
+
class Breadcrumbs < Primer::Component
|
7
|
+
status :beta
|
8
|
+
|
9
|
+
# _Note: if both `href` and `selected: true` are passed in, `href` will be ignored and the item will not be rendered as a link._
|
10
|
+
#
|
11
|
+
# @param href [String] The URL to link to.
|
12
|
+
# @param selected [Boolean] Whether or not the item is selected and not rendered as a link.
|
13
|
+
# @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
|
14
|
+
renders_many :items, "Item"
|
15
|
+
|
16
|
+
# @example Basic
|
17
|
+
# <%= render(Primer::Beta::Breadcrumbs.new) do |component| %>
|
18
|
+
# <% component.item(href: "/") do %>Home<% end %>
|
19
|
+
# <% component.item(href: "/about") do %>About<% end %>
|
20
|
+
# <% component.item(selected: true) do %>Team<% end %>
|
21
|
+
# <% end %>
|
22
|
+
#
|
23
|
+
# @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
|
24
|
+
def initialize(**system_arguments)
|
25
|
+
@system_arguments = system_arguments
|
26
|
+
@system_arguments[:tag] = :nav
|
27
|
+
@system_arguments[:aria] = { label: "Breadcrumb" }
|
28
|
+
end
|
29
|
+
|
30
|
+
def render?
|
31
|
+
items.any?
|
32
|
+
end
|
33
|
+
|
34
|
+
# This component is part of `Primer::Beta::Breadcrumbs` and should not be
|
35
|
+
# used as a standalone component.
|
36
|
+
class Item < Primer::Component
|
37
|
+
def initialize(href: nil, selected: false, **system_arguments)
|
38
|
+
@href = href
|
39
|
+
@system_arguments = system_arguments
|
40
|
+
|
41
|
+
@href = nil if selected
|
42
|
+
@system_arguments[:tag] = :li
|
43
|
+
@system_arguments[:"aria-current"] = "page" if selected
|
44
|
+
@system_arguments[:classes] = "breadcrumb-item #{@system_arguments[:classes]}"
|
45
|
+
end
|
46
|
+
|
47
|
+
def call
|
48
|
+
render(Primer::BaseComponent.new(**@system_arguments)) do
|
49
|
+
if @href.present?
|
50
|
+
render(Primer::LinkComponent.new(href: @href)) { content }
|
51
|
+
else
|
52
|
+
content
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -3,7 +3,7 @@
|
|
3
3
|
module Primer
|
4
4
|
module Navigation
|
5
5
|
# This component is part of navigation components such as `Primer::TabNavComponent`
|
6
|
-
# and `Primer::
|
6
|
+
# and `Primer::Alpha::UnderlineNav` and should not be used by itself.
|
7
7
|
#
|
8
8
|
# @accessibility
|
9
9
|
# `TabComponent` renders the selected anchor tab with `aria-current="page"` by default.
|
@@ -14,7 +14,7 @@ module Primer
|
|
14
14
|
# Panel controlled by the Tab. This will not render anything in the tab itself.
|
15
15
|
# It will provide a accessor for the Tab's parent to call and render the panel
|
16
16
|
# content in the appropriate place.
|
17
|
-
# Refer to `
|
17
|
+
# Refer to `UnderlineNav` and `TabNavComponent` implementations for examples.
|
18
18
|
#
|
19
19
|
# @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
|
20
20
|
renders_one :panel, lambda { |**system_arguments|
|
@@ -111,19 +111,21 @@ module Primer
|
|
111
111
|
|
112
112
|
@system_arguments = system_arguments
|
113
113
|
@id = @system_arguments[:id]
|
114
|
+
@wrapper_arguments = wrapper_arguments
|
114
115
|
|
115
116
|
if with_panel || @system_arguments[:tag] == :button
|
116
117
|
@system_arguments[:tag] = :button
|
117
118
|
@system_arguments[:type] = :button
|
118
119
|
@system_arguments[:role] = :tab
|
119
120
|
panel_id(panel_id)
|
121
|
+
# https://www.w3.org/TR/wai-aria-practices/#presentation_role
|
122
|
+
@wrapper_arguments[:role] = :presentation
|
120
123
|
else
|
121
124
|
@system_arguments[:tag] = :a
|
122
125
|
end
|
123
126
|
|
124
|
-
@wrapper_arguments = wrapper_arguments
|
125
127
|
@wrapper_arguments[:tag] = :li
|
126
|
-
@wrapper_arguments[:display] ||= :
|
128
|
+
@wrapper_arguments[:display] ||= :inline_flex
|
127
129
|
|
128
130
|
return unless @selected
|
129
131
|
|
@@ -20,8 +20,8 @@ module Primer
|
|
20
20
|
with_panel ? :div : :nav
|
21
21
|
end
|
22
22
|
|
23
|
-
def wrapper(**system_arguments)
|
24
|
-
return yield unless
|
23
|
+
def wrapper(with_panel:, **system_arguments)
|
24
|
+
return yield unless with_panel
|
25
25
|
|
26
26
|
render Primer::TabContainerComponent.new(**system_arguments) do
|
27
27
|
yield if block_given?
|
@@ -0,0 +1,44 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "active_support/concern"
|
4
|
+
|
5
|
+
module Primer
|
6
|
+
# Helper to share tab validation logic between components.
|
7
|
+
# The component will raise an error if there are 0 or 2+ selected tabs.
|
8
|
+
module UnderlineNavHelper
|
9
|
+
extend ActiveSupport::Concern
|
10
|
+
|
11
|
+
ALIGN_DEFAULT = :left
|
12
|
+
ALIGN_OPTIONS = [ALIGN_DEFAULT, :right].freeze
|
13
|
+
|
14
|
+
ACTIONS_TAG_DEFAULT = :div
|
15
|
+
ACTIONS_TAG_OPTIONS = [ACTIONS_TAG_DEFAULT, :span].freeze
|
16
|
+
|
17
|
+
def underline_nav_classes(classes, align)
|
18
|
+
class_names(
|
19
|
+
classes,
|
20
|
+
"UnderlineNav",
|
21
|
+
"UnderlineNav--right" => align == :right
|
22
|
+
)
|
23
|
+
end
|
24
|
+
|
25
|
+
def underline_nav_body_classes(classes)
|
26
|
+
class_names(
|
27
|
+
"UnderlineNav-body",
|
28
|
+
classes,
|
29
|
+
"list-style-none"
|
30
|
+
)
|
31
|
+
end
|
32
|
+
|
33
|
+
def underline_nav_action_classes(classes)
|
34
|
+
class_names("UnderlineNav-actions", classes)
|
35
|
+
end
|
36
|
+
|
37
|
+
def underline_nav_tab_classes(classes)
|
38
|
+
class_names(
|
39
|
+
"UnderlineNav-item",
|
40
|
+
classes
|
41
|
+
)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -35,6 +35,110 @@ module RuboCop
|
|
35
35
|
# }
|
36
36
|
#
|
37
37
|
DEPRECATED = {
|
38
|
+
bg: {
|
39
|
+
white: "bg: :primary",
|
40
|
+
gray_light: "bg: :secondary",
|
41
|
+
gray: "bg: :tertiary",
|
42
|
+
gray_dark: "bg: :canvas_inverse",
|
43
|
+
blue_light: "bg: :info",
|
44
|
+
blue: "bg: :info_inverse",
|
45
|
+
green_light: "bg: :success",
|
46
|
+
green: "bg: :success_inverse",
|
47
|
+
yellow_light: "bg: :warning",
|
48
|
+
yellow: "bg: :warning_inverse",
|
49
|
+
red_light: "bg: :danger",
|
50
|
+
red: "bg: :danger_inverse",
|
51
|
+
gray_0: nil,
|
52
|
+
gray_1: nil,
|
53
|
+
gray_2: nil,
|
54
|
+
gray_3: nil,
|
55
|
+
gray_4: nil,
|
56
|
+
gray_5: nil,
|
57
|
+
gray_6: nil,
|
58
|
+
gray_7: nil,
|
59
|
+
gray_8: nil,
|
60
|
+
gray_9: nil,
|
61
|
+
blue_0: nil,
|
62
|
+
blue_1: nil,
|
63
|
+
blue_2: nil,
|
64
|
+
blue_3: nil,
|
65
|
+
blue_4: nil,
|
66
|
+
blue_5: nil,
|
67
|
+
blue_6: nil,
|
68
|
+
blue_7: nil,
|
69
|
+
blue_8: nil,
|
70
|
+
blue_9: nil,
|
71
|
+
green_0: nil,
|
72
|
+
green_1: nil,
|
73
|
+
green_2: nil,
|
74
|
+
green_3: nil,
|
75
|
+
green_4: nil,
|
76
|
+
green_5: nil,
|
77
|
+
green_6: nil,
|
78
|
+
green_7: nil,
|
79
|
+
green_8: nil,
|
80
|
+
green_9: nil,
|
81
|
+
yellow_0: nil,
|
82
|
+
yellow_1: nil,
|
83
|
+
yellow_2: nil,
|
84
|
+
yellow_3: nil,
|
85
|
+
yellow_4: nil,
|
86
|
+
yellow_5: nil,
|
87
|
+
yellow_6: nil,
|
88
|
+
yellow_7: nil,
|
89
|
+
yellow_8: nil,
|
90
|
+
yellow_9: nil,
|
91
|
+
red_0: nil,
|
92
|
+
red_1: nil,
|
93
|
+
red_2: nil,
|
94
|
+
red_3: nil,
|
95
|
+
red_4: nil,
|
96
|
+
red_5: nil,
|
97
|
+
red_6: nil,
|
98
|
+
red_7: nil,
|
99
|
+
red_8: nil,
|
100
|
+
red_9: nil,
|
101
|
+
purple_0: nil,
|
102
|
+
purple_1: nil,
|
103
|
+
purple_2: nil,
|
104
|
+
purple_3: nil,
|
105
|
+
purple_4: nil,
|
106
|
+
purple_5: nil,
|
107
|
+
purple_6: nil,
|
108
|
+
purple_7: nil,
|
109
|
+
purple_8: nil,
|
110
|
+
purple_9: nil,
|
111
|
+
pink_0: nil,
|
112
|
+
pink_1: nil,
|
113
|
+
pink_2: nil,
|
114
|
+
pink_3: nil,
|
115
|
+
pink_4: nil,
|
116
|
+
pink_5: nil,
|
117
|
+
pink_6: nil,
|
118
|
+
pink_7: nil,
|
119
|
+
pink_8: nil,
|
120
|
+
pink_9: nil,
|
121
|
+
orange_0: nil,
|
122
|
+
orange_1: nil,
|
123
|
+
orange_2: nil,
|
124
|
+
orange_3: nil,
|
125
|
+
orange_4: nil,
|
126
|
+
orange_5: nil,
|
127
|
+
orange_6: nil,
|
128
|
+
orange_7: nil,
|
129
|
+
orange_8: nil,
|
130
|
+
orange_9: nil
|
131
|
+
},
|
132
|
+
border_color: {
|
133
|
+
gray: "border_color: :primary",
|
134
|
+
gray_light: "border_color: :secondary",
|
135
|
+
gray_dark: "border_color: :tertiary",
|
136
|
+
blue: "border_color: :info",
|
137
|
+
green: "border_color: :success",
|
138
|
+
yellow: "border_color: :warning",
|
139
|
+
red: "border_color: :danger",
|
140
|
+
white: "border_color: :inverse"
|
141
|
+
},
|
38
142
|
color: {
|
39
143
|
blue: "color: :text_link",
|
40
144
|
gray_dark: "color: :text_primary",
|
data/lib/tasks/docs.rake
CHANGED
@@ -40,7 +40,7 @@ namespace :docs do
|
|
40
40
|
Primer::BlankslateComponent,
|
41
41
|
Primer::BorderBoxComponent,
|
42
42
|
Primer::BoxComponent,
|
43
|
-
Primer::
|
43
|
+
Primer::Beta::Breadcrumbs,
|
44
44
|
Primer::ButtonComponent,
|
45
45
|
Primer::ButtonGroup,
|
46
46
|
Primer::Alpha::ButtonMarketing,
|
@@ -75,7 +75,8 @@ namespace :docs do
|
|
75
75
|
Primer::Tooltip,
|
76
76
|
Primer::Truncate,
|
77
77
|
Primer::Beta::Truncate,
|
78
|
-
Primer::
|
78
|
+
Primer::Alpha::UnderlineNav,
|
79
|
+
Primer::Alpha::UnderlinePanels
|
79
80
|
]
|
80
81
|
|
81
82
|
js_components = [
|
@@ -87,7 +88,7 @@ namespace :docs do
|
|
87
88
|
Primer::TabContainerComponent,
|
88
89
|
Primer::TabNavComponent,
|
89
90
|
Primer::TimeAgoComponent,
|
90
|
-
Primer::
|
91
|
+
Primer::Alpha::UnderlinePanels
|
91
92
|
]
|
92
93
|
|
93
94
|
all_components = Primer::Component.descendants - [Primer::BaseComponent]
|
data/static/arguments.yml
CHANGED
@@ -22,6 +22,54 @@
|
|
22
22
|
type: Hash
|
23
23
|
default: N/A
|
24
24
|
description: "[System arguments](/system-arguments)"
|
25
|
+
- component: UnderlineNav
|
26
|
+
source: https://github.com/primer/view_components/tree/main/app/components/primer/alpha/underline_nav.rb
|
27
|
+
parameters:
|
28
|
+
- name: tag
|
29
|
+
type: Symbol
|
30
|
+
default: "`:nav`"
|
31
|
+
description: One of `:div` and `:nav`.
|
32
|
+
- name: label
|
33
|
+
type: String
|
34
|
+
default: N/A
|
35
|
+
description: Sets an `aria-label` that helps assistive technology users understand
|
36
|
+
the purpose of the links, and distinguish it from similar elements.
|
37
|
+
- name: align
|
38
|
+
type: Symbol
|
39
|
+
default: "`:left`"
|
40
|
+
description: One of `:left` and `:right`. - Defaults to left
|
41
|
+
- name: body_arguments
|
42
|
+
type: Hash
|
43
|
+
default: "`{}`"
|
44
|
+
description: "[System arguments](/system-arguments) for the body wrapper."
|
45
|
+
- name: system_arguments
|
46
|
+
type: Hash
|
47
|
+
default: N/A
|
48
|
+
description: "[System arguments](/system-arguments)"
|
49
|
+
- component: UnderlinePanels
|
50
|
+
source: https://github.com/primer/view_components/tree/main/app/components/primer/alpha/underline_panels.rb
|
51
|
+
parameters:
|
52
|
+
- name: label
|
53
|
+
type: String
|
54
|
+
default: N/A
|
55
|
+
description: Sets an `aria-label` that helps assistive technology users understand
|
56
|
+
the purpose of the tabs.
|
57
|
+
- name: align
|
58
|
+
type: Symbol
|
59
|
+
default: "`:left`"
|
60
|
+
description: One of `:left` and `:right`. - Defaults to left
|
61
|
+
- name: body_arguments
|
62
|
+
type: Hash
|
63
|
+
default: "`{}`"
|
64
|
+
description: "[System arguments](/system-arguments) for the body wrapper."
|
65
|
+
- name: wrapper_arguments
|
66
|
+
type: Hash
|
67
|
+
default: "`{}`"
|
68
|
+
description: "[System arguments](/system-arguments) for the `TabContainer` wrapper."
|
69
|
+
- name: system_arguments
|
70
|
+
type: Hash
|
71
|
+
default: N/A
|
72
|
+
description: "[System arguments](/system-arguments)"
|
25
73
|
- component: BaseButton
|
26
74
|
source: https://github.com/primer/view_components/tree/main/app/components/primer/base_button.rb
|
27
75
|
parameters:
|
@@ -132,6 +180,13 @@
|
|
132
180
|
type: Hash
|
133
181
|
default: N/A
|
134
182
|
description: "[System arguments](/system-arguments)"
|
183
|
+
- component: Breadcrumbs
|
184
|
+
source: https://github.com/primer/view_components/tree/main/app/components/primer/beta/breadcrumbs.rb
|
185
|
+
parameters:
|
186
|
+
- name: system_arguments
|
187
|
+
type: Hash
|
188
|
+
default: N/A
|
189
|
+
description: "[System arguments](/system-arguments)"
|
135
190
|
- component: Text
|
136
191
|
source: https://github.com/primer/view_components/tree/main/app/components/primer/beta/text.rb
|
137
192
|
parameters:
|
@@ -235,13 +290,6 @@
|
|
235
290
|
type: Hash
|
236
291
|
default: N/A
|
237
292
|
description: "[System arguments](/system-arguments)"
|
238
|
-
- component: Breadcrumb
|
239
|
-
source: https://github.com/primer/view_components/tree/main/app/components/primer/breadcrumb_component.rb
|
240
|
-
parameters:
|
241
|
-
- name: system_arguments
|
242
|
-
type: Hash
|
243
|
-
default: N/A
|
244
|
-
description: "[System arguments](/system-arguments)"
|
245
293
|
- component: Button
|
246
294
|
source: https://github.com/primer/view_components/tree/main/app/components/primer/button_component.rb
|
247
295
|
parameters:
|
@@ -948,33 +996,3 @@
|
|
948
996
|
type: Hash
|
949
997
|
default: N/A
|
950
998
|
description: "[System arguments](/system-arguments)"
|
951
|
-
- component: UnderlineNav
|
952
|
-
source: https://github.com/primer/view_components/tree/main/app/components/primer/underline_nav_component.rb
|
953
|
-
parameters:
|
954
|
-
- name: label
|
955
|
-
type: String
|
956
|
-
default: N/A
|
957
|
-
description: The `aria-label` on top level `<nav>` element.
|
958
|
-
- name: with_panel
|
959
|
-
type: Boolean
|
960
|
-
default: "`false`"
|
961
|
-
description: Whether the `UnderlineNav` should navigate through pages or panels.
|
962
|
-
When true, [TabContainer](/components/tabcontainer) is rendered along with JavaScript
|
963
|
-
behavior.
|
964
|
-
- name: align
|
965
|
-
type: Symbol
|
966
|
-
default: "`:left`"
|
967
|
-
description: One of `:left` and `:right`. - Defaults to left
|
968
|
-
- name: body_arguments
|
969
|
-
type: Hash
|
970
|
-
default: "`{ tag: BODY_TAG_DEFAULT }`"
|
971
|
-
description: "[System arguments](/system-arguments) for the body wrapper."
|
972
|
-
- name: wrapper_arguments
|
973
|
-
type: Hash
|
974
|
-
default: "`{}`"
|
975
|
-
description: "[System arguments](/system-arguments) for the `TabContainer` wrapper.
|
976
|
-
Only applies if `with_panel` is `true`."
|
977
|
-
- name: system_arguments
|
978
|
-
type: Hash
|
979
|
-
default: N/A
|
980
|
-
description: "[System arguments](/system-arguments)"
|
data/static/classes.yml
CHANGED
data/static/constants.json
CHANGED
@@ -33,6 +33,26 @@
|
|
33
33
|
"large"
|
34
34
|
]
|
35
35
|
},
|
36
|
+
"Primer::Alpha::UnderlineNav": {
|
37
|
+
"ACTIONS_TAG_DEFAULT": "div",
|
38
|
+
"ACTIONS_TAG_OPTIONS": [
|
39
|
+
"div",
|
40
|
+
"span"
|
41
|
+
],
|
42
|
+
"ALIGN_DEFAULT": "left",
|
43
|
+
"ALIGN_OPTIONS": [
|
44
|
+
"left",
|
45
|
+
"right"
|
46
|
+
],
|
47
|
+
"BODY_TAG_DEFAULT": "ul",
|
48
|
+
"TAG_DEFAULT": "nav",
|
49
|
+
"TAG_OPTIONS": [
|
50
|
+
"nav",
|
51
|
+
"div"
|
52
|
+
]
|
53
|
+
},
|
54
|
+
"Primer::Alpha::UnderlinePanels": {
|
55
|
+
},
|
36
56
|
"Primer::BaseButton": {
|
37
57
|
"DEFAULT_TAG": "button",
|
38
58
|
"DEFAULT_TYPE": "button",
|
@@ -82,6 +102,11 @@
|
|
82
102
|
"span"
|
83
103
|
]
|
84
104
|
},
|
105
|
+
"Primer::Beta::Breadcrumbs": {
|
106
|
+
"Item": "Primer::Beta::Breadcrumbs::Item"
|
107
|
+
},
|
108
|
+
"Primer::Beta::Breadcrumbs::Item": {
|
109
|
+
},
|
85
110
|
"Primer::Beta::Text": {
|
86
111
|
"DEFAULT_TAG": "span"
|
87
112
|
},
|
@@ -110,11 +135,6 @@
|
|
110
135
|
},
|
111
136
|
"Primer::BoxComponent": {
|
112
137
|
},
|
113
|
-
"Primer::BreadcrumbComponent": {
|
114
|
-
"ItemComponent": "Primer::BreadcrumbComponent::ItemComponent"
|
115
|
-
},
|
116
|
-
"Primer::BreadcrumbComponent::ItemComponent": {
|
117
|
-
},
|
118
138
|
"Primer::ButtonComponent": {
|
119
139
|
"DEFAULT_SCHEME": "default",
|
120
140
|
"DEFAULT_VARIANT": "medium",
|
@@ -619,22 +639,5 @@
|
|
619
639
|
"p",
|
620
640
|
"strong"
|
621
641
|
]
|
622
|
-
},
|
623
|
-
"Primer::UnderlineNavComponent": {
|
624
|
-
"ACTIONS_TAG_DEFAULT": "div",
|
625
|
-
"ACTIONS_TAG_OPTIONS": [
|
626
|
-
"div",
|
627
|
-
"span"
|
628
|
-
],
|
629
|
-
"ALIGN_DEFAULT": "left",
|
630
|
-
"ALIGN_OPTIONS": [
|
631
|
-
"left",
|
632
|
-
"right"
|
633
|
-
],
|
634
|
-
"BODY_TAG_DEFAULT": "div",
|
635
|
-
"BODY_TAG_OPTIONS": [
|
636
|
-
"div",
|
637
|
-
"ul"
|
638
|
-
]
|
639
642
|
}
|
640
643
|
}
|
data/static/statuses.json
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"Primer::Alpha::ButtonMarketing": "alpha",
|
3
|
+
"Primer::Alpha::UnderlineNav": "alpha",
|
4
|
+
"Primer::Alpha::UnderlinePanels": "alpha",
|
3
5
|
"Primer::BaseButton": "beta",
|
4
6
|
"Primer::BaseComponent": "beta",
|
5
7
|
"Primer::Beta::AutoComplete": "beta",
|
@@ -7,14 +9,14 @@
|
|
7
9
|
"Primer::Beta::AutoComplete::Item": "beta",
|
8
10
|
"Primer::Beta::Avatar": "beta",
|
9
11
|
"Primer::Beta::AvatarStack": "beta",
|
12
|
+
"Primer::Beta::Breadcrumbs": "beta",
|
13
|
+
"Primer::Beta::Breadcrumbs::Item": "alpha",
|
10
14
|
"Primer::Beta::Text": "beta",
|
11
15
|
"Primer::Beta::Truncate": "beta",
|
12
16
|
"Primer::Beta::Truncate::TruncateText": "alpha",
|
13
17
|
"Primer::BlankslateComponent": "beta",
|
14
18
|
"Primer::BorderBoxComponent": "beta",
|
15
19
|
"Primer::BoxComponent": "stable",
|
16
|
-
"Primer::BreadcrumbComponent": "beta",
|
17
|
-
"Primer::BreadcrumbComponent::ItemComponent": "alpha",
|
18
20
|
"Primer::ButtonComponent": "beta",
|
19
21
|
"Primer::ButtonGroup": "beta",
|
20
22
|
"Primer::ClipboardCopy": "beta",
|
@@ -53,6 +55,5 @@
|
|
53
55
|
"Primer::TimelineItemComponent": "beta",
|
54
56
|
"Primer::TimelineItemComponent::BadgeComponent": "alpha",
|
55
57
|
"Primer::Tooltip": "beta",
|
56
|
-
"Primer::Truncate": "beta"
|
57
|
-
"Primer::UnderlineNavComponent": "alpha"
|
58
|
+
"Primer::Truncate": "beta"
|
58
59
|
}
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: primer_view_components
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.54
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- GitHub Open Source
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-08-
|
11
|
+
date: 2021-08-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: actionview
|
@@ -352,7 +352,7 @@ dependencies:
|
|
352
352
|
- - "~>"
|
353
353
|
- !ruby/object:Gem::Version
|
354
354
|
version: 0.9.25
|
355
|
-
description:
|
355
|
+
description:
|
356
356
|
email:
|
357
357
|
- opensource+primer_view_components@github.com
|
358
358
|
executables: []
|
@@ -365,10 +365,12 @@ files:
|
|
365
365
|
- app/assets/javascripts/primer_view_components.js
|
366
366
|
- app/assets/javascripts/primer_view_components.js.map
|
367
367
|
- app/components/primer/alpha/button_marketing.rb
|
368
|
+
- app/components/primer/alpha/underline_nav.html.erb
|
369
|
+
- app/components/primer/alpha/underline_nav.rb
|
370
|
+
- app/components/primer/alpha/underline_panels.html.erb
|
371
|
+
- app/components/primer/alpha/underline_panels.rb
|
368
372
|
- app/components/primer/auto_complete/auto_complete.d.ts
|
369
373
|
- app/components/primer/auto_complete/auto_complete.js
|
370
|
-
- app/components/primer/auto_complete/auto_component.d.ts
|
371
|
-
- app/components/primer/auto_complete/auto_component.js
|
372
374
|
- app/components/primer/base_button.rb
|
373
375
|
- app/components/primer/base_component.rb
|
374
376
|
- app/components/primer/beta/auto_complete.rb
|
@@ -380,6 +382,8 @@ files:
|
|
380
382
|
- app/components/primer/beta/avatar.rb
|
381
383
|
- app/components/primer/beta/avatar_stack.html.erb
|
382
384
|
- app/components/primer/beta/avatar_stack.rb
|
385
|
+
- app/components/primer/beta/breadcrumbs.html.erb
|
386
|
+
- app/components/primer/beta/breadcrumbs.rb
|
383
387
|
- app/components/primer/beta/text.rb
|
384
388
|
- app/components/primer/beta/truncate.html.erb
|
385
389
|
- app/components/primer/beta/truncate.rb
|
@@ -388,8 +392,6 @@ files:
|
|
388
392
|
- app/components/primer/border_box_component.html.erb
|
389
393
|
- app/components/primer/border_box_component.rb
|
390
394
|
- app/components/primer/box_component.rb
|
391
|
-
- app/components/primer/breadcrumb_component.html.erb
|
392
|
-
- app/components/primer/breadcrumb_component.rb
|
393
395
|
- app/components/primer/button_component.html.erb
|
394
396
|
- app/components/primer/button_component.rb
|
395
397
|
- app/components/primer/button_group.html.erb
|
@@ -472,8 +474,6 @@ files:
|
|
472
474
|
- app/components/primer/timeline_item_component.rb
|
473
475
|
- app/components/primer/tooltip.rb
|
474
476
|
- app/components/primer/truncate.rb
|
475
|
-
- app/components/primer/underline_nav_component.html.erb
|
476
|
-
- app/components/primer/underline_nav_component.rb
|
477
477
|
- app/lib/primer/class_name_helper.rb
|
478
478
|
- app/lib/primer/fetch_or_fallback_helper.rb
|
479
479
|
- app/lib/primer/join_style_arguments_helper.rb
|
@@ -481,6 +481,7 @@ files:
|
|
481
481
|
- app/lib/primer/status/dsl.rb
|
482
482
|
- app/lib/primer/tabbed_component_helper.rb
|
483
483
|
- app/lib/primer/test_selector_helper.rb
|
484
|
+
- app/lib/primer/underline_nav_helper.rb
|
484
485
|
- app/lib/primer/view_helper.rb
|
485
486
|
- lib/primer/classify.rb
|
486
487
|
- lib/primer/classify/cache.rb
|
@@ -539,7 +540,7 @@ licenses:
|
|
539
540
|
- MIT
|
540
541
|
metadata:
|
541
542
|
allowed_push_host: https://rubygems.org
|
542
|
-
post_install_message:
|
543
|
+
post_install_message:
|
543
544
|
rdoc_options: []
|
544
545
|
require_paths:
|
545
546
|
- lib
|
@@ -555,7 +556,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
555
556
|
version: '0'
|
556
557
|
requirements: []
|
557
558
|
rubygems_version: 3.1.2
|
558
|
-
signing_key:
|
559
|
+
signing_key:
|
559
560
|
specification_version: 4
|
560
561
|
summary: ViewComponents for the Primer Design System
|
561
562
|
test_files: []
|
@@ -1 +0,0 @@
|
|
1
|
-
import '@github/auto-complete-element';
|
@@ -1 +0,0 @@
|
|
1
|
-
import '@github/auto-complete-element';
|
@@ -1,57 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Primer
|
4
|
-
# Use `Breadcrumb` 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
|
-
class BreadcrumbComponent < Primer::Component
|
6
|
-
status :beta
|
7
|
-
|
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"
|
14
|
-
|
15
|
-
# @example Basic
|
16
|
-
# <%= render(Primer::BreadcrumbComponent.new) do |component| %>
|
17
|
-
# <% component.item(href: "/") do %>Home<% end %>
|
18
|
-
# <% component.item(href: "/about") do %>About<% end %>
|
19
|
-
# <% component.item(selected: true) do %>Team<% end %>
|
20
|
-
# <% end %>
|
21
|
-
#
|
22
|
-
# @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
|
23
|
-
def initialize(**system_arguments)
|
24
|
-
@system_arguments = system_arguments
|
25
|
-
@system_arguments[:tag] = :nav
|
26
|
-
@system_arguments[:aria] = { label: "Breadcrumb" }
|
27
|
-
end
|
28
|
-
|
29
|
-
def render?
|
30
|
-
items.any?
|
31
|
-
end
|
32
|
-
|
33
|
-
# This component is part of `Primer::BreadcrumbComponent` and should not be
|
34
|
-
# used as a standalone component.
|
35
|
-
class ItemComponent < Primer::Component
|
36
|
-
def initialize(href: nil, selected: false, **system_arguments)
|
37
|
-
@href = href
|
38
|
-
@system_arguments = system_arguments
|
39
|
-
|
40
|
-
@href = nil if selected
|
41
|
-
@system_arguments[:tag] = :li
|
42
|
-
@system_arguments[:"aria-current"] = "page" if selected
|
43
|
-
@system_arguments[:classes] = "breadcrumb-item #{@system_arguments[:classes]}"
|
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
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
@@ -1,187 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Primer
|
4
|
-
# Use `UnderlineNav` to style navigation with a minimal
|
5
|
-
# underlined selected state, typically used for navigation placed at the top
|
6
|
-
# of the page.
|
7
|
-
class UnderlineNavComponent < Primer::Component
|
8
|
-
include Primer::TabbedComponentHelper
|
9
|
-
|
10
|
-
ALIGN_DEFAULT = :left
|
11
|
-
ALIGN_OPTIONS = [ALIGN_DEFAULT, :right].freeze
|
12
|
-
|
13
|
-
BODY_TAG_DEFAULT = :div
|
14
|
-
BODY_TAG_OPTIONS = [BODY_TAG_DEFAULT, :ul].freeze
|
15
|
-
|
16
|
-
ACTIONS_TAG_DEFAULT = :div
|
17
|
-
ACTIONS_TAG_OPTIONS = [ACTIONS_TAG_DEFAULT, :span].freeze
|
18
|
-
|
19
|
-
# Use the tabs to list navigation items. When `with_panel` is set on the parent, a button is rendered for panel navigation. Otherwise,
|
20
|
-
# an anchor tag is rendered for page navigation. For more information, refer to <%= link_to_component(Primer::Navigation::TabComponent) %>.
|
21
|
-
#
|
22
|
-
# @param panel_id [String] Only applies if `with_panel` is `true`. Unique id of panel.
|
23
|
-
# @param selected [Boolean] Whether the tab is selected.
|
24
|
-
# @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
|
25
|
-
renders_many :tabs, lambda { |selected: false, **system_arguments|
|
26
|
-
system_arguments[:classes] = class_names(
|
27
|
-
"UnderlineNav-item",
|
28
|
-
system_arguments[:classes]
|
29
|
-
)
|
30
|
-
|
31
|
-
Primer::Navigation::TabComponent.new(
|
32
|
-
list: list?,
|
33
|
-
selected: selected,
|
34
|
-
with_panel: @with_panel,
|
35
|
-
icon_classes: "UnderlineNav-octicon",
|
36
|
-
**system_arguments
|
37
|
-
)
|
38
|
-
}
|
39
|
-
|
40
|
-
# Use actions for a call to action.
|
41
|
-
#
|
42
|
-
# @param tag [Symbol] (Primer::UnderlineNavComponent::ACTIONS_TAG_DEFAULT) <%= one_of(Primer::UnderlineNavComponent::ACTIONS_TAG_OPTIONS) %>
|
43
|
-
# @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
|
44
|
-
renders_one :actions, lambda { |tag: ACTIONS_TAG_DEFAULT, **system_arguments|
|
45
|
-
system_arguments[:tag] = fetch_or_fallback(ACTIONS_TAG_OPTIONS, tag, ACTIONS_TAG_DEFAULT)
|
46
|
-
system_arguments[:classes] = class_names("UnderlineNav-actions", system_arguments[:classes])
|
47
|
-
|
48
|
-
Primer::BaseComponent.new(**system_arguments)
|
49
|
-
}
|
50
|
-
|
51
|
-
# @example Default
|
52
|
-
# <%= render(Primer::UnderlineNavComponent.new(label: "Default")) do |component| %>
|
53
|
-
# <% component.tab(href: "#", selected: true) { "Item 1" } %>
|
54
|
-
# <% component.tab(href: "#") { "Item 2" } %>
|
55
|
-
# <% component.actions do %>
|
56
|
-
# <%= render(Primer::ButtonComponent.new) { "Button!" } %>
|
57
|
-
# <% end %>
|
58
|
-
# <% end %>
|
59
|
-
#
|
60
|
-
# @example With icons and counters
|
61
|
-
# <%= render(Primer::UnderlineNavComponent.new(label: "With icons and counters")) do |component| %>
|
62
|
-
# <% component.tab(href: "#", selected: true) do |t| %>
|
63
|
-
# <% t.icon(icon: :star) %>
|
64
|
-
# <% t.text { "Item 1" } %>
|
65
|
-
# <% end %>
|
66
|
-
# <% component.tab(href: "#") do |t| %>
|
67
|
-
# <% t.icon(icon: :star) %>
|
68
|
-
# <% t.text { "Item 2" } %>
|
69
|
-
# <% t.counter(count: 10) %>
|
70
|
-
# <% end %>
|
71
|
-
# <% component.tab(href: "#") do |t| %>
|
72
|
-
# <% t.text { "Item 3" } %>
|
73
|
-
# <% t.counter(count: 10) %>
|
74
|
-
# <% end %>
|
75
|
-
# <% component.actions do %>
|
76
|
-
# <%= render(Primer::ButtonComponent.new) { "Button!" } %>
|
77
|
-
# <% end %>
|
78
|
-
# <% end %>
|
79
|
-
#
|
80
|
-
# @example Align right
|
81
|
-
# <%= render(Primer::UnderlineNavComponent.new(label: "Align right", align: :right)) do |component| %>
|
82
|
-
# <% component.tab(href: "#", selected: true) do |t| %>
|
83
|
-
# <% t.text { "Item 1" } %>
|
84
|
-
# <% end %>
|
85
|
-
# <% component.tab(href: "#") do |t| %>
|
86
|
-
# <% t.text { "Item 2" } %>
|
87
|
-
# <% end %>
|
88
|
-
# <% component.actions do %>
|
89
|
-
# <%= render(Primer::ButtonComponent.new) { "Button!" } %>
|
90
|
-
# <% end %>
|
91
|
-
# <% end %>
|
92
|
-
#
|
93
|
-
# @example As a list
|
94
|
-
# <%= render(Primer::UnderlineNavComponent.new(label: "As a list", body_arguments: { tag: :ul })) do |component| %>
|
95
|
-
# <% component.tab(href: "#", selected: true) do |t| %>
|
96
|
-
# <% t.text { "Item 1" } %>
|
97
|
-
# <% end %>
|
98
|
-
# <% component.tab(href: "#") do |t| %>
|
99
|
-
# <% t.text { "Item 2" } %>
|
100
|
-
# <% end %>
|
101
|
-
# <% component.actions do %>
|
102
|
-
# <%= render(Primer::ButtonComponent.new) { "Button!" } %>
|
103
|
-
# <% end %>
|
104
|
-
# <% end %>
|
105
|
-
#
|
106
|
-
# @example With panels
|
107
|
-
# <%= render(Primer::UnderlineNavComponent.new(label: "With panels", with_panel: true)) do |component| %>
|
108
|
-
# <% component.tab(selected: true, id: "tab-1", panel_id: "panel-1") do |t| %>
|
109
|
-
# <% t.text { "Item 1" } %>
|
110
|
-
# <% t.panel do %>
|
111
|
-
# Panel 1
|
112
|
-
# <% end %>
|
113
|
-
# <% end %>
|
114
|
-
# <% component.tab(id: "tab-2", panel_id: "panel-2") do |t| %>
|
115
|
-
# <% t.text { "Item 2" } %>
|
116
|
-
# <% t.panel do %>
|
117
|
-
# Panel 2
|
118
|
-
# <% end %>
|
119
|
-
# <% end %>
|
120
|
-
# <% component.actions do %>
|
121
|
-
# <%= render(Primer::ButtonComponent.new) { "Button!" } %>
|
122
|
-
# <% end %>
|
123
|
-
# <% end %>
|
124
|
-
#
|
125
|
-
# @example Customizing the body
|
126
|
-
# <%= render(Primer::UnderlineNavComponent.new(label: "Default", body_arguments: { tag: :ul, classes: "custom-class", border: true, border_color: :info })) do |c| %>
|
127
|
-
# <% c.tab(selected: true, href: "#") { "Tab 1" }%>
|
128
|
-
# <% c.tab(href: "#") { "Tab 2" } %>
|
129
|
-
# <% c.tab(href: "#") { "Tab 3" } %>
|
130
|
-
# <% end %>
|
131
|
-
#
|
132
|
-
# @example Customizing the wrapper
|
133
|
-
# <%= render(Primer::UnderlineNavComponent.new(label: "Default", wrapper_arguments: { classes: "custom-class", border: true, border_color: :info })) do |c| %>
|
134
|
-
# <% c.tab(selected: true, href: "#") { "Tab 1" }%>
|
135
|
-
# <% c.tab(href: "#") { "Tab 2" } %>
|
136
|
-
# <% c.tab(href: "#") { "Tab 3" } %>
|
137
|
-
# <% end %>
|
138
|
-
#
|
139
|
-
# @param label [String] The `aria-label` on top level `<nav>` element.
|
140
|
-
# @param with_panel [Boolean] Whether the `UnderlineNav` should navigate through pages or panels. When true, <%= link_to_component(Primer::TabContainerComponent) %> is
|
141
|
-
# rendered along with JavaScript behavior.
|
142
|
-
# @param align [Symbol] <%= one_of(Primer::UnderlineNavComponent::ALIGN_OPTIONS) %> - Defaults to <%= Primer::UnderlineNavComponent::ALIGN_DEFAULT %>
|
143
|
-
# @param body_arguments [Hash] <%= link_to_system_arguments_docs %> for the body wrapper.
|
144
|
-
# @param wrapper_arguments [Hash] <%= link_to_system_arguments_docs %> for the `TabContainer` wrapper. Only applies if `with_panel` is `true`.
|
145
|
-
# @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
|
146
|
-
def initialize(label:, with_panel: false, align: ALIGN_DEFAULT, body_arguments: { tag: BODY_TAG_DEFAULT }, wrapper_arguments: {}, **system_arguments)
|
147
|
-
@with_panel = with_panel
|
148
|
-
@align = fetch_or_fallback(ALIGN_OPTIONS, align, ALIGN_DEFAULT)
|
149
|
-
@wrapper_arguments = wrapper_arguments
|
150
|
-
|
151
|
-
@system_arguments = system_arguments
|
152
|
-
@system_arguments[:tag] = navigation_tag(with_panel)
|
153
|
-
@system_arguments[:classes] = class_names(
|
154
|
-
@system_arguments[:classes],
|
155
|
-
"UnderlineNav",
|
156
|
-
"UnderlineNav--right" => @align == :right
|
157
|
-
)
|
158
|
-
|
159
|
-
@body_arguments = body_arguments
|
160
|
-
@body_tag = fetch_or_fallback(BODY_TAG_OPTIONS, body_arguments[:tag]&.to_sym, BODY_TAG_DEFAULT)
|
161
|
-
|
162
|
-
@body_arguments[:tag] = @body_tag
|
163
|
-
@body_arguments[:classes] = class_names(
|
164
|
-
"UnderlineNav-body",
|
165
|
-
@body_arguments[:classes],
|
166
|
-
"list-style-none" => list?
|
167
|
-
)
|
168
|
-
|
169
|
-
if with_panel
|
170
|
-
@body_arguments[:role] = :tablist
|
171
|
-
@body_arguments[:"aria-label"] = label
|
172
|
-
else
|
173
|
-
@system_arguments[:"aria-label"] = label
|
174
|
-
end
|
175
|
-
end
|
176
|
-
|
177
|
-
private
|
178
|
-
|
179
|
-
def list?
|
180
|
-
@body_tag == :ul
|
181
|
-
end
|
182
|
-
|
183
|
-
def body
|
184
|
-
Primer::BaseComponent.new(**@body_arguments)
|
185
|
-
end
|
186
|
-
end
|
187
|
-
end
|