primer_view_components 0.0.46 → 0.0.50
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +144 -0
- data/app/components/primer/base_component.rb +2 -2
- 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 +0 -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/{avatar_stack_component.html.erb → beta/avatar_stack.html.erb} +0 -0
- data/app/components/primer/beta/avatar_stack.rb +92 -0
- data/app/components/primer/clipboard_copy.html.erb +2 -2
- data/app/components/primer/component.rb +5 -1
- data/app/components/primer/details_component.rb +7 -7
- data/app/components/primer/image_crop.html.erb +4 -4
- data/app/components/primer/label_component.rb +13 -12
- data/app/components/primer/markdown.rb +9 -9
- data/app/components/primer/navigation/tab_component.rb +30 -2
- data/app/components/primer/popover_component.rb +6 -3
- data/app/components/primer/primer.d.ts +1 -1
- data/app/components/primer/primer.js +1 -1
- data/app/components/primer/primer.ts +1 -1
- data/app/components/primer/tab_nav_component.rb +4 -3
- data/app/components/primer/timeline_item_component.rb +2 -2
- data/app/components/primer/truncate.rb +6 -1
- data/app/components/primer/underline_nav_component.rb +4 -3
- data/app/lib/primer/octicon/cache.rb +1 -1
- data/lib/primer/classify.rb +4 -18
- data/lib/primer/classify/cache.rb +0 -5
- data/lib/primer/classify/utilities.rb +54 -22
- data/lib/primer/classify/utilities.yml +16 -0
- data/lib/primer/view_components.rb +34 -6
- data/lib/primer/view_components/constants.rb +55 -0
- data/lib/primer/view_components/linters/argument_mappers/base.rb +74 -0
- data/lib/primer/view_components/linters/argument_mappers/button.rb +32 -44
- data/lib/primer/view_components/linters/argument_mappers/clipboard_copy.rb +20 -0
- data/lib/primer/view_components/linters/argument_mappers/helpers/erb_block.rb +24 -0
- data/lib/primer/view_components/linters/argument_mappers/label.rb +50 -0
- data/lib/primer/view_components/linters/argument_mappers/system_arguments.rb +4 -1
- data/lib/primer/view_components/linters/autocorrectable.rb +30 -0
- data/lib/primer/view_components/linters/button_component_migration_counter.rb +9 -23
- data/lib/primer/view_components/linters/clipboard_copy_component_migration_counter.rb +21 -0
- data/lib/primer/view_components/linters/close_button_component_migration_counter.rb +16 -0
- data/lib/primer/view_components/linters/helpers.rb +56 -38
- data/lib/primer/view_components/linters/label_component_migration_counter.rb +25 -0
- data/lib/primer/view_components/statuses.rb +14 -0
- data/lib/primer/view_components/version.rb +1 -1
- data/lib/rubocop/config/default.yml +12 -0
- data/lib/rubocop/cop/primer.rb +4 -0
- data/lib/rubocop/cop/primer/no_tag_memoize.rb +42 -0
- data/lib/rubocop/cop/primer/system_argument_instead_of_class.rb +75 -0
- data/lib/tasks/constants.rake +12 -0
- data/lib/tasks/docs.rake +87 -32
- data/lib/tasks/utilities.rake +4 -10
- data/lib/yard/docs_helper.rb +12 -3
- data/static/arguments.yml +973 -0
- data/static/assets/view-components.svg +18 -0
- data/static/classes.yml +174 -0
- data/static/constants.json +628 -0
- data/static/statuses.json +5 -5
- metadata +34 -13
- data/app/components/primer/auto_complete.rb +0 -157
- data/app/components/primer/auto_complete/item.rb +0 -42
- data/app/components/primer/avatar_component.rb +0 -75
- data/app/components/primer/avatar_stack_component.rb +0 -90
File without changes
|
@@ -0,0 +1,92 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Primer
|
4
|
+
module Beta
|
5
|
+
# Use `AvatarStack` to stack multiple avatars together.
|
6
|
+
class AvatarStack < Primer::Component
|
7
|
+
status :beta
|
8
|
+
|
9
|
+
ALIGN_DEFAULT = :left
|
10
|
+
ALIGN_OPTIONS = [ALIGN_DEFAULT, :right].freeze
|
11
|
+
|
12
|
+
DEFAULT_TAG = :div
|
13
|
+
TAG_OPTIONS = [DEFAULT_TAG, :span].freeze
|
14
|
+
|
15
|
+
DEFAULT_BODY_TAG = :div
|
16
|
+
BODY_TAG_OPTIONS = [DEFAULT_BODY_TAG, :span].freeze
|
17
|
+
# Required list of stacked avatars.
|
18
|
+
#
|
19
|
+
# @param kwargs [Hash] The same arguments as <%= link_to_component(Primer::Beta::Avatar) %>.
|
20
|
+
renders_many :avatars, "Primer::Beta::Avatar"
|
21
|
+
|
22
|
+
# @example Default
|
23
|
+
# <%= render(Primer::Beta::AvatarStack.new) do |c| %>
|
24
|
+
# <%= c.avatar(src: "http://placekitten.com/200/200", alt: "@kittenuser") %>
|
25
|
+
# <%= c.avatar(src: "http://placekitten.com/200/200", alt: "@kittenuser") %>
|
26
|
+
# <%= c.avatar(src: "http://placekitten.com/200/200", alt: "@kittenuser") %>
|
27
|
+
# <% end %>
|
28
|
+
#
|
29
|
+
# @example Align right
|
30
|
+
# <%= render(Primer::Beta::AvatarStack.new(align: :right)) do |c| %>
|
31
|
+
# <%= c.avatar(src: "http://placekitten.com/200/200", alt: "@kittenuser") %>
|
32
|
+
# <%= c.avatar(src: "http://placekitten.com/200/200", alt: "@kittenuser") %>
|
33
|
+
# <%= c.avatar(src: "http://placekitten.com/200/200", alt: "@kittenuser") %>
|
34
|
+
# <% end %>
|
35
|
+
#
|
36
|
+
# @example With tooltip
|
37
|
+
# <%= render(Primer::Beta::AvatarStack.new(tooltipped: true, body_arguments: { label: 'This is a tooltip!' })) do |c| %>
|
38
|
+
# <%= c.avatar(src: "http://placekitten.com/200/200", alt: "@kittenuser") %>
|
39
|
+
# <%= c.avatar(src: "http://placekitten.com/200/200", alt: "@kittenuser") %>
|
40
|
+
# <%= c.avatar(src: "http://placekitten.com/200/200", alt: "@kittenuser") %>
|
41
|
+
# <% end %>
|
42
|
+
#
|
43
|
+
# @param tag [Symbol] <%= one_of(Primer::Beta::AvatarStack::TAG_OPTIONS) %>
|
44
|
+
# @param align [Symbol] <%= one_of(Primer::Beta::AvatarStack::ALIGN_OPTIONS) %>
|
45
|
+
# @param tooltipped [Boolean] Whether to add a tooltip to the stack or not.
|
46
|
+
# @param body_arguments [Hash] Parameters to add to the Body. If `tooltipped` is set, has the same arguments as <%= link_to_component(Primer::Tooltip) %>.
|
47
|
+
# The default tag is <%= pretty_value(Primer::Beta::AvatarStack::DEFAULT_BODY_TAG) %> but can be changed using `tag:`
|
48
|
+
# to <%= one_of(Primer::Beta::AvatarStack::BODY_TAG_OPTIONS, lower: true) %>
|
49
|
+
# @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
|
50
|
+
def initialize(tag: DEFAULT_TAG, align: ALIGN_DEFAULT, tooltipped: false, body_arguments: {}, **system_arguments)
|
51
|
+
@align = fetch_or_fallback(ALIGN_OPTIONS, align, ALIGN_DEFAULT)
|
52
|
+
@system_arguments = system_arguments
|
53
|
+
@tooltipped = tooltipped
|
54
|
+
@body_arguments = body_arguments
|
55
|
+
|
56
|
+
body_tag = @body_arguments[:tag] || DEFAULT_BODY_TAG
|
57
|
+
@body_arguments[:tag] = fetch_or_fallback(BODY_TAG_OPTIONS, body_tag, DEFAULT_BODY_TAG)
|
58
|
+
@body_arguments[:classes] = class_names(
|
59
|
+
"AvatarStack-body",
|
60
|
+
@body_arguments[:classes]
|
61
|
+
)
|
62
|
+
|
63
|
+
@system_arguments[:tag] = fetch_or_fallback(TAG_OPTIONS, tag, DEFAULT_TAG)
|
64
|
+
@system_arguments[:classes] = class_names(
|
65
|
+
"AvatarStack",
|
66
|
+
system_arguments[:classes],
|
67
|
+
"AvatarStack--right" => @align == :right
|
68
|
+
)
|
69
|
+
end
|
70
|
+
|
71
|
+
def body_component
|
72
|
+
if @tooltipped
|
73
|
+
Primer::Tooltip.new(**@body_arguments)
|
74
|
+
else
|
75
|
+
Primer::BaseComponent.new(**@body_arguments)
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
def before_render
|
80
|
+
@system_arguments[:classes] = class_names(
|
81
|
+
@system_arguments[:classes],
|
82
|
+
"AvatarStack--two" => avatars.size == 2,
|
83
|
+
"AvatarStack--three-plus" => avatars.size > 2
|
84
|
+
)
|
85
|
+
end
|
86
|
+
|
87
|
+
def render?
|
88
|
+
avatars.any?
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
@@ -2,7 +2,7 @@
|
|
2
2
|
<% if content.present? %>
|
3
3
|
<%= content %>
|
4
4
|
<% else %>
|
5
|
-
<%= render Primer::OcticonComponent.new(
|
6
|
-
<%= render Primer::OcticonComponent.new(
|
5
|
+
<%= render Primer::OcticonComponent.new(:paste) %>
|
6
|
+
<%= render Primer::OcticonComponent.new(:check, color: :icon_success, style: "display: none;") %>
|
7
7
|
<% end %>
|
8
8
|
<% end %>
|
@@ -29,8 +29,12 @@ module Primer
|
|
29
29
|
ActiveSupport::Deprecation.warn(message)
|
30
30
|
end
|
31
31
|
|
32
|
+
def aria(val, system_arguments)
|
33
|
+
system_arguments[:"aria-#{val}"] || system_arguments.dig(:aria, val.to_sym)
|
34
|
+
end
|
35
|
+
|
32
36
|
def validate_aria_label
|
33
|
-
aria_label =
|
37
|
+
aria_label = aria("label", @system_arguments)
|
34
38
|
raise ArgumentError, "`aria-label` is required." if aria_label.nil? && !Rails.env.production?
|
35
39
|
end
|
36
40
|
|
@@ -29,7 +29,7 @@ module Primer
|
|
29
29
|
|
30
30
|
# Use the Body slot as the main content to be shown when triggered by the Summary.
|
31
31
|
#
|
32
|
-
# @param tag [
|
32
|
+
# @param tag [Symbol] (Primer::DetailsComponent::BODY_TAG_DEFAULT) <%= one_of(Primer::DetailsComponent::BODY_TAG_OPTIONS) %>
|
33
33
|
# @param kwargs [Hash] The same arguments as <%= link_to_system_arguments_docs %>.
|
34
34
|
renders_one :body, lambda { |tag: BODY_TAG_DEFAULT, **system_arguments|
|
35
35
|
system_arguments[:tag] = fetch_or_fallback(BODY_TAG_OPTIONS, tag, BODY_TAG_DEFAULT)
|
@@ -40,12 +40,12 @@ module Primer
|
|
40
40
|
# @example Default
|
41
41
|
#
|
42
42
|
# <%= render Primer::DetailsComponent.new do |c| %>
|
43
|
-
#
|
44
|
-
#
|
45
|
-
# end
|
46
|
-
#
|
47
|
-
#
|
48
|
-
# end
|
43
|
+
# <% c.summary do %>
|
44
|
+
# Summary
|
45
|
+
# <% end %>
|
46
|
+
# <% c.body do %>
|
47
|
+
# Body
|
48
|
+
# <% end %>
|
49
49
|
# <% end %>
|
50
50
|
#
|
51
51
|
# @param overlay [Symbol] Dictates the type of overlay to render with. <%= one_of(Primer::DetailsComponent::OVERLAY_MAPPINGS.keys) %>
|
@@ -5,8 +5,8 @@
|
|
5
5
|
<%= render(Primer::SpinnerComponent.new(size: :large, flex: 1, "data-loading-slot": true)) %>
|
6
6
|
<% end %>
|
7
7
|
|
8
|
-
<input type="hidden" data-image-crop-input="x" name="cropped_x">
|
9
|
-
<input type="hidden" data-image-crop-input="y" name="cropped_y">
|
10
|
-
<input type="hidden" data-image-crop-input="width" name="cropped_width">
|
11
|
-
<input type="hidden" data-image-crop-input="height" name="cropped_height">
|
8
|
+
<input autocomplete="off" type="hidden" data-image-crop-input="x" name="cropped_x">
|
9
|
+
<input autocomplete="off" type="hidden" data-image-crop-input="y" name="cropped_y">
|
10
|
+
<input autocomplete="off" type="hidden" data-image-crop-input="width" name="cropped_width">
|
11
|
+
<input autocomplete="off" type="hidden" data-image-crop-input="height" name="cropped_height">
|
12
12
|
<% end %>
|
@@ -2,6 +2,9 @@
|
|
2
2
|
|
3
3
|
module Primer
|
4
4
|
# Use `Label` to add contextual metadata to a design.
|
5
|
+
#
|
6
|
+
# @accessibility
|
7
|
+
# Use `aria-label` if the `Label` or the context around it don't explain the label.
|
5
8
|
class LabelComponent < Primer::Component
|
6
9
|
status :beta
|
7
10
|
|
@@ -29,27 +32,25 @@ module Primer
|
|
29
32
|
VARIANT_OPTIONS = VARIANT_MAPPINGS.keys << nil
|
30
33
|
|
31
34
|
# @example Schemes
|
32
|
-
# <%= render(Primer::LabelComponent.new
|
33
|
-
# <%= render(Primer::LabelComponent.new(
|
34
|
-
# <%= render(Primer::LabelComponent.new(
|
35
|
-
# <%= render(Primer::LabelComponent.new(
|
36
|
-
# <%= render(Primer::LabelComponent.new(
|
37
|
-
# <%= render(Primer::LabelComponent.new(
|
38
|
-
# <%= render(Primer::LabelComponent.new(
|
35
|
+
# <%= render(Primer::LabelComponent.new) { "Default" } %>
|
36
|
+
# <%= render(Primer::LabelComponent.new( scheme: :primary)) { "Primary" } %>
|
37
|
+
# <%= render(Primer::LabelComponent.new( scheme: :secondary)) { "Secondary" } %>
|
38
|
+
# <%= render(Primer::LabelComponent.new( scheme: :info)) { "Info" } %>
|
39
|
+
# <%= render(Primer::LabelComponent.new( scheme: :success)) { "Success" } %>
|
40
|
+
# <%= render(Primer::LabelComponent.new( scheme: :warning)) { "Warning" } %>
|
41
|
+
# <%= render(Primer::LabelComponent.new( scheme: :danger)) { "Danger" } %>
|
39
42
|
#
|
40
43
|
# @example Variants
|
41
|
-
# <%= render(Primer::LabelComponent.new
|
42
|
-
# <%= render(Primer::LabelComponent.new(
|
44
|
+
# <%= render(Primer::LabelComponent.new) { "Default" } %>
|
45
|
+
# <%= render(Primer::LabelComponent.new( variant: :large)) { "Large" } %>
|
43
46
|
#
|
44
47
|
# @param tag [Symbol] <%= one_of(Primer::LabelComponent::TAG_OPTIONS) %>
|
45
|
-
# @param title [String] `title` attribute for the component element.
|
46
48
|
# @param scheme [Symbol] <%= one_of(Primer::LabelComponent::SCHEME_MAPPINGS.keys) %>
|
47
49
|
# @param variant [Symbol] <%= one_of(Primer::LabelComponent::VARIANT_OPTIONS) %>
|
48
50
|
# @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
|
49
|
-
def initialize(tag: DEFAULT_TAG,
|
51
|
+
def initialize(tag: DEFAULT_TAG, scheme: nil, variant: nil, **system_arguments)
|
50
52
|
@system_arguments = system_arguments
|
51
53
|
@system_arguments[:tag] = fetch_or_fallback(TAG_OPTIONS, tag, DEFAULT_TAG)
|
52
|
-
@system_arguments[:title] = title
|
53
54
|
@system_arguments[:classes] = class_names(
|
54
55
|
"Label",
|
55
56
|
system_arguments[:classes],
|
@@ -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 %>
|
@@ -18,10 +18,23 @@ module Primer
|
|
18
18
|
#
|
19
19
|
# @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
|
20
20
|
renders_one :panel, lambda { |**system_arguments|
|
21
|
+
return unless @with_panel
|
22
|
+
|
23
|
+
system_arguments[:id] = @panel_id
|
21
24
|
system_arguments[:tag] = :div
|
22
25
|
system_arguments[:role] ||= :tabpanel
|
26
|
+
system_arguments[:tabindex] = 0
|
23
27
|
system_arguments[:hidden] = true unless @selected
|
24
28
|
|
29
|
+
label_present = aria("label", system_arguments) || aria("labelledby", system_arguments)
|
30
|
+
unless label_present
|
31
|
+
if @id.present?
|
32
|
+
system_arguments[:"aria-labelledby"] = @id
|
33
|
+
elsif !Rails.env.production?
|
34
|
+
raise ArgumentError, "Panels must be labelled. Either set a unique `id` on the tab, or set an `aria-label` directly on the panel"
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
25
38
|
Primer::BaseComponent.new(**system_arguments)
|
26
39
|
}
|
27
40
|
|
@@ -86,20 +99,24 @@ module Primer
|
|
86
99
|
# @param list [Boolean] Whether the Tab is an item in a `<ul>` list.
|
87
100
|
# @param selected [Boolean] Whether the Tab is selected or not.
|
88
101
|
# @param with_panel [Boolean] Whether the Tab has an associated panel.
|
102
|
+
# @param panel_id [String] Only applies if `with_panel` is `true`. Unique id of panel.
|
89
103
|
# @param icon_classes [Boolean] Classes that must always be applied to icons.
|
90
104
|
# @param wrapper_arguments [Hash] <%= link_to_system_arguments_docs %> to be used in the `<li>` wrapper when the tab is an item in a list.
|
91
105
|
# @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
|
92
|
-
def initialize(list: false, selected: false, with_panel: false, icon_classes: "", wrapper_arguments: {}, **system_arguments)
|
106
|
+
def initialize(list: false, selected: false, with_panel: false, panel_id: "", icon_classes: "", wrapper_arguments: {}, **system_arguments)
|
93
107
|
@selected = selected
|
94
108
|
@icon_classes = icon_classes
|
95
109
|
@list = list
|
110
|
+
@with_panel = with_panel
|
96
111
|
|
97
112
|
@system_arguments = system_arguments
|
113
|
+
@id = @system_arguments[:id]
|
98
114
|
|
99
115
|
if with_panel || @system_arguments[:tag] == :button
|
100
116
|
@system_arguments[:tag] = :button
|
101
117
|
@system_arguments[:type] = :button
|
102
118
|
@system_arguments[:role] = :tab
|
119
|
+
panel_id(panel_id)
|
103
120
|
else
|
104
121
|
@system_arguments[:tag] = :a
|
105
122
|
end
|
@@ -111,7 +128,7 @@ module Primer
|
|
111
128
|
return unless @selected
|
112
129
|
|
113
130
|
if @system_arguments[:tag] == :a
|
114
|
-
aria_current =
|
131
|
+
aria_current = aria("current", system_arguments) || DEFAULT_ARIA_CURRENT_FOR_ANCHOR
|
115
132
|
@system_arguments[:"aria-current"] = fetch_or_fallback(ARIA_CURRENT_OPTIONS_FOR_ANCHOR, aria_current, DEFAULT_ARIA_CURRENT_FOR_ANCHOR)
|
116
133
|
else
|
117
134
|
@system_arguments[:"aria-selected"] = true
|
@@ -128,6 +145,17 @@ module Primer
|
|
128
145
|
yield
|
129
146
|
end
|
130
147
|
end
|
148
|
+
|
149
|
+
private
|
150
|
+
|
151
|
+
def panel_id(panel_id)
|
152
|
+
if panel_id.blank?
|
153
|
+
raise ArgumentError, "`panel_id` is required" unless Rails.env.production?
|
154
|
+
else
|
155
|
+
@panel_id = panel_id
|
156
|
+
@system_arguments[:"aria-controls"] = @panel_id
|
157
|
+
end
|
158
|
+
end
|
131
159
|
end
|
132
160
|
end
|
133
161
|
end
|
@@ -23,12 +23,15 @@ module Primer
|
|
23
23
|
:top_right => "Popover-message--top-right"
|
24
24
|
}.freeze
|
25
25
|
|
26
|
+
DEFAULT_HEADING_TAG = :h4
|
27
|
+
|
26
28
|
# The heading
|
27
29
|
#
|
30
|
+
# @param tag [Symbol] (Primer::PopoverComponent::DEFAULT_HEADING_TAG) <%= one_of(Primer::HeadingComponent::TAG_OPTIONS) %>
|
28
31
|
# @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
|
29
|
-
renders_one :heading, lambda {
|
32
|
+
renders_one :heading, lambda { |tag: DEFAULT_HEADING_TAG, **system_arguments|
|
33
|
+
system_arguments[:tag] = tag
|
30
34
|
system_arguments[:mb] ||= 2
|
31
|
-
system_arguments[:tag] ||= :h4 # rubocop:disable Primer/NoTagMemoize
|
32
35
|
|
33
36
|
Primer::HeadingComponent.new(**system_arguments)
|
34
37
|
}
|
@@ -106,7 +109,7 @@ module Primer
|
|
106
109
|
# @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
|
107
110
|
def initialize(**system_arguments)
|
108
111
|
@system_arguments = system_arguments
|
109
|
-
@system_arguments[:tag]
|
112
|
+
@system_arguments[:tag] = :div
|
110
113
|
@system_arguments[:classes] = class_names(
|
111
114
|
system_arguments[:classes],
|
112
115
|
"Popover"
|
@@ -13,6 +13,7 @@ module Primer
|
|
13
13
|
# Tabs to be rendered. When `with_panel` is set on the parent, a button is rendered for panel navigation. Otherwise,
|
14
14
|
# an anchor tag is rendered for page navigation. For more information, refer to <%= link_to_component(Primer::Navigation::TabComponent) %>.
|
15
15
|
#
|
16
|
+
# @param panel_id [String] Only applies if `with_panel` is `true`. Unique ID of panel.
|
16
17
|
# @param selected [Boolean] Whether the tab is selected.
|
17
18
|
# @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
|
18
19
|
renders_many :tabs, lambda { |selected: false, **system_arguments|
|
@@ -63,19 +64,19 @@ module Primer
|
|
63
64
|
#
|
64
65
|
# @example With panels
|
65
66
|
# <%= render(Primer::TabNavComponent.new(label: "With panels", with_panel: true)) do |c| %>
|
66
|
-
# <% c.tab(selected: true) do |t| %>
|
67
|
+
# <% c.tab(selected: true, panel_id: "panel-1", id: "tab-1") do |t| %>
|
67
68
|
# <% t.text { "Tab 1" } %>
|
68
69
|
# <% t.panel do %>
|
69
70
|
# Panel 1
|
70
71
|
# <% end %>
|
71
72
|
# <% end %>
|
72
|
-
# <% c.tab do |t| %>
|
73
|
+
# <% c.tab(id: "tab-2", panel_id: "panel-2") do |t| %>
|
73
74
|
# <% t.text { "Tab 2" } %>
|
74
75
|
# <% t.panel do %>
|
75
76
|
# Panel 2
|
76
77
|
# <% end %>
|
77
78
|
# <% end %>
|
78
|
-
# <% c.tab do |t| %>
|
79
|
+
# <% c.tab(id: "tab-3", panel_id: "panel-3") do |t| %>
|
79
80
|
# <% t.text { "Tab 3" } %>
|
80
81
|
# <% t.panel do %>
|
81
82
|
# Panel 3
|
@@ -7,14 +7,14 @@ module Primer
|
|
7
7
|
|
8
8
|
# Avatar to be rendered to the left of the Badge.
|
9
9
|
#
|
10
|
-
# @param kwargs [Hash] The same arguments as <%= link_to_component(Primer::
|
10
|
+
# @param kwargs [Hash] The same arguments as <%= link_to_component(Primer::Beta::Avatar) %>.
|
11
11
|
renders_one :avatar, lambda { |src:, size: 40, square: true, **system_arguments|
|
12
12
|
system_arguments[:classes] = class_names(
|
13
13
|
"TimelineItem-avatar",
|
14
14
|
system_arguments[:classes]
|
15
15
|
)
|
16
16
|
|
17
|
-
Primer::
|
17
|
+
Primer::Beta::Avatar.new(src: src, size: size, square: square, **system_arguments)
|
18
18
|
}
|
19
19
|
|
20
20
|
# Badge that will be connected to other TimelineItems.
|
@@ -6,7 +6,7 @@ module Primer
|
|
6
6
|
status :beta
|
7
7
|
|
8
8
|
DEFAULT_TAG = :div
|
9
|
-
TAG_OPTIONS = [DEFAULT_TAG, :span, :p].freeze
|
9
|
+
TAG_OPTIONS = [DEFAULT_TAG, :span, :p, :strong].freeze
|
10
10
|
|
11
11
|
# @example Default
|
12
12
|
# <div class="col-2">
|
@@ -22,6 +22,11 @@ module Primer
|
|
22
22
|
# @example Custom size
|
23
23
|
# <%= render(Primer::Truncate.new(tag: :span, inline: true, expandable: true, max_width: 100)) { "branch-name-that-is-really-long" } %>
|
24
24
|
#
|
25
|
+
# @example With HTML content
|
26
|
+
# <%= render(Primer::Truncate.new(tag: :span, inline: true, expandable: true, max_width: 100)) do %>
|
27
|
+
# <span>branch-name-that-is-really-long</span>
|
28
|
+
# <% end %>
|
29
|
+
#
|
25
30
|
# @param tag [Symbol] <%= one_of(Primer::Truncate::TAG_OPTIONS) %>
|
26
31
|
# @param inline [Boolean] Whether the element is inline (or inline-block).
|
27
32
|
# @param expandable [Boolean] Whether the entire string should be revealed on hover. Can only be used in conjunction with `inline`.
|