primer_view_components 0.0.63 → 0.0.67

Sign up to get free protection for your applications and to get access to all the features.
Files changed (36) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +718 -641
  3. data/app/components/primer/auto_complete/auto_complete.d.ts +1 -0
  4. data/app/components/primer/auto_complete/auto_complete.js +1 -0
  5. data/app/components/primer/beta/blankslate.rb +5 -3
  6. data/app/components/primer/button_component.html.erb +1 -1
  7. data/app/components/primer/button_component.rb +12 -10
  8. data/app/components/primer/button_group.rb +8 -7
  9. data/app/components/primer/component.rb +9 -4
  10. data/app/components/primer/content.rb +12 -0
  11. data/app/components/primer/dropdown.rb +3 -3
  12. data/app/components/primer/flash_component.rb +1 -1
  13. data/app/components/primer/image.rb +2 -2
  14. data/app/components/primer/label_component.rb +23 -13
  15. data/app/components/primer/octicon_component.rb +4 -2
  16. data/app/components/primer/popover_component.rb +10 -11
  17. data/app/components/primer/spinner_component.html.erb +2 -13
  18. data/app/components/primer/spinner_component.rb +6 -5
  19. data/app/lib/primer/octicon/cache.rb +4 -10
  20. data/lib/primer/classify/utilities.rb +0 -1
  21. data/lib/primer/classify/utilities.yml +98 -0
  22. data/lib/primer/classify.rb +1 -1
  23. data/lib/primer/view_components/engine.rb +1 -0
  24. data/lib/primer/view_components/linters/argument_mappers/button.rb +4 -4
  25. data/lib/primer/view_components/version.rb +1 -1
  26. data/lib/rubocop/cop/primer/deprecated_arguments.rb +1 -1
  27. data/lib/rubocop/cop/primer/deprecated_button_arguments.rb +51 -0
  28. data/lib/rubocop/cop/primer/deprecated_label_schemes.rb +68 -0
  29. data/lib/tasks/custom_utilities.yml +98 -0
  30. data/lib/tasks/docs.rake +9 -4
  31. data/static/arguments.yml +12 -3
  32. data/static/audited_at.json +1 -0
  33. data/static/classes.yml +5 -4
  34. data/static/constants.json +22 -8
  35. data/static/statuses.json +1 -0
  36. metadata +10 -5
@@ -0,0 +1,51 @@
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 `ButtonComponent` doesn't use deprecated arguments.
10
+ #
11
+ # bad
12
+ # ButtonComponent.new(variant: :small)
13
+ #
14
+ # good
15
+ # ButtonComponent.new(size: :small)
16
+ class DeprecatedButtonArguments < BaseCop
17
+ INVALID_MESSAGE = <<~STR
18
+ `variant` is deprecated. Use `size` instead.
19
+ STR
20
+
21
+ def_node_matcher :button_component?, <<~PATTERN
22
+ (send (const (const nil? :Primer) :ButtonComponent) :new ...)
23
+ PATTERN
24
+
25
+ DEPRECATIONS = {
26
+ variant: :size
27
+ }.freeze
28
+
29
+ def on_send(node)
30
+ return unless button_component?(node)
31
+
32
+ kwargs = node.arguments.last
33
+
34
+ return if kwargs.nil?
35
+
36
+ pair = kwargs.pairs.find { |x| x.key.value == :variant }
37
+
38
+ return if pair.nil?
39
+
40
+ add_offense(pair.key, message: INVALID_MESSAGE)
41
+ end
42
+
43
+ def autocorrect(node)
44
+ lambda do |corrector|
45
+ corrector.replace(node, DEPRECATIONS[node.value])
46
+ end
47
+ end
48
+ end
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,68 @@
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 `Label` schemes.
10
+ #
11
+ # bad
12
+ # Primer::LabelComponent.new(scheme: :info)
13
+ #
14
+ # good
15
+ # Primer::LabelComponent.new(scheme: :accent)
16
+ class DeprecatedLabelSchemes < BaseCop
17
+ INVALID_MESSAGE = <<~STR
18
+ Avoid using deprecated schemes: https://primer.style/view-components/deprecated#labelcomponent.
19
+ STR
20
+
21
+ # This is a hash of deprecated schemes and their replacements.
22
+ DEPRECATIONS = {
23
+ info: ":accent",
24
+ warning: ":attention",
25
+ orange: ":severe",
26
+ purple: ":done"
27
+ }.freeze
28
+
29
+ def on_send(node)
30
+ return unless label_node?(node)
31
+ return unless node.arguments?
32
+
33
+ # we are looking for hash arguments and they are always last
34
+ kwargs = node.arguments.last
35
+
36
+ return unless kwargs.type == :hash
37
+
38
+ kwargs.pairs.each do |pair|
39
+ # Skip if we're not dealing with a symbol
40
+ next if pair.key.type != :sym
41
+ next unless pair.value.type == :sym || pair.value.type == :str
42
+
43
+ value = pair.value.value.to_sym
44
+
45
+ next unless DEPRECATIONS.key?(value)
46
+
47
+ add_offense(pair.value, message: INVALID_MESSAGE)
48
+ end
49
+ end
50
+
51
+ def autocorrect(node)
52
+ lambda do |corrector|
53
+ replacement = DEPRECATIONS[node.value.to_sym]
54
+ corrector.replace(node, replacement)
55
+ end
56
+ end
57
+
58
+ private
59
+
60
+ def label_node?(node)
61
+ return if node.nil?
62
+
63
+ node.method_name == :new && !node.receiver.nil? && node.receiver.const_name == "Primer::LabelComponent"
64
+ end
65
+ end
66
+ end
67
+ end
68
+ end
@@ -99,6 +99,12 @@
99
99
  - border-x
100
100
  true:
101
101
  - border
102
+ 0:
103
+ - border-0
104
+ false:
105
+ - border-0
106
+ :dashed:
107
+ - border-dashed
102
108
  :border_top:
103
109
  0:
104
110
  - border-top-0
@@ -123,32 +129,84 @@
123
129
  :justify_content:
124
130
  :flex_start:
125
131
  - flex-justify-start
132
+ - flex-sm-justify-start
133
+ - flex-md-justify-start
134
+ - flex-lg-justify-start
135
+ - flex-xl-justify-start
126
136
  :flex_end:
127
137
  - flex-justify-end
138
+ - flex-sm-justify-end
139
+ - flex-md-justify-end
140
+ - flex-lg-justify-end
141
+ - flex-xl-justify-end
128
142
  :center:
129
143
  - flex-justify-center
144
+ - flex-sm-justify-center
145
+ - flex-md-justify-center
146
+ - flex-lg-justify-center
147
+ - flex-xl-justify-center
130
148
  :space_between:
131
149
  - flex-justify-between
150
+ - flex-sm-justify-between
151
+ - flex-md-justify-between
152
+ - flex-lg-justify-between
153
+ - flex-xl-justify-between
132
154
  :space_around:
133
155
  - flex-justify-around
156
+ - flex-sm-justify-around
157
+ - flex-md-justify-around
158
+ - flex-lg-justify-around
159
+ - flex-xl-justify-around
134
160
  :align_items:
135
161
  :flex_start:
136
162
  - flex-items-start
163
+ - flex-sm-items-start
164
+ - flex-md-items-start
165
+ - flex-lg-items-start
166
+ - flex-xl-items-start
137
167
  :flex_end:
138
168
  - flex-items-end
169
+ - flex-sm-items-end
170
+ - flex-md-items-end
171
+ - flex-lg-items-end
172
+ - flex-xl-items-end
139
173
  :center:
140
174
  - flex-items-center
175
+ - flex-sm-items-center
176
+ - flex-md-items-center
177
+ - flex-lg-items-center
178
+ - flex-xl-items-center
141
179
  :baseline:
142
180
  - flex-items-baseline
181
+ - flex-sm-items-baseline
182
+ - flex-md-items-baseline
183
+ - flex-lg-items-baseline
184
+ - flex-xl-items-baseline
143
185
  :stretch:
144
186
  - flex-items-stretch
187
+ - flex-sm-items-stretch
188
+ - flex-md-items-stretch
189
+ - flex-lg-items-stretch
190
+ - flex-xl-items-stretch
145
191
  :flex_wrap:
146
192
  :wrap:
147
193
  - flex-wrap
194
+ - flex-sm-wrap
195
+ - flex-md-wrap
196
+ - flex-lg-wrap
197
+ - flex-xl-wrap
148
198
  :nowrap:
149
199
  - flex-nowrap
200
+ - flex-sm-nowrap
201
+ - flex-md-nowrap
202
+ - flex-lg-nowrap
203
+ - flex-xl-nowrap
150
204
  :reverse:
151
205
  - flex-wrap-reverse
206
+ - flex-sm-wrap-reverse
207
+ - flex-md-wrap-reverse
208
+ - flex-lg-wrap-reverse
209
+ - flex-xl-wrap-reverse
152
210
  :direction:
153
211
  :column:
154
212
  - flex-column
@@ -177,24 +235,64 @@
177
235
  :flex:
178
236
  1:
179
237
  - flex-1
238
+ - flex-sm-1
239
+ - flex-md-1
240
+ - flex-lg-1
241
+ - flex-xl-1
180
242
  :auto:
181
243
  - flex-auto
244
+ - flex-sm-auto
245
+ - flex-md-auto
246
+ - flex-lg-auto
247
+ - flex-xl-auto
182
248
  :align_self:
183
249
  :auto:
184
250
  - flex-self-auto
251
+ - flex-sm-self-auto
252
+ - flex-md-self-auto
253
+ - flex-lg-self-auto
254
+ - flex-xl-self-auto
185
255
  :start:
186
256
  - flex-self-start
257
+ - flex-sm-self-start
258
+ - flex-md-self-start
259
+ - flex-lg-self-start
260
+ - flex-xl-self-start
187
261
  :end:
188
262
  - flex-self-end
263
+ - flex-sm-self-end
264
+ - flex-md-self-end
265
+ - flex-lg-self-end
266
+ - flex-xl-self-end
189
267
  :center:
190
268
  - flex-self-center
269
+ - flex-sm-self-center
270
+ - flex-md-self-center
271
+ - flex-lg-self-center
272
+ - flex-xl-self-center
191
273
  :baseline:
192
274
  - flex-self-baseline
275
+ - flex-sm-self-baseline
276
+ - flex-md-self-baseline
277
+ - flex-lg-self-baseline
278
+ - flex-xl-self-baseline
193
279
  :stretch:
194
280
  - flex-self-stretch
281
+ - flex-sm-self-stretch
282
+ - flex-md-self-stretch
283
+ - flex-lg-self-stretch
284
+ - flex-xl-self-stretch
195
285
  :flex_grow:
196
286
  0:
197
287
  - flex-grow-0
288
+ - flex-sm-grow-0
289
+ - flex-md-grow-0
290
+ - flex-lg-grow-0
291
+ - flex-xl-grow-0
198
292
  :flex_shrink:
199
293
  0:
200
294
  - flex-shrink-0
295
+ - flex-sm-shrink-0
296
+ - flex-md-shrink-0
297
+ - flex-lg-shrink-0
298
+ - flex-xl-shrink-0
data/lib/tasks/docs.rake CHANGED
@@ -315,7 +315,6 @@ namespace :docs do
315
315
  nav_entries = Dir[File.join(*%w[adr *.md])].sort.map do |orig_path|
316
316
  orig_file_name = File.basename(orig_path)
317
317
  url_name = orig_file_name.chomp(".md")
318
- title = ActiveSupport::Inflector.titleize(url_name.sub(/\A\d+-/, ""))
319
318
 
320
319
  file_contents = File.read(orig_path)
321
320
  file_contents = <<~CONTENTS.sub(/\n+\z/, "\n")
@@ -323,6 +322,12 @@ namespace :docs do
323
322
  #{file_contents}
324
323
  CONTENTS
325
324
 
325
+ title_match = /^# (.+)/.match(file_contents)
326
+ title = title_match[1]
327
+
328
+ # Don't include initial ADR for recording ADRs
329
+ next nil if title == "Record architecture decisions"
330
+
326
331
  File.write(File.join(adr_content_dir, orig_file_name), file_contents)
327
332
  puts "Copied #{orig_path}"
328
333
 
@@ -332,9 +337,9 @@ namespace :docs do
332
337
  nav_yaml_file = File.join(*%w[docs src @primer gatsby-theme-doctocat nav.yml])
333
338
  nav_yaml = YAML.load_file(nav_yaml_file)
334
339
  adr_entry = {
335
- "title" => "Architecture Decisions",
340
+ "title" => "Architecture decisions",
336
341
  "url" => "/adr",
337
- "children" => nav_entries
342
+ "children" => nav_entries.compact
338
343
  }
339
344
 
340
345
  existing_index = nav_yaml.index { |entry| entry["url"] == "/adr" }
@@ -360,7 +365,7 @@ namespace :docs do
360
365
  short_name = component.name.gsub(/Primer|::/, "")
361
366
  initialize_method = documentation.meths.find(&:constructor?)
362
367
 
363
- next unless initialize_method.tags(:example).any?
368
+ next unless initialize_method&.tags(:example)&.any?
364
369
 
365
370
  yard_example_tags = initialize_method.tags(:example)
366
371
 
data/static/arguments.yml CHANGED
@@ -324,6 +324,10 @@
324
324
  description: One of `:danger`, `:default`, `:invisible`, `:link`, `:outline`,
325
325
  or `:primary`.
326
326
  - name: variant
327
+ type: Symbol
328
+ default: "`nil`"
329
+ description: DEPRECATED. One of `:medium` and `:small`.
330
+ - name: size
327
331
  type: Symbol
328
332
  default: "`:medium`"
329
333
  description: One of `:medium` and `:small`.
@@ -355,6 +359,10 @@
355
359
  source: https://github.com/primer/view_components/tree/main/app/components/primer/button_group.rb
356
360
  parameters:
357
361
  - name: variant
362
+ type: Symbol
363
+ default: "`nil`"
364
+ description: DEPRECATED. One of `:medium` and `:small`.
365
+ - name: size
358
366
  type: Symbol
359
367
  default: "`:medium`"
360
368
  description: One of `:medium` and `:small`.
@@ -655,9 +663,10 @@
655
663
  description: One of `:a`, `:div`, `:span`, or `:summary`.
656
664
  - name: scheme
657
665
  type: Symbol
658
- default: "`nil`"
659
- description: One of `:danger`, `:info`, `:orange`, `:primary`, `:purple`, `:secondary`,
660
- `:success`, or `:warning`.
666
+ default: "`:default`"
667
+ description: One of `:accent`, `:attention`, `:danger`, `:default`, `:done`, `:info`,
668
+ `:orange`, `:primary`, `:purple`, `:secondary`, `:severe`, `:sponsors`, `:success`,
669
+ or `:warning`.
661
670
  - name: variant
662
671
  type: Symbol
663
672
  default: "`nil`"
@@ -28,6 +28,7 @@
28
28
  "Primer::ButtonGroup": "",
29
29
  "Primer::ClipboardCopy": "",
30
30
  "Primer::CloseButton": "",
31
+ "Primer::Content": "",
31
32
  "Primer::CounterComponent": "",
32
33
  "Primer::DetailsComponent": "",
33
34
  "Primer::Dropdown": "",
data/static/classes.yml CHANGED
@@ -20,13 +20,16 @@
20
20
  - ".Counter--primary"
21
21
  - ".Counter--secondary"
22
22
  - ".Label"
23
+ - ".Label--accent"
24
+ - ".Label--attention"
23
25
  - ".Label--danger"
24
- - ".Label--info"
26
+ - ".Label--done"
25
27
  - ".Label--large"
26
28
  - ".Label--primary"
27
29
  - ".Label--secondary"
30
+ - ".Label--severe"
31
+ - ".Label--sponsors"
28
32
  - ".Label--success"
29
- - ".Label--warning"
30
33
  - ".Layout"
31
34
  - ".Layout--flowRow-until-lg"
32
35
  - ".Layout--flowRow-until-md"
@@ -191,7 +194,6 @@
191
194
  - ".pr-2"
192
195
  - ".pt-5"
193
196
  - ".right-0"
194
- - ".sr-only"
195
197
  - ".tabnav"
196
198
  - ".tabnav-tab"
197
199
  - ".tabnav-tabs"
@@ -202,4 +204,3 @@
202
204
  - ".tooltipped-n"
203
205
  - ".tooltipped-no-delay"
204
206
  - ".tooltipped-s"
205
- - ".v-align-bottom"
@@ -279,7 +279,7 @@
279
279
  },
280
280
  "Primer::ButtonComponent": {
281
281
  "DEFAULT_SCHEME": "default",
282
- "DEFAULT_VARIANT": "medium",
282
+ "DEFAULT_SIZE": "medium",
283
283
  "LINK_SCHEME": "link",
284
284
  "SCHEME_MAPPINGS": {
285
285
  "default": "",
@@ -297,11 +297,11 @@
297
297
  "invisible",
298
298
  "link"
299
299
  ],
300
- "VARIANT_MAPPINGS": {
300
+ "SIZE_MAPPINGS": {
301
301
  "small": "btn-sm",
302
302
  "medium": ""
303
303
  },
304
- "VARIANT_OPTIONS": [
304
+ "SIZE_OPTIONS": [
305
305
  "small",
306
306
  "medium"
307
307
  ]
@@ -317,6 +317,8 @@
317
317
  "submit"
318
318
  ]
319
319
  },
320
+ "Primer::Content": {
321
+ },
320
322
  "Primer::CounterComponent": {
321
323
  "DEFAULT_SCHEME": "default",
322
324
  "DEPRECATED_SCHEME_OPTIONS": [
@@ -504,29 +506,41 @@
504
506
  "Primer::ImageCrop": {
505
507
  },
506
508
  "Primer::LabelComponent": {
509
+ "DEFAULT_SCHEME": "default",
507
510
  "DEFAULT_TAG": "span",
508
511
  "DEPRECATED_SCHEME_OPTIONS": [
512
+ "info",
513
+ "warning",
509
514
  "orange",
510
515
  "purple"
511
516
  ],
512
517
  "SCHEME_MAPPINGS": {
518
+ "default": "",
513
519
  "primary": "Label--primary",
514
520
  "secondary": "Label--secondary",
515
- "info": "Label--info",
521
+ "accent": "Label--accent",
516
522
  "success": "Label--success",
517
- "warning": "Label--warning",
523
+ "attention": "Label--attention",
518
524
  "danger": "Label--danger",
525
+ "severe": "Label--severe",
526
+ "done": "Label--done",
527
+ "sponsors": "Label--sponsors",
528
+ "info": "Label--info",
529
+ "warning": "Label--warning",
519
530
  "orange": "Label--orange",
520
531
  "purple": "Label--purple"
521
532
  },
522
533
  "SCHEME_OPTIONS": [
534
+ "default",
523
535
  "primary",
524
536
  "secondary",
525
- "info",
537
+ "accent",
526
538
  "success",
527
- "warning",
539
+ "attention",
528
540
  "danger",
529
- null
541
+ "severe",
542
+ "done",
543
+ "sponsors"
530
544
  ],
531
545
  "TAG_OPTIONS": [
532
546
  "span",
data/static/statuses.json CHANGED
@@ -28,6 +28,7 @@
28
28
  "Primer::ButtonGroup": "beta",
29
29
  "Primer::ClipboardCopy": "beta",
30
30
  "Primer::CloseButton": "beta",
31
+ "Primer::Content": "stable",
31
32
  "Primer::CounterComponent": "beta",
32
33
  "Primer::DetailsComponent": "beta",
33
34
  "Primer::Dropdown": "alpha",
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.63
4
+ version: 0.0.67
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: 2021-12-03 00:00:00.000000000 Z
11
+ date: 2022-01-25 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: '15'
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: '15'
54
+ version: '16'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: view_component
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -391,6 +391,8 @@ files:
391
391
  - app/components/primer/alpha/underline_nav.rb
392
392
  - app/components/primer/alpha/underline_panels.html.erb
393
393
  - app/components/primer/alpha/underline_panels.rb
394
+ - app/components/primer/auto_complete/auto_complete.d.ts
395
+ - app/components/primer/auto_complete/auto_complete.js
394
396
  - app/components/primer/base_button.rb
395
397
  - app/components/primer/base_component.rb
396
398
  - app/components/primer/beta/auto_complete.rb
@@ -425,6 +427,7 @@ files:
425
427
  - app/components/primer/clipboard_copy_component.ts
426
428
  - app/components/primer/close_button.rb
427
429
  - app/components/primer/component.rb
430
+ - app/components/primer/content.rb
428
431
  - app/components/primer/counter_component.rb
429
432
  - app/components/primer/details_component.html.erb
430
433
  - app/components/primer/details_component.rb
@@ -543,6 +546,8 @@ files:
543
546
  - lib/rubocop/cop/primer.rb
544
547
  - lib/rubocop/cop/primer/base_cop.rb
545
548
  - lib/rubocop/cop/primer/deprecated_arguments.rb
549
+ - lib/rubocop/cop/primer/deprecated_button_arguments.rb
550
+ - lib/rubocop/cop/primer/deprecated_label_schemes.rb
546
551
  - lib/rubocop/cop/primer/deprecated_layout_component.rb
547
552
  - lib/rubocop/cop/primer/no_tag_memoize.rb
548
553
  - lib/rubocop/cop/primer/primer_octicon.rb
@@ -584,7 +589,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
584
589
  - !ruby/object:Gem::Version
585
590
  version: '0'
586
591
  requirements: []
587
- rubygems_version: 3.1.6
592
+ rubygems_version: 3.1.2
588
593
  signing_key:
589
594
  specification_version: 4
590
595
  summary: ViewComponents for the Primer Design System