primer_view_components 0.0.68 → 0.0.71

Sign up to get free protection for your applications and to get access to all the features.
Files changed (40) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +96 -1
  3. data/app/assets/javascripts/primer_view_components.js +1 -1
  4. data/app/assets/javascripts/primer_view_components.js.map +1 -1
  5. data/app/components/primer/alpha/navigation_list_element.d.ts +11 -0
  6. data/app/components/primer/alpha/navigation_list_element.js +42 -0
  7. data/app/components/primer/alpha/tooltip.d.ts +24 -0
  8. data/app/components/primer/alpha/tooltip.js +381 -0
  9. data/app/components/primer/alpha/tooltip.rb +103 -0
  10. data/app/components/primer/alpha/tooltip.ts +383 -0
  11. data/app/components/primer/base_component.rb +2 -2
  12. data/app/components/primer/beta/auto_complete/auto_complete.html.erb +16 -6
  13. data/app/components/primer/beta/auto_complete.rb +82 -20
  14. data/app/components/primer/beta/truncate.rb +1 -0
  15. data/app/components/primer/button_component.html.erb +1 -0
  16. data/app/components/primer/button_component.rb +29 -0
  17. data/app/components/primer/component.rb +9 -2
  18. data/app/components/primer/details_component.rb +1 -1
  19. data/app/components/primer/icon_button.rb +1 -1
  20. data/app/components/primer/link_component.erb +4 -0
  21. data/app/components/primer/link_component.rb +29 -4
  22. data/app/components/primer/markdown.rb +1 -1
  23. data/app/components/primer/primer.d.ts +1 -0
  24. data/app/components/primer/primer.js +1 -0
  25. data/app/components/primer/primer.ts +1 -0
  26. data/app/components/primer/subhead_component.html.erb +1 -1
  27. data/app/components/primer/subhead_component.rb +1 -1
  28. data/lib/primer/classify/utilities.yml +40 -0
  29. data/lib/primer/view_components/linters/button_component_migration_counter.rb +1 -1
  30. data/lib/primer/view_components/version.rb +1 -1
  31. data/lib/rubocop/cop/primer/primer_octicon.rb +1 -1
  32. data/lib/tasks/custom_utilities.yml +12 -0
  33. data/lib/tasks/docs.rake +9 -5
  34. data/lib/tasks/utilities.rake +1 -1
  35. data/static/arguments.yml +43 -1
  36. data/static/audited_at.json +1 -0
  37. data/static/classes.yml +5 -0
  38. data/static/constants.json +18 -0
  39. data/static/statuses.json +1 -0
  40. metadata +18 -11
@@ -0,0 +1,4 @@
1
+ <%= render Primer::BaseComponent.new(**@system_arguments) do %>
2
+ <%= content %>
3
+ <%= tooltip %>
4
+ <% end %>
@@ -15,6 +15,23 @@ module Primer
15
15
  DEFAULT_TAG = :a
16
16
  TAG_OPTIONS = [DEFAULT_TAG, :span].freeze
17
17
 
18
+ # `Tooltip` that appears on mouse hover or keyboard focus over the link. Use tooltips sparingly and as a last resort.
19
+ # **Important:** This tooltip defaults to `type: :description`. In a few scenarios, `type: :label` may be more appropriate.
20
+ # Consult the <%= link_to_component(Primer::Alpha::Tooltip) %> documentation for more information.
21
+ #
22
+ # @param type [Symbol] (:description) <%= one_of(Primer::Alpha::Tooltip::TYPE_OPTIONS) %>
23
+ # @param system_arguments [Hash] Same arguments as <%= link_to_component(Primer::Alpha::Tooltip) %>.
24
+ renders_one :tooltip, lambda { |**system_arguments|
25
+ raise ArgumentError, "Links with a tooltip must have a unique `id` set on the `LinkComponent`." if @id.blank? && !Rails.env.production?
26
+
27
+ @system_arguments = system_arguments
28
+
29
+ @system_arguments[:for_id] = @id
30
+ @system_arguments[:type] ||= :description
31
+
32
+ Primer::Alpha::Tooltip.new(**@system_arguments)
33
+ }
34
+
18
35
  # @example Default
19
36
  # <%= render(Primer::LinkComponent.new(href: "#")) { "Link" } %>
20
37
  #
@@ -31,6 +48,15 @@ module Primer
31
48
  # @example Span as link
32
49
  # <%= render(Primer::LinkComponent.new(tag: :span)) { "Span as a link" } %>
33
50
  #
51
+ # @example With tooltip
52
+ # @description
53
+ # Use tooltips sparingly and as a last resort. Consult the <%= link_to_component(Primer::Alpha::Tooltip) %> documentation for more information.
54
+ # @code
55
+ # <%= render(Primer::LinkComponent.new(href: "#", id: "link-with-tooltip")) do |c| %>
56
+ # <% c.tooltip(text: "Tooltip text") %>
57
+ # Link
58
+ # <% end %>
59
+ #
34
60
  # @param tag [String] <%= one_of(Primer::LinkComponent::TAG_OPTIONS) %>
35
61
  # @param href [String] URL to be used for the Link. Required if tag is `:a`. If the requirements are not met an error will be raised in non production environments. In production, an empty link element will be rendered.
36
62
  # @param scheme [Symbol] <%= one_of(Primer::LinkComponent::SCHEME_MAPPINGS.keys) %>
@@ -39,6 +65,9 @@ module Primer
39
65
  # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
40
66
  def initialize(href: nil, tag: DEFAULT_TAG, scheme: DEFAULT_SCHEME, muted: false, underline: true, **system_arguments)
41
67
  @system_arguments = system_arguments
68
+
69
+ @id = @system_arguments[:id]
70
+
42
71
  @system_arguments[:tag] = fetch_or_fallback(TAG_OPTIONS, tag, DEFAULT_TAG)
43
72
  @system_arguments[:href] = href
44
73
  @system_arguments[:classes] = class_names(
@@ -50,10 +79,6 @@ module Primer
50
79
  )
51
80
  end
52
81
 
53
- def call
54
- render(Primer::BaseComponent.new(**@system_arguments)) { content }
55
- end
56
-
57
82
  def before_render
58
83
  raise ArgumentError, "href is required when using <a> tag" if @system_arguments[:tag] == :a && @system_arguments[:href].nil? && !Rails.env.production?
59
84
  end
@@ -93,7 +93,7 @@ module Primer
93
93
  # <ol>
94
94
  # <li>Michael Jackson</li>
95
95
  # <li>Michael Bolton</li>
96
- # <li>Michael Buble</li>
96
+ # <li>Michael Bublé</li>
97
97
  # </ol>
98
98
  #
99
99
  # <p>And an unordered task list:</p>
@@ -5,3 +5,4 @@ import './time_ago_component';
5
5
  import './local_time';
6
6
  import './image_crop';
7
7
  import './dropdown';
8
+ import './alpha/tooltip';
@@ -5,3 +5,4 @@ import './time_ago_component';
5
5
  import './local_time';
6
6
  import './image_crop';
7
7
  import './dropdown';
8
+ import './alpha/tooltip';
@@ -5,3 +5,4 @@ import './time_ago_component'
5
5
  import './local_time'
6
6
  import './image_crop'
7
7
  import './dropdown'
8
+ import './alpha/tooltip'
@@ -1,5 +1,5 @@
1
1
  <%= render Primer::BaseComponent.new(**@system_arguments) do %>
2
2
  <%= heading %>
3
- <%= actions %>
4
3
  <%= description %>
4
+ <%= actions %>
5
5
  <% end %>
@@ -4,7 +4,7 @@ module Primer
4
4
  # Use `Subhead` as the start of a section. The `:heading` slot will render an `<h2>` font-sized text.
5
5
  #
6
6
  # - Optionally set the `:description` slot to render a short description and the `:actions` slot for a related action.
7
- # - Use a succint, one-line description for the `:description` slot. For longer descriptions, omit the description slot and render a paragraph below the `Subhead`.
7
+ # - Use a succinct, one-line description for the `:description` slot. For longer descriptions, omit the description slot and render a paragraph below the `Subhead`.
8
8
  # - Use the actions slot to render a related action to the right of the heading. Use <%= link_to_component(Primer::ButtonComponent) %> or <%= link_to_component(Primer::LinkComponent) %>.
9
9
  #
10
10
  # @accessibility
@@ -39,6 +39,10 @@
39
39
  - color-fg-severe
40
40
  :danger:
41
41
  - color-fg-danger
42
+ :open:
43
+ - color-fg-open
44
+ :closed:
45
+ - color-fg-closed
42
46
  :done:
43
47
  - color-fg-done
44
48
  :sponsors:
@@ -78,6 +82,14 @@
78
82
  - color-bg-danger
79
83
  :danger_emphasis:
80
84
  - color-bg-danger-emphasis
85
+ :open:
86
+ - color-bg-open
87
+ :open_emphasis:
88
+ - color-bg-open-emphasis
89
+ :closed:
90
+ - color-bg-closed
91
+ :closed_emphasis:
92
+ - color-bg-closed-emphasis
81
93
  :done:
82
94
  - color-bg-done
83
95
  :done_emphasis:
@@ -86,6 +98,8 @@
86
98
  - color-bg-sponsors
87
99
  :sponsors_emphasis:
88
100
  - color-bg-sponsors-emphasis
101
+ :transparent:
102
+ - color-bg-transparent
89
103
  :border_color:
90
104
  :default:
91
105
  - color-border-default
@@ -113,6 +127,14 @@
113
127
  - color-border-danger
114
128
  :danger_emphasis:
115
129
  - color-border-danger-emphasis
130
+ :open:
131
+ - color-border-open
132
+ :open_emphasis:
133
+ - color-border-open-emphasis
134
+ :closed:
135
+ - color-border-closed
136
+ :closed_emphasis:
137
+ - color-border-closed-emphasis
116
138
  :done:
117
139
  - color-border-done
118
140
  :done_emphasis:
@@ -1395,6 +1417,12 @@
1395
1417
  - hide-lg
1396
1418
  :xl:
1397
1419
  - hide-xl
1420
+ :whenNarrow:
1421
+ - hide-whenNarrow
1422
+ :whenRegular:
1423
+ - hide-whenRegular
1424
+ :whenWide:
1425
+ - hide-whenWide
1398
1426
  :container:
1399
1427
  :sm:
1400
1428
  - container-sm
@@ -1533,10 +1561,22 @@
1533
1561
  :text_align:
1534
1562
  :right:
1535
1563
  - text-right
1564
+ - text-sm-right
1565
+ - text-md-right
1566
+ - text-lg-right
1567
+ - text-xl-right
1536
1568
  :left:
1537
1569
  - text-left
1570
+ - text-sm-left
1571
+ - text-md-left
1572
+ - text-lg-left
1573
+ - text-xl-left
1538
1574
  :center:
1539
1575
  - text-center
1576
+ - text-sm-center
1577
+ - text-md-center
1578
+ - text-lg-center
1579
+ - text-xl-center
1540
1580
  :font_weight:
1541
1581
  :light:
1542
1582
  - text-light
@@ -15,7 +15,7 @@ module ERBLint
15
15
  constant: "TAG_OPTIONS"
16
16
  ).freeze
17
17
 
18
- # CloseButton component has preference when this class is seen in conjuction with `btn`.
18
+ # CloseButton component has preference when this class is seen in conjunction with `btn`.
19
19
  DISALLOWED_CLASSES = %w[close-button].freeze
20
20
  CLASSES = %w[btn btn-link].freeze
21
21
  MESSAGE = "We are migrating buttons to use [Primer::ButtonComponent](https://primer.style/view-components/components/button), please try to use that instead of raw HTML."
@@ -5,7 +5,7 @@ module Primer
5
5
  module VERSION
6
6
  MAJOR = 0
7
7
  MINOR = 0
8
- PATCH = 68
8
+ PATCH = 71
9
9
 
10
10
  STRING = [MAJOR, MINOR, PATCH].join(".")
11
11
  end
@@ -207,7 +207,7 @@ module RuboCop
207
207
  return node.source unless node.type == :str
208
208
  return ":#{node.value}" unless node.value.include?("-")
209
209
 
210
- # If the icon contains `-` we need to cast the string as a symbole
210
+ # If the icon contains `-` we need to cast the string as a symbol
211
211
  # E.g: `arrow-down` becomes `:"arrow-down"`
212
212
  ":#{node.source}"
213
213
  end
@@ -54,10 +54,22 @@
54
54
  :text_align:
55
55
  :right:
56
56
  - text-right
57
+ - text-sm-right
58
+ - text-md-right
59
+ - text-lg-right
60
+ - text-xl-right
57
61
  :left:
58
62
  - text-left
63
+ - text-sm-left
64
+ - text-md-left
65
+ - text-lg-left
66
+ - text-xl-left
59
67
  :center:
60
68
  - text-center
69
+ - text-sm-center
70
+ - text-md-center
71
+ - text-lg-center
72
+ - text-xl-center
61
73
  :font_weight:
62
74
  :light:
63
75
  - text-light
data/lib/tasks/docs.rake CHANGED
@@ -82,7 +82,8 @@ namespace :docs do
82
82
  Primer::Alpha::UnderlineNav,
83
83
  Primer::Alpha::UnderlinePanels,
84
84
  Primer::Alpha::TabNav,
85
- Primer::Alpha::TabPanels
85
+ Primer::Alpha::TabPanels,
86
+ Primer::Alpha::Tooltip
86
87
  ]
87
88
 
88
89
  js_components = [
@@ -94,7 +95,10 @@ namespace :docs do
94
95
  Primer::TabContainerComponent,
95
96
  Primer::TimeAgoComponent,
96
97
  Primer::Alpha::UnderlinePanels,
97
- Primer::Alpha::TabPanels
98
+ Primer::Alpha::TabPanels,
99
+ Primer::Alpha::Tooltip,
100
+ Primer::ButtonComponent,
101
+ Primer::LinkComponent
98
102
  ]
99
103
 
100
104
  all_components = Primer::Component.descendants - [Primer::BaseComponent]
@@ -168,12 +172,12 @@ namespace :docs do
168
172
  f.puts("| Name | Type | Default | Description |")
169
173
  f.puts("| :- | :- | :- | :- |")
170
174
 
171
- docummented_params = params.map(&:name)
175
+ documented_params = params.map(&:name)
172
176
  component_params = component.instance_method(:initialize).parameters.map { |p| p.last.to_s }
173
177
 
174
- if (docummented_params & component_params).size != component_params.size
178
+ if (documented_params & component_params).size != component_params.size
175
179
  err = { arguments: {} }
176
- (component_params - docummented_params).each do |arg|
180
+ (component_params - documented_params).each do |arg|
177
181
  err[:arguments][arg] = "Not documented"
178
182
  end
179
183
 
@@ -86,7 +86,7 @@ namespace :utilities do
86
86
  classname.sub!(/^[^-]+-/, "")
87
87
  end
88
88
 
89
- # Change the rest from hypens to underscores
89
+ # Change the rest from hyphens to underscores
90
90
  classname.sub!(/-/, "_")
91
91
 
92
92
  # convert padding/margin negative values ie n7 to -7
data/static/arguments.yml CHANGED
@@ -95,6 +95,30 @@
95
95
  type: Hash
96
96
  default: N/A
97
97
  description: "[System arguments](/system-arguments)"
98
+ - component: Tooltip
99
+ source: https://github.com/primer/view_components/tree/main/app/components/primer/alpha/tooltip.rb
100
+ parameters:
101
+ - name: for_id
102
+ type: String
103
+ default: N/A
104
+ description: The ID of the element that the tooltip should be attached to.
105
+ - name: type
106
+ type: Symbol
107
+ default: N/A
108
+ description: One of `:description` and `:label`.
109
+ - name: direction
110
+ type: Symbol
111
+ default: "`:s`"
112
+ description: One of `:e`, `:n`, `:ne`, `:nw`, `:s`, `:se`, `:sw`, or `:w`.
113
+ - name: text
114
+ type: String
115
+ default: N/A
116
+ description: The text content of the tooltip. This should be brief and no longer
117
+ than a sentence.
118
+ - name: system_arguments
119
+ type: Hash
120
+ default: N/A
121
+ description: "[System arguments](/system-arguments)"
98
122
  - component: UnderlineNav
99
123
  source: https://github.com/primer/view_components/tree/main/app/components/primer/alpha/underline_nav.rb
100
124
  parameters:
@@ -177,15 +201,33 @@
177
201
  type: String
178
202
  default: N/A
179
203
  description: Id of the input element.
204
+ - name: input_name
205
+ type: String
206
+ default: "`nil`"
207
+ description: Optional name of the input element, defaults to `input_id` when not
208
+ set.
180
209
  - name: list_id
181
210
  type: String
182
211
  default: N/A
183
212
  description: Id of the list element.
213
+ - name: with_icon
214
+ type: Boolean
215
+ default: "`false`"
216
+ description: Controls if a search icon is visible, defaults to `false`.
184
217
  - name: is_label_visible
185
218
  type: Boolean
186
219
  default: "`true`"
187
220
  description: Controls if the label is visible. If `false`, screen reader only
188
221
  text will be added.
222
+ - name: is_clearable
223
+ type: Boolean
224
+ default: "`false`"
225
+ description: Adds optional clear button.
226
+ - name: is_label_inline
227
+ type: Boolean
228
+ default: "`false`"
229
+ description: Controls if the label is inline. On smaller screens, label will always
230
+ become stacked.
189
231
  - name: system_arguments
190
232
  type: Hash
191
233
  default: N/A
@@ -453,7 +495,7 @@
453
495
  - name: reset
454
496
  type: Boolean
455
497
  default: "`false`"
456
- description: Defatuls to false. If set to true, it will remove the default caret
498
+ description: Defaults to false. If set to true, it will remove the default caret
457
499
  and remove style from the summary element
458
500
  - name: system_arguments
459
501
  type: Hash
@@ -6,6 +6,7 @@
6
6
  "Primer::Alpha::Layout::Sidebar": "",
7
7
  "Primer::Alpha::TabNav": "",
8
8
  "Primer::Alpha::TabPanels": "",
9
+ "Primer::Alpha::Tooltip": "",
9
10
  "Primer::Alpha::UnderlineNav": "",
10
11
  "Primer::Alpha::UnderlinePanels": "",
11
12
  "Primer::BaseButton": "",
data/static/classes.yml CHANGED
@@ -82,7 +82,11 @@
82
82
  - ".UnderlineNav-item"
83
83
  - ".UnderlineNav-octicon"
84
84
  - ".anim-rotate"
85
+ - ".autocomplete-body"
86
+ - ".autocomplete-embedded-icon-wrap"
85
87
  - ".autocomplete-item"
88
+ - ".autocomplete-label-inline"
89
+ - ".autocomplete-label-stacked"
86
90
  - ".autocomplete-results"
87
91
  - ".avatar"
88
92
  - ".avatar-more"
@@ -171,6 +175,7 @@
171
175
  - ".left-0"
172
176
  - ".lh-0"
173
177
  - ".list-style-none"
178
+ - ".m-2"
174
179
  - ".markdown-body"
175
180
  - ".mb-0"
176
181
  - ".mb-2"
@@ -138,6 +138,24 @@
138
138
  "div"
139
139
  ]
140
140
  },
141
+ "Primer::Alpha::Tooltip": {
142
+ "DIRECTION_DEFAULT": "s",
143
+ "DIRECTION_OPTIONS": [
144
+ "s",
145
+ "n",
146
+ "e",
147
+ "w",
148
+ "ne",
149
+ "nw",
150
+ "se",
151
+ "sw"
152
+ ],
153
+ "TYPE_FALLBACK": "description",
154
+ "TYPE_OPTIONS": [
155
+ "label",
156
+ "description"
157
+ ]
158
+ },
141
159
  "Primer::Alpha::UnderlineNav": {
142
160
  "BODY_TAG_DEFAULT": "ul",
143
161
  "TAG_DEFAULT": "nav",
data/static/statuses.json CHANGED
@@ -6,6 +6,7 @@
6
6
  "Primer::Alpha::Layout::Sidebar": "alpha",
7
7
  "Primer::Alpha::TabNav": "alpha",
8
8
  "Primer::Alpha::TabPanels": "alpha",
9
+ "Primer::Alpha::Tooltip": "alpha",
9
10
  "Primer::Alpha::UnderlineNav": "alpha",
10
11
  "Primer::Alpha::UnderlinePanels": "alpha",
11
12
  "Primer::BaseButton": "beta",
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.68
4
+ version: 0.0.71
5
5
  platform: ruby
6
6
  authors:
7
7
  - GitHub Open Source
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-02-23 00:00:00.000000000 Z
11
+ date: 2022-03-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionview
@@ -42,16 +42,16 @@ dependencies:
42
42
  name: octicons
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - "~>"
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
- version: '16'
47
+ version: 17.0.0
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: '16'
54
+ version: 17.0.0
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: view_component
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -366,7 +366,7 @@ dependencies:
366
366
  - - "~>"
367
367
  - !ruby/object:Gem::Version
368
368
  version: 0.9.25
369
- description:
369
+ description:
370
370
  email:
371
371
  - opensource+primer_view_components@github.com
372
372
  executables: []
@@ -383,10 +383,16 @@ files:
383
383
  - app/components/primer/alpha/button_marketing.rb
384
384
  - app/components/primer/alpha/layout.html.erb
385
385
  - app/components/primer/alpha/layout.rb
386
+ - app/components/primer/alpha/navigation_list_element.d.ts
387
+ - app/components/primer/alpha/navigation_list_element.js
386
388
  - app/components/primer/alpha/tab_nav.html.erb
387
389
  - app/components/primer/alpha/tab_nav.rb
388
390
  - app/components/primer/alpha/tab_panels.html.erb
389
391
  - app/components/primer/alpha/tab_panels.rb
392
+ - app/components/primer/alpha/tooltip.d.ts
393
+ - app/components/primer/alpha/tooltip.js
394
+ - app/components/primer/alpha/tooltip.rb
395
+ - app/components/primer/alpha/tooltip.ts
390
396
  - app/components/primer/alpha/underline_nav.html.erb
391
397
  - app/components/primer/alpha/underline_nav.rb
392
398
  - app/components/primer/alpha/underline_panels.html.erb
@@ -458,6 +464,7 @@ files:
458
464
  - app/components/primer/label_component.rb
459
465
  - app/components/primer/layout_component.html.erb
460
466
  - app/components/primer/layout_component.rb
467
+ - app/components/primer/link_component.erb
461
468
  - app/components/primer/link_component.rb
462
469
  - app/components/primer/local_time.d.ts
463
470
  - app/components/primer/local_time.js
@@ -573,7 +580,7 @@ licenses:
573
580
  - MIT
574
581
  metadata:
575
582
  allowed_push_host: https://rubygems.org
576
- post_install_message:
583
+ post_install_message:
577
584
  rdoc_options: []
578
585
  require_paths:
579
586
  - lib
@@ -588,8 +595,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
588
595
  - !ruby/object:Gem::Version
589
596
  version: '0'
590
597
  requirements: []
591
- rubygems_version: 3.1.6
592
- signing_key:
598
+ rubygems_version: 3.2.22
599
+ signing_key:
593
600
  specification_version: 4
594
601
  summary: ViewComponents for the Primer Design System
595
602
  test_files: []