primer_view_components 0.0.65 → 0.0.68
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +58 -0
- data/README.md +1 -1
- data/app/components/primer/beta/auto_complete/auto_complete.html.erb +11 -3
- data/app/components/primer/beta/auto_complete.rb +20 -95
- data/app/components/primer/beta/blankslate.html.erb +6 -2
- data/app/components/primer/beta/blankslate.rb +8 -11
- data/app/components/primer/content.rb +12 -0
- data/app/components/primer/dropdown.rb +2 -2
- data/app/components/primer/popover_component.rb +15 -20
- data/app/components/primer/tooltip.rb +1 -1
- data/app/lib/primer/test_selector_helper.rb +1 -1
- data/lib/primer/classify/utilities.rb +37 -8
- data/lib/primer/view_components/version.rb +1 -1
- data/lib/rubocop/cop/primer/component_name_migration.rb +35 -0
- data/lib/tasks/docs.rake +12 -6
- data/lib/tasks/utilities.rake +2 -15
- data/static/arguments.yml +9 -0
- data/static/audited_at.json +1 -1
- data/static/classes.yml +4 -4
- data/static/constants.json +2 -8
- data/static/statuses.json +2 -2
- metadata +7 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 537c5d2b6d37e3cfc2493426db201a7ea7268a00b3e5b06536d49956ad25658f
|
4
|
+
data.tar.gz: a8aa51d217947855498867c2e18e0ad8d34ee5c9dd565170544e3deeec63a25f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e5965f3012b7407029185f7698020c0207d9541dcc8fe78e93fabf207de062eba38358f00c3c270189ee2811ace542f97941e2b6e4f96d77f05c33da23af9098
|
7
|
+
data.tar.gz: 63b806a174ea5f35c89d2e5568781c010e307680b8bee36bb4de835b77cea5cc82c816bbfdd03d2b0ec283f47b23c8c351c9ef552a691dcd42097964bc88fa88
|
data/CHANGELOG.md
CHANGED
@@ -30,6 +30,64 @@ The category for changes related to documentation, testing and tooling. Also, fo
|
|
30
30
|
|
31
31
|
## main
|
32
32
|
|
33
|
+
## 0.0.68
|
34
|
+
|
35
|
+
### Updates
|
36
|
+
|
37
|
+
- Add accessible labels to Search AutoComplete when provided with an icon.
|
38
|
+
|
39
|
+
_Andri Alexandrou_
|
40
|
+
|
41
|
+
- Restricts children for AutoComplete API to prevent accessibility violations and misuse
|
42
|
+
|
43
|
+
_Lindsey Wild_
|
44
|
+
|
45
|
+
- Migrate from Heroku to Azure for the Rails storybook server.
|
46
|
+
|
47
|
+
_Cameron Dutro_
|
48
|
+
|
49
|
+
- Remove CSS utilities from Blankslate
|
50
|
+
|
51
|
+
_Hector Garcia_
|
52
|
+
|
53
|
+
- Improve last example on the PopoverComponent docs
|
54
|
+
|
55
|
+
_Hector Garcia_
|
56
|
+
|
57
|
+
### Bug Fixes
|
58
|
+
|
59
|
+
- Fix live reloading during local docs development.
|
60
|
+
|
61
|
+
_Cameron Dutro_
|
62
|
+
|
63
|
+
### Deprecations
|
64
|
+
|
65
|
+
- Deprecate `Tooltip` component.
|
66
|
+
|
67
|
+
_Kate Higa_
|
68
|
+
|
69
|
+
### Misc
|
70
|
+
|
71
|
+
- Updates README with missing `alt` attribute on image
|
72
|
+
|
73
|
+
_Kate Higa_
|
74
|
+
|
75
|
+
- Updates contributing docs
|
76
|
+
|
77
|
+
_Lindsey Wild_
|
78
|
+
|
79
|
+
## 0.0.67
|
80
|
+
|
81
|
+
- Updating octicons to `> 16`
|
82
|
+
|
83
|
+
_Jon Rohan_
|
84
|
+
|
85
|
+
## 0.0.66
|
86
|
+
|
87
|
+
- Revert optimization changes to utilities.
|
88
|
+
|
89
|
+
_Josh Klina_
|
90
|
+
|
33
91
|
## 0.0.65
|
34
92
|
|
35
93
|
### Breaking Changes
|
data/README.md
CHANGED
@@ -1,6 +1,14 @@
|
|
1
|
-
<%= label %>
|
2
1
|
<%= render Primer::BaseComponent.new(**@system_arguments) do %>
|
3
|
-
<%=
|
4
|
-
|
2
|
+
<label for="<%= @input_id %>">
|
3
|
+
<% if @is_label_visible %>
|
4
|
+
<%= @label_text %>
|
5
|
+
<% else %>
|
6
|
+
<span class="sr-only"><%= @label_text %></span>
|
7
|
+
<% end %>
|
8
|
+
<% if icon.present? %>
|
9
|
+
<%= icon %>
|
10
|
+
<% end %>
|
11
|
+
</label>
|
12
|
+
<input id="<%= @input_id %>" name="<%= @input_id %>" type="text" class="form-control" autocomplete="off">
|
5
13
|
<%= results %>
|
6
14
|
<% end %>
|
@@ -7,41 +7,14 @@ module Primer
|
|
7
7
|
# @accessibility
|
8
8
|
# Always set an accessible label to help the user interact with the component.
|
9
9
|
#
|
10
|
-
# *
|
11
|
-
#
|
12
|
-
#
|
13
|
-
#
|
14
|
-
# always be used unless there is compelling reason not to. A placeholder is not a label.
|
10
|
+
# * `label_text` is required and visible by default.
|
11
|
+
# * If you must use a non-visible label, set `is_label_visible` to `false`.
|
12
|
+
# However, please note that a visible label should almost always
|
13
|
+
# be used unless there is compelling reason not to. A placeholder is not a label.
|
15
14
|
class AutoComplete < Primer::Component
|
16
15
|
status :beta
|
17
16
|
|
18
|
-
# Optionally render a visible label. See <%= link_to_accessibility %>
|
19
|
-
#
|
20
|
-
# @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
|
21
|
-
renders_one :label, lambda { |**system_arguments|
|
22
|
-
deny_tag_argument(**system_arguments)
|
23
|
-
system_arguments[:for] = @input_id
|
24
|
-
system_arguments[:tag] = :label
|
25
|
-
Primer::BaseComponent.new(**system_arguments)
|
26
|
-
}
|
27
|
-
|
28
|
-
# Required input used to search for results
|
29
|
-
#
|
30
|
-
# @param type [Symbol] <%= one_of(Primer::Beta::AutoComplete::Input::TYPE_OPTIONS) %>
|
31
|
-
# @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
|
32
|
-
renders_one :input, lambda { |**system_arguments|
|
33
|
-
aria_label = aria("label", system_arguments) || @aria_label
|
34
|
-
if aria_label.present?
|
35
|
-
system_arguments[:"aria-label"] = aria_label
|
36
|
-
system_arguments[:aria]&.delete(:label)
|
37
|
-
end
|
38
|
-
|
39
|
-
name = system_arguments[:name] || @input_id
|
40
|
-
Input.new(id: @input_id, name: name, **system_arguments)
|
41
|
-
}
|
42
|
-
|
43
17
|
# Optional icon to be rendered before the input. Has the same arguments as <%= link_to_component(Primer::OcticonComponent) %>.
|
44
|
-
#
|
45
18
|
renders_one :icon, Primer::OcticonComponent
|
46
19
|
|
47
20
|
# Customizable results list.
|
@@ -56,34 +29,17 @@ module Primer
|
|
56
29
|
system_arguments[:classes]
|
57
30
|
)
|
58
31
|
|
59
|
-
aria_label = system_arguments[:"aria-label"] || system_arguments.dig(:aria, :label) || @aria_label
|
60
|
-
system_arguments[:"aria-label"] = aria_label if aria_label.present?
|
61
|
-
system_arguments[:aria]&.delete(:label)
|
62
|
-
|
63
32
|
Primer::BaseComponent.new(**system_arguments)
|
64
33
|
}
|
65
34
|
|
66
35
|
# @example Default
|
67
|
-
# <%= render(Primer::Beta::AutoComplete.new(src: "/auto_complete", input_id: "fruits-input-1", list_id: "fruits-popup-1", position: :relative))
|
68
|
-
# <% c.label(classes:"").with_content("Fruits") %>
|
69
|
-
# <% c.input(type: :text) %>
|
70
|
-
# <% end %>
|
36
|
+
# <%= render(Primer::Beta::AutoComplete.new(label_text: "Fruits", src: "/auto_complete", input_id: "fruits-input-1", list_id: "fruits-popup-1", position: :relative)) %>
|
71
37
|
#
|
72
|
-
# @example With
|
73
|
-
# <%= render(Primer::Beta::AutoComplete.new(
|
74
|
-
# <% c.input(type: :text) %>
|
75
|
-
# <% end %>
|
76
|
-
#
|
77
|
-
# @example With `aria-labelledby`
|
78
|
-
# <%= render(Primer::HeadingComponent.new(tag: :h2, id: "search-1")) { "Search" } %>
|
79
|
-
# <%= render(Primer::Beta::AutoComplete.new(src: "/auto_complete", input_id: "fruits-input-3", list_id: "fruits-popup-2", position: :relative)) do |c| %>
|
80
|
-
# <% c.input("aria-labelledby": "search-1") %>
|
81
|
-
# <% end %>
|
38
|
+
# @example With Non-Visible Label
|
39
|
+
# <%= render(Primer::Beta::AutoComplete.new(label_text: "Fruits", src: "/auto_complete", input_id: "fruits-input-2", list_id: "fruits-popup-2", is_label_visible: false, position: :relative)) %>
|
82
40
|
#
|
83
|
-
# @example With
|
84
|
-
# <%= render(Primer::Beta::AutoComplete.new(src: "/auto_complete", input_id: "fruits-input-
|
85
|
-
# <% c.label(classes:"").with_content("Fruits") %>
|
86
|
-
# <% c.input(type: :text) %>
|
41
|
+
# @example With Custom Classes for the Results
|
42
|
+
# <%= render(Primer::Beta::AutoComplete.new(label_text: "Fruits", src: "/auto_complete", input_id: "fruits-input-3", list_id: "fruits-popup-3", position: :relative)) do |c| %>
|
87
43
|
# <% c.results(classes: "custom-class") do %>
|
88
44
|
# <%= render(Primer::Beta::AutoComplete::Item.new(selected: true, value: "apple")) do |c| %>
|
89
45
|
# Apple
|
@@ -95,22 +51,25 @@ module Primer
|
|
95
51
|
# <% end %>
|
96
52
|
#
|
97
53
|
# @example With Icon
|
98
|
-
# <%= render(Primer::Beta::AutoComplete.new(src: "/auto_complete", list_id: "fruits-popup-4", input_id: "fruits-input-4", position: :relative)) do |c| %>
|
99
|
-
# <% c.label(classes:"").with_content("Fruits") %>
|
100
|
-
# <% c.input(type: :text) %>
|
54
|
+
# <%= render(Primer::Beta::AutoComplete.new(label_text: "Fruits", src: "/auto_complete", list_id: "fruits-popup-4", input_id: "fruits-input-4", position: :relative)) do |c| %>
|
101
55
|
# <% c.icon(icon: :search) %>
|
102
56
|
# <% end %>
|
103
57
|
#
|
58
|
+
# @example With Icon and Non-Visible Label
|
59
|
+
# <%= render(Primer::Beta::AutoComplete.new(label_text: "Fruits", src: "/auto_complete", list_id: "fruits-popup-5", input_id: "fruits-input-5", is_label_visible: false, position: :relative)) do |c| %>
|
60
|
+
# <% c.icon(icon: :search) %>
|
61
|
+
# <% end %>
|
62
|
+
# @param label_text [String] The label of the input.
|
104
63
|
# @param src [String] The route to query.
|
105
64
|
# @param input_id [String] Id of the input element.
|
106
65
|
# @param list_id [String] Id of the list element.
|
66
|
+
# @param is_label_visible [Boolean] Controls if the label is visible. If `false`, screen reader only text will be added.
|
107
67
|
# @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
|
108
|
-
def initialize(src:, list_id:, input_id:, **system_arguments)
|
68
|
+
def initialize(label_text:, src:, list_id:, input_id:, is_label_visible: true, **system_arguments)
|
69
|
+
@label_text = label_text
|
109
70
|
@list_id = list_id
|
110
71
|
@input_id = input_id
|
111
|
-
@
|
112
|
-
|
113
|
-
system_arguments.delete(:"aria-label") && system_arguments[:aria]&.delete(:label)
|
72
|
+
@is_label_visible = is_label_visible
|
114
73
|
|
115
74
|
@system_arguments = deny_tag_argument(**system_arguments)
|
116
75
|
@system_arguments[:tag] = "auto-complete"
|
@@ -118,44 +77,10 @@ module Primer
|
|
118
77
|
@system_arguments[:for] = list_id
|
119
78
|
end
|
120
79
|
|
121
|
-
# add `results` without needing to explicitly call
|
80
|
+
# add `results` without needing to explicitly call them in the view
|
122
81
|
def before_render
|
123
|
-
raise ArgumentError, "Missing `input` slot" if input.blank?
|
124
|
-
raise ArgumentError, "Accessible label is required." if label.blank? && input.missing_label?
|
125
|
-
|
126
82
|
results(classes: "") unless results
|
127
83
|
end
|
128
|
-
|
129
|
-
# This component is part of `Primer::Beta::AutoCompleteComponent` and should not be
|
130
|
-
# used as a standalone component.
|
131
|
-
class Input < Primer::Component
|
132
|
-
DEFAULT_TYPE = :text
|
133
|
-
TYPE_OPTIONS = [DEFAULT_TYPE, :search].freeze
|
134
|
-
|
135
|
-
# @param type [Symbol] <%= one_of(Primer::Beta::AutoComplete::Input::TYPE_OPTIONS) %>
|
136
|
-
# @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
|
137
|
-
def initialize(type: DEFAULT_TYPE, **system_arguments)
|
138
|
-
@system_arguments = deny_tag_argument(**system_arguments)
|
139
|
-
@system_arguments[:tag] = :input
|
140
|
-
|
141
|
-
@aria_label = system_arguments[:"aria-label"]
|
142
|
-
@aria_labelledby = system_arguments[:"aria-labelledby"] || system_arguments.dig(:aria, :labelledby)
|
143
|
-
|
144
|
-
@system_arguments[:type] = fetch_or_fallback(TYPE_OPTIONS, type, DEFAULT_TYPE)
|
145
|
-
@system_arguments[:classes] = class_names(
|
146
|
-
"form-control",
|
147
|
-
system_arguments[:classes]
|
148
|
-
)
|
149
|
-
end
|
150
|
-
|
151
|
-
def missing_label?
|
152
|
-
@aria_label.blank? && @aria_labelledby.blank?
|
153
|
-
end
|
154
|
-
|
155
|
-
def call
|
156
|
-
render(Primer::BaseComponent.new(**@system_arguments))
|
157
|
-
end
|
158
|
-
end
|
159
84
|
end
|
160
85
|
end
|
161
86
|
end
|
@@ -5,9 +5,13 @@
|
|
5
5
|
<%= heading %>
|
6
6
|
<%= description %>
|
7
7
|
|
8
|
-
|
8
|
+
<% if primary_action.present? %>
|
9
|
+
<div class="blankslate-action">
|
10
|
+
<%= primary_action %>
|
11
|
+
</div>
|
12
|
+
<% end %>
|
9
13
|
<% if secondary_action.present? %>
|
10
|
-
<div class="
|
14
|
+
<div class="blankslate-action">
|
11
15
|
<%= secondary_action %>
|
12
16
|
</div>
|
13
17
|
<% end %>
|
@@ -5,9 +5,11 @@ module Primer
|
|
5
5
|
# Use `Blankslate` when there is a lack of content within a page or section. Use as placeholder to tell users why something isn't there.
|
6
6
|
#
|
7
7
|
# @accessibility
|
8
|
-
# -
|
9
|
-
# -
|
8
|
+
# - The blankslate uses a semantic heading that must be set at the appropriate level based on the hierarchy of the page.
|
9
|
+
# - All blankslate visuals have been programmed as decorative images, using `aria-hidden=”true”` and `img alt=””`, which will hide the visual from screen reader users.
|
10
|
+
# - The blankslate supports a primary and secondary action. Both actions have been built as semantic links with primary and secondary styling.
|
10
11
|
# - `secondary_action` text should be meaningful out of context and clearly describe the destination. Avoid using vague text like, "Learn more" or "Click here".
|
12
|
+
# - The blankslate can leverage the spinner component, which will communicate to screen reader users that the content is still loading.
|
11
13
|
class Blankslate < Primer::Component
|
12
14
|
status :beta
|
13
15
|
|
@@ -24,20 +26,19 @@ module Primer
|
|
24
26
|
# @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
|
25
27
|
renders_one :visual, types: {
|
26
28
|
icon: lambda { |**system_arguments|
|
27
|
-
system_arguments[:mb] = 3
|
28
29
|
system_arguments[:size] ||= :medium
|
29
30
|
system_arguments[:classes] = class_names("blankslate-icon", system_arguments[:classes])
|
30
31
|
|
31
32
|
Primer::OcticonComponent.new(**system_arguments)
|
32
33
|
},
|
33
34
|
spinner: lambda { |**system_arguments|
|
34
|
-
system_arguments[:
|
35
|
+
system_arguments[:classes] = class_names("blankslate-image", system_arguments[:classes])
|
35
36
|
|
36
37
|
Primer::SpinnerComponent.new(**system_arguments)
|
37
38
|
},
|
38
39
|
image: lambda { |**system_arguments|
|
39
|
-
system_arguments[:mb] = 3
|
40
40
|
system_arguments[:size] = "56x56"
|
41
|
+
system_arguments[:classes] = class_names("blankslate-image", system_arguments[:classes])
|
41
42
|
|
42
43
|
Primer::Image.new(**system_arguments)
|
43
44
|
}
|
@@ -50,8 +51,7 @@ module Primer
|
|
50
51
|
renders_one :heading, lambda { |tag:, **system_arguments|
|
51
52
|
deny_tag_argument(**system_arguments)
|
52
53
|
system_arguments[:tag] = tag
|
53
|
-
system_arguments[:
|
54
|
-
system_arguments[:classes] = class_names("h2", system_arguments[:classes])
|
54
|
+
system_arguments[:classes] = class_names("blankslate-heading", system_arguments[:classes])
|
55
55
|
|
56
56
|
Primer::HeadingComponent.new(**system_arguments)
|
57
57
|
}
|
@@ -64,7 +64,7 @@ module Primer
|
|
64
64
|
# @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
|
65
65
|
renders_one :description, lambda { |**system_arguments|
|
66
66
|
deny_tag_argument(**system_arguments)
|
67
|
-
system_arguments[:tag] = :
|
67
|
+
system_arguments[:tag] = :p
|
68
68
|
|
69
69
|
Primer::BaseComponent.new(**system_arguments)
|
70
70
|
}
|
@@ -80,7 +80,6 @@ module Primer
|
|
80
80
|
deny_tag_argument(**system_arguments)
|
81
81
|
system_arguments[:tag] = :a
|
82
82
|
system_arguments[:href] = href
|
83
|
-
system_arguments[:mt] = 5
|
84
83
|
system_arguments[:size] = :medium
|
85
84
|
system_arguments[:scheme] ||= :primary
|
86
85
|
|
@@ -96,8 +95,6 @@ module Primer
|
|
96
95
|
# @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
|
97
96
|
renders_one :secondary_action, lambda { |href:, **system_arguments|
|
98
97
|
system_arguments[:href] = href
|
99
|
-
# Padding is needed to increase touch area.
|
100
|
-
system_arguments[:p] = 3
|
101
98
|
|
102
99
|
Primer::LinkComponent.new(**system_arguments)
|
103
100
|
}
|
@@ -6,12 +6,12 @@ module Primer
|
|
6
6
|
class Dropdown < Primer::Component
|
7
7
|
# Required trigger for the dropdown. Has the same arguments as <%= link_to_component(Primer::ButtonComponent) %>,
|
8
8
|
# but it is locked as a `summary` tag.
|
9
|
-
renders_one :button, lambda { |**system_arguments
|
9
|
+
renders_one :button, lambda { |**system_arguments|
|
10
10
|
@button_arguments = system_arguments
|
11
11
|
@button_arguments[:button] = true
|
12
12
|
@button_arguments[:dropdown] = @with_caret
|
13
13
|
|
14
|
-
|
14
|
+
Primer::Content.new
|
15
15
|
}
|
16
16
|
|
17
17
|
# Required context menu for the dropdown.
|
@@ -41,22 +41,21 @@ module Primer
|
|
41
41
|
# @param caret [Symbol] <%= one_of(Primer::PopoverComponent::CARET_MAPPINGS.keys) %>
|
42
42
|
# @param large [Boolean] Whether to use the large version of the component.
|
43
43
|
# @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
|
44
|
-
renders_one :body, lambda { |caret: CARET_DEFAULT, large: false, **system_arguments
|
45
|
-
|
46
|
-
|
44
|
+
renders_one :body, lambda { |caret: CARET_DEFAULT, large: false, **system_arguments|
|
45
|
+
@body_arguments = system_arguments
|
46
|
+
@body_arguments[:classes] = class_names(
|
47
|
+
@body_arguments[:classes],
|
47
48
|
"Popover-message Box",
|
48
49
|
CARET_MAPPINGS[fetch_or_fallback(CARET_MAPPINGS.keys, caret, CARET_DEFAULT)],
|
49
50
|
"Popover-message--large" => large
|
50
51
|
)
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
52
|
+
@body_arguments[:p] ||= 4
|
53
|
+
@body_arguments[:mt] ||= 2
|
54
|
+
@body_arguments[:mx] ||= :auto
|
55
|
+
@body_arguments[:text_align] ||= :left
|
56
|
+
@body_arguments[:box_shadow] ||= :large
|
56
57
|
|
57
|
-
|
58
|
-
@body_arguments = system_arguments
|
59
|
-
view_context.capture { block&.call }
|
58
|
+
Primer::Content.new
|
60
59
|
}
|
61
60
|
|
62
61
|
# @example Default
|
@@ -89,20 +88,16 @@ module Primer
|
|
89
88
|
# <% end %>
|
90
89
|
# <% end %>
|
91
90
|
#
|
92
|
-
# @example With
|
91
|
+
# @example With multiple elements in the body
|
93
92
|
# <%= render Primer::PopoverComponent.new do |component| %>
|
94
93
|
# <% component.heading do %>
|
95
94
|
# Activity feed
|
96
95
|
# <% end %>
|
97
96
|
# <% component.body(caret: :left) do %>
|
98
|
-
# <p>
|
99
|
-
#
|
100
|
-
#
|
101
|
-
#
|
102
|
-
# <li>Thing #1</li>
|
103
|
-
# <li>Thing #2</li>
|
104
|
-
# </ul>
|
105
|
-
# </div>
|
97
|
+
# <p>This is the Popover body.</p>
|
98
|
+
# <%= render Primer::ButtonComponent.new(type: :submit) do %>
|
99
|
+
# Got it!
|
100
|
+
# <% end %>
|
106
101
|
# <% end %>
|
107
102
|
# <% end %>
|
108
103
|
#
|
@@ -4,7 +4,7 @@ module Primer
|
|
4
4
|
# Module to allow components to deal with the `test_selector` argument.
|
5
5
|
# It will only add the selector if env is not Production.
|
6
6
|
#
|
7
|
-
#
|
7
|
+
# test_selector: "foo" => data-test-selector="foo"
|
8
8
|
module TestSelectorHelper
|
9
9
|
TEST_SELECTOR_TAG = :test_selector
|
10
10
|
|
@@ -19,6 +19,20 @@ module Primer
|
|
19
19
|
|
20
20
|
BREAKPOINTS = ["", "-sm", "-md", "-lg", "-xl"].freeze
|
21
21
|
|
22
|
+
# Replacements for some classnames that end up being a different argument key
|
23
|
+
REPLACEMENT_KEYS = {
|
24
|
+
"^anim" => "animation",
|
25
|
+
"^v-align" => "vertical_align",
|
26
|
+
"^d" => "display",
|
27
|
+
"^wb" => "word_break",
|
28
|
+
"^v" => "visibility",
|
29
|
+
"^width" => "w",
|
30
|
+
"^height" => "h",
|
31
|
+
"^color-bg" => "bg",
|
32
|
+
"^color-border" => "border_color",
|
33
|
+
"^color-fg" => "color"
|
34
|
+
}.freeze
|
35
|
+
|
22
36
|
SUPPORTED_KEY_CACHE = Hash.new { |h, k| h[k] = !UTILITIES[k].nil? }
|
23
37
|
BREAKPOINT_INDEX_CACHE = Hash.new { |h, k| h[k] = BREAKPOINTS.index(k) }
|
24
38
|
|
@@ -159,15 +173,30 @@ module Primer
|
|
159
173
|
private
|
160
174
|
|
161
175
|
def find_selector(selector)
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
176
|
+
key = infer_selector_key(selector)
|
177
|
+
value_hash = UTILITIES[key]
|
178
|
+
|
179
|
+
return nil if value_hash.blank?
|
180
|
+
|
181
|
+
# Each value hash will also contain an array of classnames for breakpoints
|
182
|
+
# Key argument `0`, classes `[ "mr-0", "mr-sm-0", "mr-md-0", "mr-lg-0", "mr-xl-0" ]`
|
183
|
+
value_hash.each do |key_argument, classnames|
|
184
|
+
# Skip each value hash until we get one with the selector
|
185
|
+
next unless classnames.include?(selector)
|
186
|
+
|
187
|
+
# Return [:mr, 0, 1]
|
188
|
+
# has index of classname, so we can match it up with responsive array `mr: [nil, 0]`
|
189
|
+
return [key, key_argument, classnames.index(selector)]
|
190
|
+
end
|
191
|
+
|
192
|
+
nil
|
193
|
+
end
|
194
|
+
|
195
|
+
def infer_selector_key(selector)
|
196
|
+
REPLACEMENT_KEYS.each do |k, v|
|
197
|
+
return v.to_sym if selector.match?(Regexp.new(k))
|
169
198
|
end
|
170
|
-
|
199
|
+
selector.split("-").first.to_sym
|
171
200
|
end
|
172
201
|
end
|
173
202
|
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "rubocop"
|
4
|
+
|
5
|
+
# :nocov:
|
6
|
+
module RuboCop
|
7
|
+
module Cop
|
8
|
+
module Primer
|
9
|
+
# This cop ensures that components don't use deprecated component names
|
10
|
+
#
|
11
|
+
# bad
|
12
|
+
# Primer::ComponentNameComponent.new()
|
13
|
+
#
|
14
|
+
# good
|
15
|
+
# Primer::Beta::ComponentName.new()
|
16
|
+
class ComponentNameMigration < BaseCop
|
17
|
+
DEPRECATIONS = {
|
18
|
+
"Primer::TestComponent" => "Primer::Beta::Test"
|
19
|
+
}.freeze
|
20
|
+
|
21
|
+
def on_send(node)
|
22
|
+
return unless node.method_name == :new && !node.receiver.nil? && DEPRECATIONS.key?(node.receiver.const_name)
|
23
|
+
|
24
|
+
add_offense(node.receiver, message: "Don't use deprecated names")
|
25
|
+
end
|
26
|
+
|
27
|
+
def autocorrect(node)
|
28
|
+
lambda do |corrector|
|
29
|
+
corrector.replace(node, DEPRECATIONS[node.const_name])
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
data/lib/tasks/docs.rake
CHANGED
@@ -106,7 +106,8 @@ namespace :docs do
|
|
106
106
|
errors = []
|
107
107
|
|
108
108
|
# Deletes docs before regenerating them, guaranteeing that we don't keep stale docs.
|
109
|
-
|
109
|
+
components_content_glob = File.join(*%w[docs content components ** *.md])
|
110
|
+
FileUtils.rm_rf(components_content_glob)
|
110
111
|
|
111
112
|
components.sort_by(&:name).each do |component|
|
112
113
|
documentation = registry.get(component.name)
|
@@ -114,7 +115,7 @@ namespace :docs do
|
|
114
115
|
data = docs_metadata(component)
|
115
116
|
|
116
117
|
path = Pathname.new(data[:path])
|
117
|
-
path.dirname.
|
118
|
+
path.dirname.mkpath unless path.dirname.exist?
|
118
119
|
File.open(path, "w") do |f|
|
119
120
|
f.puts("---")
|
120
121
|
f.puts("title: #{data[:title]}")
|
@@ -315,7 +316,6 @@ namespace :docs do
|
|
315
316
|
nav_entries = Dir[File.join(*%w[adr *.md])].sort.map do |orig_path|
|
316
317
|
orig_file_name = File.basename(orig_path)
|
317
318
|
url_name = orig_file_name.chomp(".md")
|
318
|
-
title = ActiveSupport::Inflector.titleize(url_name.sub(/\A\d+-/, ""))
|
319
319
|
|
320
320
|
file_contents = File.read(orig_path)
|
321
321
|
file_contents = <<~CONTENTS.sub(/\n+\z/, "\n")
|
@@ -323,6 +323,12 @@ namespace :docs do
|
|
323
323
|
#{file_contents}
|
324
324
|
CONTENTS
|
325
325
|
|
326
|
+
title_match = /^# (.+)/.match(file_contents)
|
327
|
+
title = title_match[1]
|
328
|
+
|
329
|
+
# Don't include initial ADR for recording ADRs
|
330
|
+
next nil if title == "Record architecture decisions"
|
331
|
+
|
326
332
|
File.write(File.join(adr_content_dir, orig_file_name), file_contents)
|
327
333
|
puts "Copied #{orig_path}"
|
328
334
|
|
@@ -332,9 +338,9 @@ namespace :docs do
|
|
332
338
|
nav_yaml_file = File.join(*%w[docs src @primer gatsby-theme-doctocat nav.yml])
|
333
339
|
nav_yaml = YAML.load_file(nav_yaml_file)
|
334
340
|
adr_entry = {
|
335
|
-
"title" => "Architecture
|
341
|
+
"title" => "Architecture decisions",
|
336
342
|
"url" => "/adr",
|
337
|
-
"children" => nav_entries
|
343
|
+
"children" => nav_entries.compact
|
338
344
|
}
|
339
345
|
|
340
346
|
existing_index = nav_yaml.index { |entry| entry["url"] == "/adr" }
|
@@ -360,7 +366,7 @@ namespace :docs do
|
|
360
366
|
short_name = component.name.gsub(/Primer|::/, "")
|
361
367
|
initialize_method = documentation.meths.find(&:constructor?)
|
362
368
|
|
363
|
-
next unless initialize_method
|
369
|
+
next unless initialize_method&.tags(:example)&.any?
|
364
370
|
|
365
371
|
yard_example_tags = initialize_method.tags(:example)
|
366
372
|
|
data/lib/tasks/utilities.rake
CHANGED
@@ -5,6 +5,7 @@ namespace :utilities do
|
|
5
5
|
require "yaml"
|
6
6
|
require "json"
|
7
7
|
require File.expand_path("./../../demo/config/environment.rb", __dir__)
|
8
|
+
require "primer/classify/utilities"
|
8
9
|
|
9
10
|
# Keys that are looked for to be included in the utilities.yml file
|
10
11
|
# rubocop:disable Lint/ConstantDefinitionInBlock
|
@@ -28,20 +29,6 @@ namespace :utilities do
|
|
28
29
|
/^v\b/
|
29
30
|
].freeze
|
30
31
|
|
31
|
-
# Replacements for some classnames that end up being a different argument key
|
32
|
-
REPLACEMENT_KEYS = {
|
33
|
-
"^anim" => "animation",
|
34
|
-
"^v-align" => "vertical_align",
|
35
|
-
"^d" => "display",
|
36
|
-
"^wb" => "word_break",
|
37
|
-
"^v" => "visibility",
|
38
|
-
"^width" => "w",
|
39
|
-
"^height" => "h",
|
40
|
-
"^color-bg" => "bg",
|
41
|
-
"^color-border" => "border_color",
|
42
|
-
"^color-fg" => "color"
|
43
|
-
}.freeze
|
44
|
-
|
45
32
|
BREAKPOINTS = [nil, "sm", "md", "lg", "xl"].freeze
|
46
33
|
# rubocop:enable Lint/ConstantDefinitionInBlock
|
47
34
|
|
@@ -80,7 +67,7 @@ namespace :utilities do
|
|
80
67
|
key = ""
|
81
68
|
|
82
69
|
# Look for a replacement key
|
83
|
-
REPLACEMENT_KEYS.each do |k, v|
|
70
|
+
Primer::Classify::Utilities::REPLACEMENT_KEYS.each do |k, v|
|
84
71
|
next unless classname.match?(Regexp.new(k))
|
85
72
|
|
86
73
|
key = v
|
data/static/arguments.yml
CHANGED
@@ -165,6 +165,10 @@
|
|
165
165
|
- component: AutoComplete
|
166
166
|
source: https://github.com/primer/view_components/tree/main/app/components/primer/beta/auto_complete.rb
|
167
167
|
parameters:
|
168
|
+
- name: label_text
|
169
|
+
type: String
|
170
|
+
default: N/A
|
171
|
+
description: The label of the input.
|
168
172
|
- name: src
|
169
173
|
type: String
|
170
174
|
default: N/A
|
@@ -177,6 +181,11 @@
|
|
177
181
|
type: String
|
178
182
|
default: N/A
|
179
183
|
description: Id of the list element.
|
184
|
+
- name: is_label_visible
|
185
|
+
type: Boolean
|
186
|
+
default: "`true`"
|
187
|
+
description: Controls if the label is visible. If `false`, screen reader only
|
188
|
+
text will be added.
|
180
189
|
- name: system_arguments
|
181
190
|
type: Hash
|
182
191
|
default: N/A
|
data/static/audited_at.json
CHANGED
@@ -11,7 +11,6 @@
|
|
11
11
|
"Primer::BaseButton": "",
|
12
12
|
"Primer::BaseComponent": "",
|
13
13
|
"Primer::Beta::AutoComplete": "",
|
14
|
-
"Primer::Beta::AutoComplete::Input": "",
|
15
14
|
"Primer::Beta::AutoComplete::Item": "",
|
16
15
|
"Primer::Beta::Avatar": "",
|
17
16
|
"Primer::Beta::AvatarStack": "",
|
@@ -28,6 +27,7 @@
|
|
28
27
|
"Primer::ButtonGroup": "",
|
29
28
|
"Primer::ClipboardCopy": "",
|
30
29
|
"Primer::CloseButton": "",
|
30
|
+
"Primer::Content": "",
|
31
31
|
"Primer::CounterComponent": "",
|
32
32
|
"Primer::DetailsComponent": "",
|
33
33
|
"Primer::Dropdown": "",
|
data/static/classes.yml
CHANGED
@@ -88,7 +88,10 @@
|
|
88
88
|
- ".avatar-more"
|
89
89
|
- ".avatar-small"
|
90
90
|
- ".blankslate"
|
91
|
+
- ".blankslate-action"
|
92
|
+
- ".blankslate-heading"
|
91
93
|
- ".blankslate-icon"
|
94
|
+
- ".blankslate-image"
|
92
95
|
- ".blankslate-narrow"
|
93
96
|
- ".blankslate-spacious"
|
94
97
|
- ".border"
|
@@ -163,7 +166,6 @@
|
|
163
166
|
- ".form-control"
|
164
167
|
- ".gutter-condensed"
|
165
168
|
- ".gutter-lg"
|
166
|
-
- ".h2"
|
167
169
|
- ".hidden-text-expander"
|
168
170
|
- ".inline"
|
169
171
|
- ".left-0"
|
@@ -171,9 +173,7 @@
|
|
171
173
|
- ".list-style-none"
|
172
174
|
- ".markdown-body"
|
173
175
|
- ".mb-0"
|
174
|
-
- ".mb-1"
|
175
176
|
- ".mb-2"
|
176
|
-
- ".mb-3"
|
177
177
|
- ".menu"
|
178
178
|
- ".menu-heading"
|
179
179
|
- ".menu-item"
|
@@ -181,7 +181,6 @@
|
|
181
181
|
- ".mr-2"
|
182
182
|
- ".mr-n1"
|
183
183
|
- ".mt-2"
|
184
|
-
- ".mt-3"
|
185
184
|
- ".mt-5"
|
186
185
|
- ".mx-auto"
|
187
186
|
- ".no-underline"
|
@@ -194,6 +193,7 @@
|
|
194
193
|
- ".pr-2"
|
195
194
|
- ".pt-5"
|
196
195
|
- ".right-0"
|
196
|
+
- ".sr-only"
|
197
197
|
- ".tabnav"
|
198
198
|
- ".tabnav-tab"
|
199
199
|
- ".tabnav-tabs"
|
data/static/constants.json
CHANGED
@@ -181,16 +181,8 @@
|
|
181
181
|
]
|
182
182
|
},
|
183
183
|
"Primer::Beta::AutoComplete": {
|
184
|
-
"Input": "Primer::Beta::AutoComplete::Input",
|
185
184
|
"Item": "Primer::Beta::AutoComplete::Item"
|
186
185
|
},
|
187
|
-
"Primer::Beta::AutoComplete::Input": {
|
188
|
-
"DEFAULT_TYPE": "text",
|
189
|
-
"TYPE_OPTIONS": [
|
190
|
-
"text",
|
191
|
-
"search"
|
192
|
-
]
|
193
|
-
},
|
194
186
|
"Primer::Beta::AutoComplete::Item": {
|
195
187
|
},
|
196
188
|
"Primer::Beta::Avatar": {
|
@@ -317,6 +309,8 @@
|
|
317
309
|
"submit"
|
318
310
|
]
|
319
311
|
},
|
312
|
+
"Primer::Content": {
|
313
|
+
},
|
320
314
|
"Primer::CounterComponent": {
|
321
315
|
"DEFAULT_SCHEME": "default",
|
322
316
|
"DEPRECATED_SCHEME_OPTIONS": [
|
data/static/statuses.json
CHANGED
@@ -11,7 +11,6 @@
|
|
11
11
|
"Primer::BaseButton": "beta",
|
12
12
|
"Primer::BaseComponent": "beta",
|
13
13
|
"Primer::Beta::AutoComplete": "beta",
|
14
|
-
"Primer::Beta::AutoComplete::Input": "alpha",
|
15
14
|
"Primer::Beta::AutoComplete::Item": "beta",
|
16
15
|
"Primer::Beta::Avatar": "beta",
|
17
16
|
"Primer::Beta::AvatarStack": "beta",
|
@@ -28,6 +27,7 @@
|
|
28
27
|
"Primer::ButtonGroup": "beta",
|
29
28
|
"Primer::ClipboardCopy": "beta",
|
30
29
|
"Primer::CloseButton": "beta",
|
30
|
+
"Primer::Content": "stable",
|
31
31
|
"Primer::CounterComponent": "beta",
|
32
32
|
"Primer::DetailsComponent": "beta",
|
33
33
|
"Primer::Dropdown": "alpha",
|
@@ -61,6 +61,6 @@
|
|
61
61
|
"Primer::TimeAgoComponent": "beta",
|
62
62
|
"Primer::TimelineItemComponent": "beta",
|
63
63
|
"Primer::TimelineItemComponent::BadgeComponent": "alpha",
|
64
|
-
"Primer::Tooltip": "
|
64
|
+
"Primer::Tooltip": "deprecated",
|
65
65
|
"Primer::Truncate": "beta"
|
66
66
|
}
|
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.68
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- GitHub Open Source
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-02-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: actionview
|
@@ -44,14 +44,14 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
47
|
+
version: '16'
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
54
|
+
version: '16'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: view_component
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -425,6 +425,7 @@ files:
|
|
425
425
|
- app/components/primer/clipboard_copy_component.ts
|
426
426
|
- app/components/primer/close_button.rb
|
427
427
|
- app/components/primer/component.rb
|
428
|
+
- app/components/primer/content.rb
|
428
429
|
- app/components/primer/counter_component.rb
|
429
430
|
- app/components/primer/details_component.html.erb
|
430
431
|
- app/components/primer/details_component.rb
|
@@ -542,6 +543,7 @@ files:
|
|
542
543
|
- lib/rubocop/config/default.yml
|
543
544
|
- lib/rubocop/cop/primer.rb
|
544
545
|
- lib/rubocop/cop/primer/base_cop.rb
|
546
|
+
- lib/rubocop/cop/primer/component_name_migration.rb
|
545
547
|
- lib/rubocop/cop/primer/deprecated_arguments.rb
|
546
548
|
- lib/rubocop/cop/primer/deprecated_button_arguments.rb
|
547
549
|
- lib/rubocop/cop/primer/deprecated_label_schemes.rb
|
@@ -586,7 +588,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
586
588
|
- !ruby/object:Gem::Version
|
587
589
|
version: '0'
|
588
590
|
requirements: []
|
589
|
-
rubygems_version: 3.1.
|
591
|
+
rubygems_version: 3.1.6
|
590
592
|
signing_key:
|
591
593
|
specification_version: 4
|
592
594
|
summary: ViewComponents for the Primer Design System
|