primer_view_components 0.0.48 → 0.0.49

Sign up to get free protection for your applications and to get access to all the features.
Files changed (34) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +43 -0
  3. data/app/components/primer/beta/avatar.rb +1 -1
  4. data/app/components/primer/{avatar_stack_component.html.erb → beta/avatar_stack.html.erb} +0 -0
  5. data/app/components/primer/beta/avatar_stack.rb +92 -0
  6. data/app/components/primer/image_crop.html.erb +4 -4
  7. data/app/components/primer/navigation/tab_component.rb +15 -1
  8. data/app/components/primer/tab_nav_component.rb +4 -3
  9. data/app/components/primer/truncate.rb +1 -1
  10. data/app/components/primer/underline_nav_component.rb +3 -2
  11. data/lib/primer/classify/utilities.rb +33 -12
  12. data/lib/primer/view_components.rb +34 -6
  13. data/lib/primer/view_components/constants.rb +55 -0
  14. data/lib/primer/view_components/linters/argument_mappers/base.rb +39 -0
  15. data/lib/primer/view_components/linters/argument_mappers/button.rb +35 -44
  16. data/lib/primer/view_components/linters/argument_mappers/clipboard_copy.rb +25 -0
  17. data/lib/primer/view_components/linters/argument_mappers/label.rb +56 -0
  18. data/lib/primer/view_components/linters/autocorrectable.rb +30 -0
  19. data/lib/primer/view_components/linters/button_component_migration_counter.rb +9 -23
  20. data/lib/primer/view_components/linters/clipboard_copy_component_migration_counter.rb +21 -0
  21. data/lib/primer/view_components/linters/helpers.rb +42 -41
  22. data/lib/primer/view_components/linters/label_component_migration_counter.rb +25 -0
  23. data/lib/primer/view_components/version.rb +1 -1
  24. data/lib/tasks/constants.rake +12 -0
  25. data/lib/tasks/docs.rake +24 -23
  26. data/lib/tasks/utilities.rake +2 -10
  27. data/lib/yard/docs_helper.rb +12 -3
  28. data/static/arguments.yml +977 -0
  29. data/static/assets/view-components.svg +18 -0
  30. data/static/classes.yml +174 -0
  31. data/static/constants.json +628 -0
  32. data/static/statuses.json +1 -1
  33. metadata +16 -4
  34. data/app/components/primer/avatar_stack_component.rb +0 -90
data/static/statuses.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "Primer::Alpha::ButtonMarketing": "alpha",
3
- "Primer::AvatarStackComponent": "beta",
4
3
  "Primer::BaseButton": "beta",
5
4
  "Primer::BaseComponent": "beta",
6
5
  "Primer::Beta::AutoComplete": "beta",
7
6
  "Primer::Beta::AutoComplete::Input": "alpha",
8
7
  "Primer::Beta::AutoComplete::Item": "beta",
9
8
  "Primer::Beta::Avatar": "beta",
9
+ "Primer::Beta::AvatarStack": "beta",
10
10
  "Primer::Beta::Text": "beta",
11
11
  "Primer::BlankslateComponent": "beta",
12
12
  "Primer::BorderBoxComponent": "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.48
4
+ version: 0.0.49
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-07-21 00:00:00.000000000 Z
11
+ date: 2021-07-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionview
@@ -355,8 +355,6 @@ files:
355
355
  - app/components/primer/auto_complete/auto_complete.js
356
356
  - app/components/primer/auto_complete/auto_component.d.ts
357
357
  - app/components/primer/auto_complete/auto_component.js
358
- - app/components/primer/avatar_stack_component.html.erb
359
- - app/components/primer/avatar_stack_component.rb
360
358
  - app/components/primer/base_button.rb
361
359
  - app/components/primer/base_component.rb
362
360
  - app/components/primer/beta/auto_complete.rb
@@ -366,6 +364,8 @@ files:
366
364
  - app/components/primer/beta/auto_complete/auto_complete.ts
367
365
  - app/components/primer/beta/auto_complete/item.rb
368
366
  - app/components/primer/beta/avatar.rb
367
+ - app/components/primer/beta/avatar_stack.html.erb
368
+ - app/components/primer/beta/avatar_stack.rb
369
369
  - app/components/primer/beta/text.rb
370
370
  - app/components/primer/blankslate_component.html.erb
371
371
  - app/components/primer/blankslate_component.rb
@@ -477,20 +477,28 @@ files:
477
477
  - lib/primer/classify/utilities.rb
478
478
  - lib/primer/classify/utilities.yml
479
479
  - lib/primer/view_components.rb
480
+ - lib/primer/view_components/constants.rb
480
481
  - lib/primer/view_components/engine.rb
481
482
  - lib/primer/view_components/linters.rb
483
+ - lib/primer/view_components/linters/argument_mappers/base.rb
482
484
  - lib/primer/view_components/linters/argument_mappers/button.rb
485
+ - lib/primer/view_components/linters/argument_mappers/clipboard_copy.rb
483
486
  - lib/primer/view_components/linters/argument_mappers/conversion_error.rb
487
+ - lib/primer/view_components/linters/argument_mappers/label.rb
484
488
  - lib/primer/view_components/linters/argument_mappers/system_arguments.rb
489
+ - lib/primer/view_components/linters/autocorrectable.rb
485
490
  - lib/primer/view_components/linters/button_component_migration_counter.rb
491
+ - lib/primer/view_components/linters/clipboard_copy_component_migration_counter.rb
486
492
  - lib/primer/view_components/linters/flash_component_migration_counter.rb
487
493
  - lib/primer/view_components/linters/helpers.rb
494
+ - lib/primer/view_components/linters/label_component_migration_counter.rb
488
495
  - lib/primer/view_components/statuses.rb
489
496
  - lib/primer/view_components/version.rb
490
497
  - lib/rubocop/config/default.yml
491
498
  - lib/rubocop/cop/primer.rb
492
499
  - lib/rubocop/cop/primer/no_tag_memoize.rb
493
500
  - lib/rubocop/cop/primer/system_argument_instead_of_class.rb
501
+ - lib/tasks/constants.rake
494
502
  - lib/tasks/coverage.rake
495
503
  - lib/tasks/docs.rake
496
504
  - lib/tasks/statuses.rake
@@ -498,6 +506,10 @@ files:
498
506
  - lib/yard/docs_helper.rb
499
507
  - lib/yard/renders_many_handler.rb
500
508
  - lib/yard/renders_one_handler.rb
509
+ - static/arguments.yml
510
+ - static/assets/view-components.svg
511
+ - static/classes.yml
512
+ - static/constants.json
501
513
  - static/statuses.json
502
514
  homepage: https://github.com/primer/view_components
503
515
  licenses:
@@ -1,90 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Primer
4
- # Use `AvatarStack` to stack multiple avatars together.
5
- class AvatarStackComponent < Primer::Component
6
- status :beta
7
-
8
- ALIGN_DEFAULT = :left
9
- ALIGN_OPTIONS = [ALIGN_DEFAULT, :right].freeze
10
-
11
- DEFAULT_TAG = :div
12
- TAG_OPTIONS = [DEFAULT_TAG, :span].freeze
13
-
14
- DEFAULT_BODY_TAG = :div
15
- BODY_TAG_OPTIONS = [DEFAULT_BODY_TAG, :span].freeze
16
- # Required list of stacked avatars.
17
- #
18
- # @param kwargs [Hash] The same arguments as <%= link_to_component(Primer::Beta::Avatar) %>.
19
- renders_many :avatars, "Primer::Beta::Avatar"
20
-
21
- # @example Default
22
- # <%= render(Primer::AvatarStackComponent.new) do |c| %>
23
- # <%= c.avatar(src: "http://placekitten.com/200/200", alt: "@kittenuser") %>
24
- # <%= c.avatar(src: "http://placekitten.com/200/200", alt: "@kittenuser") %>
25
- # <%= c.avatar(src: "http://placekitten.com/200/200", alt: "@kittenuser") %>
26
- # <% end %>
27
- #
28
- # @example Align right
29
- # <%= render(Primer::AvatarStackComponent.new(align: :right)) do |c| %>
30
- # <%= c.avatar(src: "http://placekitten.com/200/200", alt: "@kittenuser") %>
31
- # <%= c.avatar(src: "http://placekitten.com/200/200", alt: "@kittenuser") %>
32
- # <%= c.avatar(src: "http://placekitten.com/200/200", alt: "@kittenuser") %>
33
- # <% end %>
34
- #
35
- # @example With tooltip
36
- # <%= render(Primer::AvatarStackComponent.new(tooltipped: true, body_arguments: { label: 'This is a tooltip!' })) do |c| %>
37
- # <%= c.avatar(src: "http://placekitten.com/200/200", alt: "@kittenuser") %>
38
- # <%= c.avatar(src: "http://placekitten.com/200/200", alt: "@kittenuser") %>
39
- # <%= c.avatar(src: "http://placekitten.com/200/200", alt: "@kittenuser") %>
40
- # <% end %>
41
- #
42
- # @param tag [Symbol] <%= one_of(Primer::AvatarStackComponent::TAG_OPTIONS) %>
43
- # @param align [Symbol] <%= one_of(Primer::AvatarStackComponent::ALIGN_OPTIONS) %>
44
- # @param tooltipped [Boolean] Whether to add a tooltip to the stack or not.
45
- # @param body_arguments [Hash] Parameters to add to the Body. If `tooltipped` is set, has the same arguments as <%= link_to_component(Primer::Tooltip) %>.
46
- # The default tag is <%= pretty_value(Primer::AvatarStackComponent::DEFAULT_BODY_TAG) %> but can be changed using `tag:`
47
- # to <%= one_of(Primer::AvatarStackComponent::BODY_TAG_OPTIONS, lower: true) %>
48
- # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
49
- def initialize(tag: DEFAULT_TAG, align: ALIGN_DEFAULT, tooltipped: false, body_arguments: {}, **system_arguments)
50
- @align = fetch_or_fallback(ALIGN_OPTIONS, align, ALIGN_DEFAULT)
51
- @system_arguments = system_arguments
52
- @tooltipped = tooltipped
53
- @body_arguments = body_arguments
54
-
55
- body_tag = @body_arguments[:tag] || DEFAULT_BODY_TAG
56
- @body_arguments[:tag] = fetch_or_fallback(BODY_TAG_OPTIONS, body_tag, DEFAULT_BODY_TAG)
57
- @body_arguments[:classes] = class_names(
58
- "AvatarStack-body",
59
- @body_arguments[:classes]
60
- )
61
-
62
- @system_arguments[:tag] = fetch_or_fallback(TAG_OPTIONS, tag, DEFAULT_TAG)
63
- @system_arguments[:classes] = class_names(
64
- "AvatarStack",
65
- system_arguments[:classes],
66
- "AvatarStack--right" => @align == :right
67
- )
68
- end
69
-
70
- def body_component
71
- if @tooltipped
72
- Primer::Tooltip.new(**@body_arguments)
73
- else
74
- Primer::BaseComponent.new(**@body_arguments)
75
- end
76
- end
77
-
78
- def before_render
79
- @system_arguments[:classes] = class_names(
80
- @system_arguments[:classes],
81
- "AvatarStack--two" => avatars.size == 2,
82
- "AvatarStack--three-plus" => avatars.size > 2
83
- )
84
- end
85
-
86
- def render?
87
- avatars.any?
88
- end
89
- end
90
- end