primer_view_components 0.0.43 → 0.0.47
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 +220 -3
- data/app/assets/javascripts/primer_view_components.js +1 -1
- data/app/assets/javascripts/primer_view_components.js.map +1 -1
- data/app/components/primer/alpha/button_marketing.rb +70 -0
- data/app/components/primer/avatar_stack_component.rb +9 -3
- data/app/components/primer/base_component.rb +52 -23
- data/app/components/primer/beta/auto_complete.rb +159 -0
- data/app/components/primer/beta/auto_complete/auto_complete.d.ts +1 -0
- data/app/components/primer/{auto_complete → beta/auto_complete}/auto_complete.html.erb +1 -0
- data/app/components/primer/beta/auto_complete/auto_complete.js +1 -0
- data/app/components/primer/{auto_complete → beta/auto_complete}/auto_complete.ts +0 -0
- data/app/components/primer/beta/auto_complete/item.rb +44 -0
- data/app/components/primer/beta/avatar.rb +77 -0
- data/app/components/primer/beta/text.rb +27 -0
- data/app/components/primer/blankslate_component.rb +2 -1
- data/app/components/primer/border_box_component.rb +3 -0
- data/app/components/primer/button_component.rb +3 -2
- data/app/components/primer/clipboard_copy.rb +25 -7
- data/app/components/primer/component.rb +4 -0
- data/app/components/primer/details_component.rb +18 -3
- data/app/components/primer/dropdown.d.ts +1 -0
- data/app/components/primer/{dropdown_component.html.erb → dropdown.html.erb} +2 -1
- data/app/components/primer/dropdown.js +1 -0
- data/app/components/primer/dropdown.rb +149 -0
- data/app/components/primer/dropdown.ts +1 -0
- data/app/components/primer/dropdown/menu.d.ts +1 -0
- data/app/components/primer/dropdown/menu.html.erb +25 -0
- data/app/components/primer/dropdown/menu.js +1 -0
- data/app/components/primer/dropdown/menu.rb +99 -0
- data/app/components/primer/dropdown/menu.ts +1 -0
- data/app/components/primer/heading_component.rb +1 -1
- data/app/components/primer/icon_button.rb +1 -1
- data/app/components/primer/image_crop.rb +1 -1
- data/app/components/primer/markdown.rb +9 -9
- data/app/components/primer/menu_component.rb +7 -3
- data/app/components/primer/navigation/tab_component.rb +6 -6
- data/app/components/primer/octicon_component.rb +3 -2
- data/app/components/primer/popover_component.rb +6 -3
- data/app/components/primer/primer.d.ts +2 -1
- data/app/components/primer/primer.js +2 -1
- data/app/components/primer/primer.ts +2 -1
- data/app/components/primer/spinner_component.rb +2 -0
- data/app/components/primer/tab_nav_component.rb +5 -3
- data/app/components/primer/timeline_item_component.rb +2 -2
- data/app/components/primer/tooltip.rb +1 -1
- data/app/components/primer/truncate.rb +5 -0
- data/app/components/primer/underline_nav_component.rb +10 -4
- data/{app/lib → lib}/primer/classify.rb +16 -33
- data/{app/lib → lib}/primer/classify/cache.rb +6 -40
- data/{app/lib → lib}/primer/classify/flex.rb +0 -0
- data/{app/lib → lib}/primer/classify/functional_background_colors.rb +2 -0
- data/{app/lib → lib}/primer/classify/functional_border_colors.rb +2 -0
- data/{app/lib → lib}/primer/classify/functional_colors.rb +0 -0
- data/{app/lib → lib}/primer/classify/functional_text_colors.rb +2 -0
- data/{app/lib → lib}/primer/classify/grid.rb +0 -0
- data/lib/primer/classify/utilities.rb +148 -0
- data/lib/primer/classify/utilities.yml +1271 -0
- data/lib/primer/view_components.rb +1 -0
- data/lib/primer/view_components/linters/argument_mappers/button.rb +82 -0
- data/lib/primer/view_components/linters/argument_mappers/conversion_error.rb +10 -0
- data/lib/primer/view_components/linters/argument_mappers/system_arguments.rb +47 -0
- data/lib/primer/view_components/linters/button_component_migration_counter.rb +24 -1
- data/lib/primer/view_components/linters/flash_component_migration_counter.rb +1 -1
- data/lib/primer/view_components/linters/helpers.rb +137 -18
- data/lib/primer/view_components/statuses.rb +14 -0
- data/lib/primer/view_components/version.rb +1 -1
- data/lib/tasks/docs.rake +179 -110
- data/lib/tasks/utilities.rake +105 -0
- data/lib/yard/docs_helper.rb +13 -3
- data/static/statuses.json +9 -7
- metadata +41 -27
- data/app/components/primer/auto_complete.rb +0 -100
- data/app/components/primer/auto_complete/item.rb +0 -42
- data/app/components/primer/avatar_component.rb +0 -75
- data/app/components/primer/button_marketing_component.rb +0 -68
- data/app/components/primer/dropdown/menu_component.html.erb +0 -12
- data/app/components/primer/dropdown/menu_component.rb +0 -46
- data/app/components/primer/dropdown_component.rb +0 -73
- data/app/components/primer/text_component.rb +0 -25
- data/app/lib/primer/classify/spacing.rb +0 -63
@@ -0,0 +1 @@
|
|
1
|
+
import './dropdown/menu';
|
@@ -1,6 +1,7 @@
|
|
1
1
|
<%= render(Primer::DetailsComponent.new(**@system_arguments)) do |c| %>
|
2
|
-
<% c.summary(
|
2
|
+
<% c.summary(**@button_arguments) do %>
|
3
3
|
<%= button %>
|
4
|
+
<% if @with_caret %><div class="dropdown-caret"></div><% end %>
|
4
5
|
<% end %>
|
5
6
|
|
6
7
|
<% c.body do %>
|
@@ -0,0 +1 @@
|
|
1
|
+
import './dropdown/menu';
|
@@ -0,0 +1,149 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Primer
|
4
|
+
# `Dropdown` is a lightweight context menu for housing navigation and actions.
|
5
|
+
# They're great for instances where you don't need the full power (and code) of the SelectMenu.
|
6
|
+
class Dropdown < Primer::Component
|
7
|
+
# Required trigger for the dropdown. Has the same arguments as <%= link_to_component(Primer::ButtonComponent) %>,
|
8
|
+
# but it is locked as a `summary` tag.
|
9
|
+
renders_one :button, lambda { |**system_arguments, &block|
|
10
|
+
@button_arguments = system_arguments
|
11
|
+
@button_arguments[:button] = true
|
12
|
+
|
13
|
+
view_context.capture { block&.call }
|
14
|
+
}
|
15
|
+
|
16
|
+
# Required context menu for the dropdown.
|
17
|
+
#
|
18
|
+
# @param as [Symbol] When `as` is `:list`, wraps the menu in a `<ul>` with a `<li>` for each item.
|
19
|
+
# @param direction [Symbol] <%= one_of(Primer::Dropdown::Menu::DIRECTION_OPTIONS) %>
|
20
|
+
# @param scheme [Symbol] Pass `:dark` for dark mode theming
|
21
|
+
# @param header [String] Optional string to display as the header
|
22
|
+
# @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
|
23
|
+
renders_one :menu, "Primer::Dropdown::Menu"
|
24
|
+
|
25
|
+
# @example Default
|
26
|
+
# <%= render(Primer::Dropdown.new) do |c| %>
|
27
|
+
# <% c.button do %>
|
28
|
+
# Dropdown
|
29
|
+
# <% end %>
|
30
|
+
#
|
31
|
+
# <%= c.menu(header: "Options") do |menu|
|
32
|
+
# menu.item { "Item 1" }
|
33
|
+
# menu.item { "Item 2" }
|
34
|
+
# menu.item { "Item 3" }
|
35
|
+
# end %>
|
36
|
+
# <% end %>
|
37
|
+
#
|
38
|
+
# @example With dividers
|
39
|
+
#
|
40
|
+
# @description
|
41
|
+
# Dividers can be used to separate a group of items. They don't have any content.
|
42
|
+
# @code
|
43
|
+
# <%= render(Primer::Dropdown.new) do |c| %>
|
44
|
+
# <% c.button do %>
|
45
|
+
# Dropdown
|
46
|
+
# <% end %>
|
47
|
+
#
|
48
|
+
# <%= c.menu(header: "Options") do |menu|
|
49
|
+
# menu.item { "Item 1" }
|
50
|
+
# menu.item { "Item 2" }
|
51
|
+
# menu.item(divider: true)
|
52
|
+
# menu.item { "Item 3" }
|
53
|
+
# menu.item { "Item 4" }
|
54
|
+
# menu.item(divider: true)
|
55
|
+
# menu.item { "Item 5" }
|
56
|
+
# menu.item { "Item 6" }
|
57
|
+
# end %>
|
58
|
+
# <% end %>
|
59
|
+
#
|
60
|
+
# @example With direction
|
61
|
+
# <%= render(Primer::Dropdown.new(display: :inline_block)) do |c| %>
|
62
|
+
# <% c.button do %>
|
63
|
+
# Dropdown
|
64
|
+
# <% end %>
|
65
|
+
#
|
66
|
+
# <%= c.menu(header: "Options", direction: :s) do |menu|
|
67
|
+
# menu.item { "Item 1" }
|
68
|
+
# menu.item { "Item 2" }
|
69
|
+
# menu.item { "Item 3" }
|
70
|
+
# menu.item { "Item 4" }
|
71
|
+
# end %>
|
72
|
+
# <% end %>
|
73
|
+
#
|
74
|
+
# @example With caret
|
75
|
+
# <%= render(Primer::Dropdown.new(with_caret: true)) do |c| %>
|
76
|
+
# <% c.button do %>
|
77
|
+
# Dropdown
|
78
|
+
# <% end %>
|
79
|
+
#
|
80
|
+
# <%= c.menu(header: "Options") do |menu|
|
81
|
+
# menu.item { "Item 1" }
|
82
|
+
# menu.item { "Item 2" }
|
83
|
+
# menu.item { "Item 3" }
|
84
|
+
# menu.item { "Item 4" }
|
85
|
+
# end %>
|
86
|
+
# <% end %>
|
87
|
+
#
|
88
|
+
# @example Customizing the button
|
89
|
+
# <%= render(Primer::Dropdown.new) do |c| %>
|
90
|
+
# <% c.button(scheme: :primary, variant: :small) do %>
|
91
|
+
# Dropdown
|
92
|
+
# <% end %>
|
93
|
+
#
|
94
|
+
# <%= c.menu(header: "Options") do |menu|
|
95
|
+
# menu.item { "Item 1" }
|
96
|
+
# menu.item { "Item 2" }
|
97
|
+
# menu.item { "Item 3" }
|
98
|
+
# menu.item { "Item 4" }
|
99
|
+
# end %>
|
100
|
+
# <% end %>
|
101
|
+
#
|
102
|
+
# @example Menu as list
|
103
|
+
# <%= render(Primer::Dropdown.new) do |c| %>
|
104
|
+
# <% c.button do %>
|
105
|
+
# Dropdown
|
106
|
+
# <% end %>
|
107
|
+
#
|
108
|
+
# <%= c.menu(as: :list, header: "Options") do |menu|
|
109
|
+
# menu.item { "Item 1" }
|
110
|
+
# menu.item { "Item 2" }
|
111
|
+
# menu.item(divider: true)
|
112
|
+
# menu.item { "Item 3" }
|
113
|
+
# menu.item { "Item 4" }
|
114
|
+
# end %>
|
115
|
+
# <% end %>
|
116
|
+
#
|
117
|
+
# @example Customizing menu items
|
118
|
+
# <%= render(Primer::Dropdown.new) do |c| %>
|
119
|
+
# <% c.button do %>
|
120
|
+
# Dropdown
|
121
|
+
# <% end %>
|
122
|
+
#
|
123
|
+
# <%= c.menu(header: "Options") do |menu|
|
124
|
+
# menu.item(tag: :button) { "Item 1" }
|
125
|
+
# menu.item(classes: "custom-class") { "Item 2" }
|
126
|
+
# menu.item { "Item 3" }
|
127
|
+
# end %>
|
128
|
+
# <% end %>
|
129
|
+
#
|
130
|
+
# @param overlay [Symbol] <%= one_of(Primer::DetailsComponent::OVERLAY_MAPPINGS.keys) %>
|
131
|
+
# @param with_caret [Boolean] Whether or not a caret should be rendered in the button.
|
132
|
+
# @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
|
133
|
+
def initialize(overlay: :default, with_caret: false, **system_arguments)
|
134
|
+
@with_caret = with_caret
|
135
|
+
|
136
|
+
@system_arguments = system_arguments
|
137
|
+
@system_arguments[:overlay] = overlay
|
138
|
+
@system_arguments[:reset] = true
|
139
|
+
@system_arguments[:classes] = class_names(
|
140
|
+
@system_arguments[:classes],
|
141
|
+
"dropdown"
|
142
|
+
)
|
143
|
+
end
|
144
|
+
|
145
|
+
def render?
|
146
|
+
button.present? && menu.present?
|
147
|
+
end
|
148
|
+
end
|
149
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
import './dropdown/menu'
|
@@ -0,0 +1 @@
|
|
1
|
+
import '@github/details-menu-element';
|
@@ -0,0 +1,25 @@
|
|
1
|
+
<%= render Primer::BaseComponent.new(**@system_arguments) do %>
|
2
|
+
<% if @header.present? %>
|
3
|
+
<div class="dropdown-header">
|
4
|
+
<%= @header %>
|
5
|
+
</div>
|
6
|
+
<% end %>
|
7
|
+
|
8
|
+
<% if list? %>
|
9
|
+
<ul>
|
10
|
+
<% items.each do |item| %>
|
11
|
+
<% if item.divider? %>
|
12
|
+
<%= item %>
|
13
|
+
<% else %>
|
14
|
+
<li>
|
15
|
+
<%= item %>
|
16
|
+
</li>
|
17
|
+
<% end %>
|
18
|
+
<% end %>
|
19
|
+
</ul>
|
20
|
+
<% else %>
|
21
|
+
<% items.each do |item| %>
|
22
|
+
<%= item %>
|
23
|
+
<% end %>
|
24
|
+
<% end %>
|
25
|
+
<% end %>
|
@@ -0,0 +1 @@
|
|
1
|
+
import '@github/details-menu-element';
|
@@ -0,0 +1,99 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Primer
|
4
|
+
class Dropdown
|
5
|
+
# This component is part of `Dropdown` and should not be
|
6
|
+
# used as a standalone component.
|
7
|
+
class Menu < Primer::Component
|
8
|
+
AS_DEFAULT = :default
|
9
|
+
AS_OPTIONS = [AS_DEFAULT, :list].freeze
|
10
|
+
|
11
|
+
SCHEME_DEFAULT = :default
|
12
|
+
SCHEME_MAPPINGS = {
|
13
|
+
SCHEME_DEFAULT => "",
|
14
|
+
:dark => "dropdown-menu-dark"
|
15
|
+
}.freeze
|
16
|
+
|
17
|
+
DIRECTION_DEFAULT = :se
|
18
|
+
DIRECTION_OPTIONS = [DIRECTION_DEFAULT, :sw, :w, :e, :ne, :s].freeze
|
19
|
+
|
20
|
+
# @param tag [Symbol] <%= one_of(Primer::Dropdown::Menu::Item::TAG_OPTIONS) %>.
|
21
|
+
# @param divider [Boolean] Whether the item is a divider without any function.
|
22
|
+
# @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
|
23
|
+
renders_many :items, lambda { |divider: false, **system_arguments|
|
24
|
+
Primer::Dropdown::Menu::Item.new(as: @as, divider: divider, **system_arguments)
|
25
|
+
}
|
26
|
+
|
27
|
+
# @param as [Symbol] When `as` is `:list`, wraps the menu in a `<ul>` with a `<li>` for each item.
|
28
|
+
# @param direction [Symbol] <%= one_of(Primer::Dropdown::Menu::DIRECTION_OPTIONS) %>.
|
29
|
+
# @param header [String] Header to be displayed above the menu.
|
30
|
+
# @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
|
31
|
+
def initialize(as: AS_DEFAULT, direction: DIRECTION_DEFAULT, scheme: SCHEME_DEFAULT, header: nil, **system_arguments)
|
32
|
+
@header = header
|
33
|
+
@direction = direction
|
34
|
+
@as = fetch_or_fallback(AS_OPTIONS, as, AS_DEFAULT)
|
35
|
+
|
36
|
+
@system_arguments = system_arguments
|
37
|
+
@system_arguments[:tag] = "details-menu"
|
38
|
+
@system_arguments[:role] = "menu"
|
39
|
+
|
40
|
+
@system_arguments[:classes] = class_names(
|
41
|
+
@system_arguments[:classes],
|
42
|
+
"dropdown-menu",
|
43
|
+
"dropdown-menu-#{fetch_or_fallback(DIRECTION_OPTIONS, direction, DIRECTION_DEFAULT)}",
|
44
|
+
SCHEME_MAPPINGS[fetch_or_fallback(SCHEME_MAPPINGS.keys, scheme, SCHEME_DEFAULT)]
|
45
|
+
)
|
46
|
+
end
|
47
|
+
|
48
|
+
private
|
49
|
+
|
50
|
+
def list?
|
51
|
+
@as == :list
|
52
|
+
end
|
53
|
+
|
54
|
+
# Items to be rendered in the `Dropdown` menu.
|
55
|
+
class Item < Primer::Component
|
56
|
+
TAG_DEFAULT = :a
|
57
|
+
BUTTON_TAGS = [:button, :summary].freeze
|
58
|
+
TAG_OPTIONS = [TAG_DEFAULT, *BUTTON_TAGS].freeze
|
59
|
+
|
60
|
+
def initialize(as:, tag: TAG_DEFAULT, divider: false, **system_arguments)
|
61
|
+
@divider = divider
|
62
|
+
@as = as
|
63
|
+
|
64
|
+
@system_arguments = system_arguments
|
65
|
+
@system_arguments[:tag] = fetch_or_fallback(TAG_OPTIONS, tag, TAG_DEFAULT)
|
66
|
+
@system_arguments[:tag] = :li if list? && divider?
|
67
|
+
@system_arguments[:role] ||= :menuitem
|
68
|
+
@system_arguments[:role] = :separator if divider
|
69
|
+
@system_arguments[:classes] = class_names(
|
70
|
+
@system_arguments[:classes],
|
71
|
+
"dropdown-item" => !divider,
|
72
|
+
"dropdown-divider" => divider
|
73
|
+
)
|
74
|
+
end
|
75
|
+
|
76
|
+
def call
|
77
|
+
component = if BUTTON_TAGS.include?(@system_arguments[:tag])
|
78
|
+
Primer::ButtonComponent.new(scheme: :link, **@system_arguments)
|
79
|
+
else
|
80
|
+
Primer::BaseComponent.new(**@system_arguments)
|
81
|
+
end
|
82
|
+
|
83
|
+
# divider has no content
|
84
|
+
render(component) if divider?
|
85
|
+
|
86
|
+
render(component) { content }
|
87
|
+
end
|
88
|
+
|
89
|
+
def divider?
|
90
|
+
@divider
|
91
|
+
end
|
92
|
+
|
93
|
+
def list?
|
94
|
+
@as == :list
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
import '@github/details-menu-element'
|
@@ -5,7 +5,7 @@ module Primer
|
|
5
5
|
#
|
6
6
|
# - Set tag to one of `:h1`, `:h2`, `:h3`, `:h4`, `:h5`, `:h6` based on what is appropriate for the page context.
|
7
7
|
# - Use `Heading` as the title of a section or sub section.
|
8
|
-
# - Do not use `Heading` for styling alone. For simply styling text, consider using <%= link_to_component(Primer::
|
8
|
+
# - Do not use `Heading` for styling alone. For simply styling text, consider using <%= link_to_component(Primer::Beta::Text) %> with relevant <%= link_to_typography_docs %>
|
9
9
|
# such as `font_size` and `font_weight`.
|
10
10
|
# - Do not jump heading levels. For instance, do not follow a `<h1>` with an `<h3>`. Heading levels should increase by one in ascending order.
|
11
11
|
#
|
@@ -31,7 +31,7 @@ module Primer
|
|
31
31
|
#
|
32
32
|
# <%= render(Primer::BorderBoxComponent.new) do |component| %>
|
33
33
|
# <% component.body do %>
|
34
|
-
# <%= render(Primer::
|
34
|
+
# <%= render(Primer::Beta::Text.new(pr: 2)) { "Body" } %>
|
35
35
|
# <%= render(Primer::IconButton.new(icon: :pencil, box: true, "aria-label": "Edit")) %>
|
36
36
|
# <% end %>
|
37
37
|
# <% end %>
|
@@ -6,7 +6,7 @@ module Primer
|
|
6
6
|
# A loading indicator that is shown while the image is loading.
|
7
7
|
# @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
|
8
8
|
renders_one :loading, lambda { |**system_arguments|
|
9
|
-
system_arguments[:tag]
|
9
|
+
system_arguments[:tag] = :div
|
10
10
|
system_arguments[:"data-loading-slot"] = true
|
11
11
|
|
12
12
|
Primer::BaseComponent.new(**system_arguments)
|
@@ -99,17 +99,17 @@ module Primer
|
|
99
99
|
# <p>And an unordered task list:</p>
|
100
100
|
#
|
101
101
|
# <ul>
|
102
|
-
# <li><input type="checkbox" checked
|
103
|
-
# <li><input type="checkbox"
|
104
|
-
# <li><input type="checkbox"
|
102
|
+
# <li><input type="checkbox" id="create-markdown" checked /><label for="create-markdown">Create a sample markdown document</label><br></li>
|
103
|
+
# <li><input type="checkbox" id="tasks-list" checked /><label for="tasks-list">Add tasks list to it</label><br></li>
|
104
|
+
# <li><input type="checkbox" id="take-vacation" checked /><label for="take-vacation">Take a vacation</label><br></li>
|
105
105
|
# </ul>
|
106
106
|
#
|
107
107
|
# <p>And a "mixed" task list:</p>
|
108
108
|
#
|
109
109
|
# <ul>
|
110
|
-
# <li><input type="checkbox"
|
110
|
+
# <li><input type="checkbox"id="steal-underpants"/><label for="steal-underpants">Steal underpants</label></li>
|
111
111
|
# <li>?</li>
|
112
|
-
# <li><input type="checkbox"
|
112
|
+
# <li><input type="checkbox"id="profit"/><label for="profit">Profit!</label></li>
|
113
113
|
# </ul>
|
114
114
|
#
|
115
115
|
# And a nested list:
|
@@ -241,9 +241,9 @@ module Primer
|
|
241
241
|
#
|
242
242
|
# <pre><code>var foo = "bar";</code></pre>
|
243
243
|
#
|
244
|
-
# <pre><code>Long, single-line code blocks should not wrap. They should horizontally scroll if they are too long. This line should be long enough to demonstrate this.</code></pre>
|
244
|
+
# <pre tabindex="0"><code>Long, single-line code blocks should not wrap. They should horizontally scroll if they are too long. This line should be long enough to demonstrate this.</code></pre>
|
245
245
|
#
|
246
|
-
# <pre><code>var foo = "The same thing is true for code with syntax highlighting. A single line of code should horizontally scroll if it is really long.";</code></pre>
|
246
|
+
# <pre tabindex="0"><code>var foo = "The same thing is true for code with syntax highlighting. A single line of code should horizontally scroll if it is really long.";</code></pre>
|
247
247
|
#
|
248
248
|
# <p>Inline code inside table cells should still be distinguishable.</p>
|
249
249
|
#
|
@@ -270,11 +270,11 @@ module Primer
|
|
270
270
|
#
|
271
271
|
# <p>Small images should be shown at their actual size.</p>
|
272
272
|
#
|
273
|
-
# <p><img src="http://placekitten.com/g/300/200/"/></p>
|
273
|
+
# <p><img alt="kitten" src="http://placekitten.com/g/300/200/"/></p>
|
274
274
|
#
|
275
275
|
# <p>Large images should always scale down and fit in the content container.</p>
|
276
276
|
#
|
277
|
-
# <p><img src="http://placekitten.com/g/1200/800/"/></p>
|
277
|
+
# <p><img alt="kitten" src="http://placekitten.com/g/1200/800/"/></p>
|
278
278
|
#
|
279
279
|
# <pre><code>This is the final element on the page and there should be no margin below this.</code></pre>
|
280
280
|
# <% end %>
|
@@ -3,11 +3,15 @@
|
|
3
3
|
module Primer
|
4
4
|
# Use `Menu` to create vertical lists of navigational links.
|
5
5
|
class MenuComponent < Primer::Component
|
6
|
+
HEADING_TAG_OPTIONS = [:h1, :h2, :h3, :h4, :h5, :h6].freeze
|
7
|
+
HEADING_TAG_FALLBACK = :h2
|
8
|
+
|
6
9
|
# Optional menu heading
|
7
10
|
#
|
11
|
+
# @param tag [Symbol] <%= one_of(Primer::MenuComponent::HEADING_TAG_OPTIONS) %>
|
8
12
|
# @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
|
9
|
-
renders_one :heading, lambda {
|
10
|
-
system_arguments[:tag]
|
13
|
+
renders_one :heading, lambda { |tag:, **system_arguments|
|
14
|
+
system_arguments[:tag] = fetch_or_fallback(HEADING_TAG_OPTIONS, tag, HEADING_TAG_FALLBACK)
|
11
15
|
system_arguments[:classes] = class_names(
|
12
16
|
"menu-heading",
|
13
17
|
system_arguments[:classes]
|
@@ -35,7 +39,7 @@ module Primer
|
|
35
39
|
|
36
40
|
# @example Default
|
37
41
|
# <%= render(Primer::MenuComponent.new) do |c| %>
|
38
|
-
# <% c.heading do %>
|
42
|
+
# <% c.heading(tag: :h2) do %>
|
39
43
|
# Heading
|
40
44
|
# <% end %>
|
41
45
|
# <% c.item(selected: true, href: "#url") do %>
|
@@ -18,7 +18,7 @@ module Primer
|
|
18
18
|
#
|
19
19
|
# @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
|
20
20
|
renders_one :panel, lambda { |**system_arguments|
|
21
|
-
system_arguments[:tag]
|
21
|
+
system_arguments[:tag] = :div
|
22
22
|
system_arguments[:role] ||= :tabpanel
|
23
23
|
system_arguments[:hidden] = true unless @selected
|
24
24
|
|
@@ -38,8 +38,8 @@ module Primer
|
|
38
38
|
|
39
39
|
# The Tab's text.
|
40
40
|
#
|
41
|
-
# @param kwargs [Hash] The same arguments as <%= link_to_component(Primer::
|
42
|
-
renders_one :text, Primer::
|
41
|
+
# @param kwargs [Hash] The same arguments as <%= link_to_component(Primer::Beta::Text) %>.
|
42
|
+
renders_one :text, Primer::Beta::Text
|
43
43
|
|
44
44
|
# Counter to be rendered in the Tab right.
|
45
45
|
#
|
@@ -96,12 +96,12 @@ module Primer
|
|
96
96
|
|
97
97
|
@system_arguments = system_arguments
|
98
98
|
|
99
|
-
if with_panel
|
100
|
-
@system_arguments[:tag]
|
99
|
+
if with_panel || @system_arguments[:tag] == :button
|
100
|
+
@system_arguments[:tag] = :button
|
101
101
|
@system_arguments[:type] = :button
|
102
102
|
@system_arguments[:role] = :tab
|
103
103
|
else
|
104
|
-
@system_arguments[:tag]
|
104
|
+
@system_arguments[:tag] = :a
|
105
105
|
end
|
106
106
|
|
107
107
|
@wrapper_arguments = wrapper_arguments
|