primer_view_components 0.0.50 → 0.0.54
Sign up to get free protection for your applications and to get access to all the features.
- 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
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
|
@@ -0,0 +1,110 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Primer
|
4
|
+
module Beta
|
5
|
+
# Use `Truncate` to shorten overflowing text with an ellipsis.
|
6
|
+
class Truncate < Primer::Component
|
7
|
+
status :beta
|
8
|
+
|
9
|
+
# Text slot used for the truncated text.
|
10
|
+
#
|
11
|
+
# @param priority [Boolean] if true, the text will be given priority
|
12
|
+
# @param expandable [Boolean] if true, the text will expand on hover or focus
|
13
|
+
# @param max_width [Integer] if provided, the text will be truncated at a maximum width
|
14
|
+
# @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
|
15
|
+
renders_many :items, "TruncateText"
|
16
|
+
|
17
|
+
# @example Default
|
18
|
+
# <%= render(Primer::Beta::Truncate.new) { "branch-name-that-is-really-long" } %>
|
19
|
+
#
|
20
|
+
# @example Multiple items
|
21
|
+
# <%= render(Primer::Beta::Truncate.new) do |component| %>
|
22
|
+
# <% component.item do %>really-long-repository-owner-name<% end %>
|
23
|
+
# <% component.item(font_weight: :bold) do %>
|
24
|
+
# <%= render(Primer::BaseComponent.new(tag: :span, font_weight: :normal)) { "/" } %> really-long-repository-name
|
25
|
+
# <% end %>
|
26
|
+
# <% end %>
|
27
|
+
#
|
28
|
+
# @example Advanced multiple items
|
29
|
+
# <%= render(Primer::Beta::Truncate.new(tag: :ol)) do |component| %>
|
30
|
+
# <% component.item(tag: :li) do %>primer<% end %>
|
31
|
+
# <% component.item(tag: :li, priority: true) do %>/ css<% end %>
|
32
|
+
# <% component.item(tag: :li) do %>/ Issues<% end %>
|
33
|
+
# <% component.item(tag: :li) do %>/ #123 —<% end %>
|
34
|
+
# <% component.item(tag: :li, priority: true) do %>
|
35
|
+
# Visual bug on primer.style found in lists
|
36
|
+
# <% end %>
|
37
|
+
# <% end %>
|
38
|
+
#
|
39
|
+
# @example Expand on hover or focus
|
40
|
+
# <%= render(Primer::Beta::Truncate.new) do |component| %>
|
41
|
+
# <% component.item(tag: :a, href: "#", expandable: true) do %>really-long-repository-owner-name<% end %>
|
42
|
+
# <% component.item(tag: :a, href: "#", expandable: true) do %>really-long-repository-owner-name<% end %>
|
43
|
+
# <% component.item(tag: :a, href: "#", expandable: true) do %>really-long-repository-owner-name<% end %>
|
44
|
+
# <% component.item(tag: :a, href: "#", expandable: true) do %>really-long-repository-owner-name<% end %>
|
45
|
+
# <% end %>
|
46
|
+
#
|
47
|
+
# @example Max widths
|
48
|
+
# <%= render(Primer::Beta::Truncate.new) do |component| %>
|
49
|
+
# <% component.item(max_width: 300, expandable: true) do %>branch-name-that-is-really-long-branch-name-that-is-really-long-branch-name-that-is-really-long<% end %>
|
50
|
+
# <% component.item(max_width: 200, expandable: true) do %>branch-name-that-is-really-long-branch-name-that-is-really-long-branch-name-that-is-really-long<% end %>
|
51
|
+
# <% component.item(max_width: 100, expandable: true) do %>branch-name-that-is-really-long-branch-name-that-is-really-long-branch-name-that-is-really-long<% end %>
|
52
|
+
# <% end %>
|
53
|
+
#
|
54
|
+
# @example Max widths on new lines
|
55
|
+
# <%= render(Primer::Beta::Truncate.new) do |component| %>
|
56
|
+
# <% component.item(max_width: 300, expandable: true) do %>branch-name-that-is-really-long-branch-name-that-is-really-long-branch-name-that-is-really-long<% end %>
|
57
|
+
# <% end %>
|
58
|
+
# <br/>
|
59
|
+
# <%= render(Primer::Beta::Truncate.new) do |component| %>
|
60
|
+
# <% component.item(max_width: 200, expandable: true) do %>branch-name-that-is-really-long-branch-name-that-is-really-long-branch-name-that-is-really-long<% end %>
|
61
|
+
# <% end %>
|
62
|
+
# <br/>
|
63
|
+
# <%= render(Primer::Beta::Truncate.new) do |component| %>
|
64
|
+
# <% component.item(max_width: 100, expandable: true) do %>branch-name-that-is-really-long-branch-name-that-is-really-long-branch-name-that-is-really-long<% end %>
|
65
|
+
# <% end %>
|
66
|
+
#
|
67
|
+
# @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
|
68
|
+
def initialize(**system_arguments)
|
69
|
+
@system_arguments = system_arguments
|
70
|
+
@system_arguments[:tag] = system_arguments[:tag] || :span
|
71
|
+
@system_arguments[:classes] = class_names(
|
72
|
+
"Truncate",
|
73
|
+
system_arguments[:classes]
|
74
|
+
)
|
75
|
+
end
|
76
|
+
|
77
|
+
def before_render
|
78
|
+
return unless content.present? && items.empty?
|
79
|
+
|
80
|
+
item { content }
|
81
|
+
end
|
82
|
+
|
83
|
+
def render?
|
84
|
+
items.any?
|
85
|
+
end
|
86
|
+
|
87
|
+
# This component is part of `Primer::Beta::Truncate` and should not be
|
88
|
+
# used as a standalone component.
|
89
|
+
class TruncateText < Primer::Component
|
90
|
+
def initialize(priority: false, expandable: false, max_width: nil, **system_arguments)
|
91
|
+
@system_arguments = system_arguments
|
92
|
+
@system_arguments[:tag] = system_arguments[:tag] || :span
|
93
|
+
@system_arguments[:classes] = class_names(
|
94
|
+
"Truncate-text",
|
95
|
+
"Truncate-text--primary": priority,
|
96
|
+
"Truncate-text--expandable": expandable
|
97
|
+
)
|
98
|
+
|
99
|
+
@system_arguments[:style] = join_style_arguments(@system_arguments[:style], "max-width: #{max_width}px;") unless max_width.nil?
|
100
|
+
end
|
101
|
+
|
102
|
+
def call
|
103
|
+
render(Primer::BaseComponent.new(**@system_arguments)) do
|
104
|
+
content
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
@@ -13,6 +13,14 @@ module Primer
|
|
13
13
|
}.freeze
|
14
14
|
PADDING_SUGGESTION = "Perhaps you could consider using :padding options of #{PADDING_MAPPINGS.keys.to_sentence}?"
|
15
15
|
|
16
|
+
DEFAULT_ROW_SCHEME = :default
|
17
|
+
ROW_SCHEME_MAPPINGS = {
|
18
|
+
DEFAULT_ROW_SCHEME => "",
|
19
|
+
:neutral => "Box-row--gray",
|
20
|
+
:info => "Box-row--blue",
|
21
|
+
:warning => "Box-row--yellow"
|
22
|
+
}.freeze
|
23
|
+
|
16
24
|
# Optional Header.
|
17
25
|
#
|
18
26
|
# @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
|
@@ -54,11 +62,13 @@ module Primer
|
|
54
62
|
|
55
63
|
# Use Rows to add rows with borders and maintain the same padding.
|
56
64
|
#
|
65
|
+
# @param scheme [Symbol] Color scheme. <%= one_of(Primer::BorderBoxComponent::ROW_SCHEME_MAPPINGS.keys) %>
|
57
66
|
# @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
|
58
|
-
renders_many :rows, lambda {
|
67
|
+
renders_many :rows, lambda { |scheme: DEFAULT_ROW_SCHEME, **system_arguments|
|
59
68
|
system_arguments[:tag] = :li
|
60
69
|
system_arguments[:classes] = class_names(
|
61
70
|
"Box-row",
|
71
|
+
ROW_SCHEME_MAPPINGS[fetch_or_fallback(ROW_SCHEME_MAPPINGS.keys, scheme, DEFAULT_ROW_SCHEME)],
|
62
72
|
system_arguments[:classes]
|
63
73
|
)
|
64
74
|
|
@@ -102,6 +112,22 @@ module Primer
|
|
102
112
|
# <% end %>
|
103
113
|
# <% end %>
|
104
114
|
#
|
115
|
+
# @example Row colors
|
116
|
+
# <%= render(Primer::BorderBoxComponent.new) do |component| %>
|
117
|
+
# <% component.row do %>
|
118
|
+
# Default
|
119
|
+
# <% end %>
|
120
|
+
# <% component.row(scheme: :neutral) do %>
|
121
|
+
# Neutral
|
122
|
+
# <% end %>
|
123
|
+
# <% component.row(scheme: :info) do %>
|
124
|
+
# Info
|
125
|
+
# <% end %>
|
126
|
+
# <% component.row(scheme: :warning) do %>
|
127
|
+
# Warning
|
128
|
+
# <% end %>
|
129
|
+
# <% end %>
|
130
|
+
#
|
105
131
|
# @param padding [Symbol] <%= one_of(Primer::BorderBoxComponent::PADDING_MAPPINGS.keys) %>
|
106
132
|
# @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
|
107
133
|
def initialize(padding: DEFAULT_PADDING, **system_arguments)
|
@@ -6,7 +6,7 @@ module Primer
|
|
6
6
|
# @accessibility
|
7
7
|
# Always set an accessible label to help the user interact with the component.
|
8
8
|
class ClipboardCopy < Primer::Component
|
9
|
-
status :
|
9
|
+
status :beta
|
10
10
|
|
11
11
|
# @example Default
|
12
12
|
# <%= render(Primer::ClipboardCopy.new(value: "Text to copy", "aria-label": "Copy text to the system clipboard")) %>
|
@@ -28,7 +28,7 @@ module Primer
|
|
28
28
|
# Dropdown
|
29
29
|
# <% end %>
|
30
30
|
#
|
31
|
-
#
|
31
|
+
# <% c.menu(header: "Options") do |menu|
|
32
32
|
# menu.item { "Item 1" }
|
33
33
|
# menu.item { "Item 2" }
|
34
34
|
# menu.item { "Item 3" }
|
@@ -45,7 +45,7 @@ module Primer
|
|
45
45
|
# Dropdown
|
46
46
|
# <% end %>
|
47
47
|
#
|
48
|
-
#
|
48
|
+
# <% c.menu(header: "Options") do |menu|
|
49
49
|
# menu.item { "Item 1" }
|
50
50
|
# menu.item { "Item 2" }
|
51
51
|
# menu.item(divider: true)
|
@@ -63,7 +63,7 @@ module Primer
|
|
63
63
|
# Dropdown
|
64
64
|
# <% end %>
|
65
65
|
#
|
66
|
-
#
|
66
|
+
# <% c.menu(header: "Options", direction: :s) do |menu|
|
67
67
|
# menu.item { "Item 1" }
|
68
68
|
# menu.item { "Item 2" }
|
69
69
|
# menu.item { "Item 3" }
|
@@ -77,7 +77,7 @@ module Primer
|
|
77
77
|
# Dropdown
|
78
78
|
# <% end %>
|
79
79
|
#
|
80
|
-
#
|
80
|
+
# <% c.menu(header: "Options") do |menu|
|
81
81
|
# menu.item { "Item 1" }
|
82
82
|
# menu.item { "Item 2" }
|
83
83
|
# menu.item { "Item 3" }
|
@@ -91,7 +91,7 @@ module Primer
|
|
91
91
|
# Dropdown
|
92
92
|
# <% end %>
|
93
93
|
#
|
94
|
-
#
|
94
|
+
# <% c.menu(header: "Options") do |menu|
|
95
95
|
# menu.item { "Item 1" }
|
96
96
|
# menu.item { "Item 2" }
|
97
97
|
# menu.item { "Item 3" }
|
@@ -105,7 +105,7 @@ module Primer
|
|
105
105
|
# Dropdown
|
106
106
|
# <% end %>
|
107
107
|
#
|
108
|
-
#
|
108
|
+
# <% c.menu(as: :list, header: "Options") do |menu|
|
109
109
|
# menu.item { "Item 1" }
|
110
110
|
# menu.item { "Item 2" }
|
111
111
|
# menu.item(divider: true)
|
@@ -120,7 +120,7 @@ module Primer
|
|
120
120
|
# Dropdown
|
121
121
|
# <% end %>
|
122
122
|
#
|
123
|
-
#
|
123
|
+
# <% c.menu(header: "Options") do |menu|
|
124
124
|
# menu.item(tag: :button) { "Item 1" }
|
125
125
|
# menu.item(classes: "custom-class") { "Item 2" }
|
126
126
|
# menu.item { "Item 3" }
|
@@ -42,7 +42,7 @@ module Primer
|
|
42
42
|
# @param type [Symbol] <%= one_of(Primer::BaseButton::TYPE_OPTIONS) %>
|
43
43
|
# @param box [Boolean] Whether the button is in a <%= link_to_component(Primer::BorderBoxComponent) %>. If `true`, the button will have the `Box-btn-octicon` class.
|
44
44
|
# @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
|
45
|
-
def initialize(scheme: DEFAULT_SCHEME,
|
45
|
+
def initialize(icon:, scheme: DEFAULT_SCHEME, box: false, **system_arguments)
|
46
46
|
@icon = icon
|
47
47
|
|
48
48
|
@system_arguments = system_arguments
|
@@ -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
|
|
@@ -142,7 +144,7 @@ module Primer
|
|
142
144
|
end
|
143
145
|
|
144
146
|
render(Primer::BaseComponent.new(**@wrapper_arguments)) do
|
145
|
-
yield
|
147
|
+
yield if block_given?
|
146
148
|
end
|
147
149
|
end
|
148
150
|
|
@@ -11,9 +11,6 @@ module Primer
|
|
11
11
|
# @param bg [Symbol] The background color
|
12
12
|
# @param kwargs [Hash] The same arguments as <%= link_to_system_arguments_docs %>.
|
13
13
|
renders_many :items, lambda { |percentage: 0, bg: :success_inverse, **system_arguments|
|
14
|
-
percentage = percentage
|
15
|
-
system_arguments = system_arguments
|
16
|
-
|
17
14
|
system_arguments[:tag] = :span
|
18
15
|
system_arguments[:bg] = bg
|
19
16
|
system_arguments[:style] = join_style_arguments(system_arguments[:style], "width: #{percentage}%;")
|
@@ -40,7 +40,7 @@ module Primer
|
|
40
40
|
|
41
41
|
# @example Default
|
42
42
|
# <%= render(Primer::TabNavComponent.new(label: "Default")) do |c| %>
|
43
|
-
# <% c.tab(selected: true, href: "#") { "Tab 1" }%>
|
43
|
+
# <% c.tab(selected: true, href: "#") { "Tab 1" } %>
|
44
44
|
# <% c.tab(href: "#") { "Tab 2" } %>
|
45
45
|
# <% c.tab(href: "#") { "Tab 3" } %>
|
46
46
|
# <% end %>
|
@@ -48,6 +48,7 @@ module Primer
|
|
48
48
|
end
|
49
49
|
end
|
50
50
|
|
51
|
+
# rubocop:disable Style/OptionalBooleanParameter
|
51
52
|
def fetch_or_fallback_boolean(given_value, fallback = false)
|
52
53
|
if [true, false].include?(given_value)
|
53
54
|
given_value
|
@@ -55,6 +56,7 @@ module Primer
|
|
55
56
|
fallback
|
56
57
|
end
|
57
58
|
end
|
59
|
+
# rubocop:enable Style/OptionalBooleanParameter
|
58
60
|
|
59
61
|
def silence_deprecations?
|
60
62
|
Rails.application.config.primer_view_components.silence_deprecations
|
@@ -20,11 +20,11 @@ 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
|
-
yield
|
27
|
+
yield if block_given?
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
@@ -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
|