primer_view_components 0.0.43 → 0.0.44

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +52 -4
  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/button_marketing.rb +70 -0
  6. data/app/components/primer/auto_complete.rb +97 -41
  7. data/app/components/primer/auto_complete/auto_complete.html.erb +1 -0
  8. data/app/components/primer/beta/text.rb +27 -0
  9. data/app/components/primer/blankslate_component.rb +2 -1
  10. data/app/components/primer/button_component.rb +3 -2
  11. data/app/components/primer/details_component.rb +12 -1
  12. data/app/components/primer/dropdown.d.ts +1 -0
  13. data/app/components/primer/{dropdown_component.html.erb → dropdown.html.erb} +2 -1
  14. data/app/components/primer/dropdown.js +1 -0
  15. data/app/components/primer/dropdown.rb +149 -0
  16. data/app/components/primer/dropdown.ts +1 -0
  17. data/app/components/primer/dropdown/menu.d.ts +1 -0
  18. data/app/components/primer/dropdown/menu.html.erb +25 -0
  19. data/app/components/primer/dropdown/menu.js +1 -0
  20. data/app/components/primer/dropdown/menu.rb +99 -0
  21. data/app/components/primer/dropdown/menu.ts +1 -0
  22. data/app/components/primer/heading_component.rb +1 -1
  23. data/app/components/primer/icon_button.rb +1 -1
  24. data/app/components/primer/navigation/tab_component.rb +2 -2
  25. data/app/components/primer/octicon_component.rb +3 -2
  26. data/app/components/primer/primer.d.ts +1 -0
  27. data/app/components/primer/primer.js +1 -0
  28. data/app/components/primer/primer.ts +1 -0
  29. data/app/components/primer/spinner_component.rb +2 -0
  30. data/lib/primer/view_components/linters/argument_mappers/button.rb +82 -0
  31. data/lib/primer/view_components/linters/argument_mappers/conversion_error.rb +10 -0
  32. data/lib/primer/view_components/linters/argument_mappers/system_arguments.rb +46 -0
  33. data/lib/primer/view_components/linters/button_component_migration_counter.rb +20 -1
  34. data/lib/primer/view_components/linters/flash_component_migration_counter.rb +1 -1
  35. data/lib/primer/view_components/linters/helpers.rb +7 -3
  36. data/lib/primer/view_components/version.rb +1 -1
  37. data/lib/tasks/docs.rake +111 -96
  38. data/lib/yard/docs_helper.rb +12 -2
  39. data/static/statuses.json +6 -4
  40. metadata +17 -8
  41. data/app/components/primer/button_marketing_component.rb +0 -68
  42. data/app/components/primer/dropdown/menu_component.html.erb +0 -12
  43. data/app/components/primer/dropdown/menu_component.rb +0 -46
  44. data/app/components/primer/dropdown_component.rb +0 -73
  45. data/app/components/primer/text_component.rb +0 -25
@@ -3,7 +3,13 @@
3
3
  module YARD
4
4
  # Helper methods to use for yard documentation
5
5
  module DocsHelper
6
- def one_of(enumerable, lower: false)
6
+ def one_of(enumerable, lower: false, sort: true)
7
+ # Sort the array if requested
8
+ if sort
9
+ compare = ->(a, b) { a.class == b.class ? a <=> b : a.class.to_s <=> b.class.to_s }
10
+ enumerable = enumerable.sort { |a, b| compare.call(a, b) }
11
+ end
12
+
7
13
  values =
8
14
  case enumerable
9
15
  when Hash
@@ -14,7 +20,7 @@ module YARD
14
20
  enumerable.map do |key|
15
21
  pretty_value(key)
16
22
  end
17
- end
23
+ end
18
24
 
19
25
  prefix = "One of"
20
26
  prefix = prefix.downcase if lower
@@ -22,6 +28,10 @@ module YARD
22
28
  "#{prefix} #{values.to_sentence(last_word_connector: ', or ')}."
23
29
  end
24
30
 
31
+ def link_to_accessibility
32
+ "[Accessibility](#system-arguments)"
33
+ end
34
+
25
35
  def link_to_system_arguments_docs
26
36
  "[System arguments](/system-arguments)"
27
37
  end
data/static/statuses.json CHANGED
@@ -1,10 +1,13 @@
1
1
  {
2
+ "Primer::Alpha::ButtonMarketing": "alpha",
2
3
  "Primer::AutoComplete": "beta",
4
+ "Primer::AutoComplete::Input": "alpha",
3
5
  "Primer::AutoComplete::Item": "beta",
4
6
  "Primer::AvatarComponent": "beta",
5
7
  "Primer::AvatarStackComponent": "beta",
6
8
  "Primer::BaseButton": "beta",
7
9
  "Primer::BaseComponent": "beta",
10
+ "Primer::Beta::Text": "beta",
8
11
  "Primer::BlankslateComponent": "beta",
9
12
  "Primer::BorderBoxComponent": "beta",
10
13
  "Primer::BoxComponent": "stable",
@@ -12,13 +15,13 @@
12
15
  "Primer::BreadcrumbComponent::ItemComponent": "alpha",
13
16
  "Primer::ButtonComponent": "beta",
14
17
  "Primer::ButtonGroup": "beta",
15
- "Primer::ButtonMarketingComponent": "alpha",
16
18
  "Primer::ClipboardCopy": "alpha",
17
19
  "Primer::CloseButton": "beta",
18
20
  "Primer::CounterComponent": "beta",
19
21
  "Primer::DetailsComponent": "beta",
20
- "Primer::Dropdown::MenuComponent": "alpha",
21
- "Primer::DropdownComponent": "alpha",
22
+ "Primer::Dropdown": "alpha",
23
+ "Primer::Dropdown::Menu": "alpha",
24
+ "Primer::Dropdown::Menu::Item": "alpha",
22
25
  "Primer::DropdownMenuComponent": "deprecated",
23
26
  "Primer::FlashComponent": "beta",
24
27
  "Primer::FlexComponent": "deprecated",
@@ -44,7 +47,6 @@
44
47
  "Primer::SubheadComponent": "beta",
45
48
  "Primer::TabContainerComponent": "alpha",
46
49
  "Primer::TabNavComponent": "beta",
47
- "Primer::TextComponent": "beta",
48
50
  "Primer::TimeAgoComponent": "beta",
49
51
  "Primer::TimelineItemComponent": "beta",
50
52
  "Primer::TimelineItemComponent::BadgeComponent": "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.43
4
+ version: 0.0.44
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-06-03 00:00:00.000000000 Z
11
+ date: 2021-06-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionview
@@ -350,6 +350,7 @@ files:
350
350
  - README.md
351
351
  - app/assets/javascripts/primer_view_components.js
352
352
  - app/assets/javascripts/primer_view_components.js.map
353
+ - app/components/primer/alpha/button_marketing.rb
353
354
  - app/components/primer/auto_complete.rb
354
355
  - app/components/primer/auto_complete/auto_complete.d.ts
355
356
  - app/components/primer/auto_complete/auto_complete.html.erb
@@ -363,6 +364,7 @@ files:
363
364
  - app/components/primer/avatar_stack_component.rb
364
365
  - app/components/primer/base_button.rb
365
366
  - app/components/primer/base_component.rb
367
+ - app/components/primer/beta/text.rb
366
368
  - app/components/primer/blankslate_component.html.erb
367
369
  - app/components/primer/blankslate_component.rb
368
370
  - app/components/primer/border_box_component.html.erb
@@ -374,7 +376,6 @@ files:
374
376
  - app/components/primer/button_component.rb
375
377
  - app/components/primer/button_group.html.erb
376
378
  - app/components/primer/button_group.rb
377
- - app/components/primer/button_marketing_component.rb
378
379
  - app/components/primer/clipboard_copy.html.erb
379
380
  - app/components/primer/clipboard_copy.rb
380
381
  - app/components/primer/clipboard_copy_component.d.ts
@@ -385,10 +386,16 @@ files:
385
386
  - app/components/primer/counter_component.rb
386
387
  - app/components/primer/details_component.html.erb
387
388
  - app/components/primer/details_component.rb
388
- - app/components/primer/dropdown/menu_component.html.erb
389
- - app/components/primer/dropdown/menu_component.rb
390
- - app/components/primer/dropdown_component.html.erb
391
- - app/components/primer/dropdown_component.rb
389
+ - app/components/primer/dropdown.d.ts
390
+ - app/components/primer/dropdown.html.erb
391
+ - app/components/primer/dropdown.js
392
+ - app/components/primer/dropdown.rb
393
+ - app/components/primer/dropdown.ts
394
+ - app/components/primer/dropdown/menu.d.ts
395
+ - app/components/primer/dropdown/menu.html.erb
396
+ - app/components/primer/dropdown/menu.js
397
+ - app/components/primer/dropdown/menu.rb
398
+ - app/components/primer/dropdown/menu.ts
392
399
  - app/components/primer/dropdown_menu_component.html.erb
393
400
  - app/components/primer/dropdown_menu_component.rb
394
401
  - app/components/primer/flash_component.html.erb
@@ -439,7 +446,6 @@ files:
439
446
  - app/components/primer/tab_container_component.ts
440
447
  - app/components/primer/tab_nav_component.html.erb
441
448
  - app/components/primer/tab_nav_component.rb
442
- - app/components/primer/text_component.rb
443
449
  - app/components/primer/time_ago_component.d.ts
444
450
  - app/components/primer/time_ago_component.js
445
451
  - app/components/primer/time_ago_component.rb
@@ -470,6 +476,9 @@ files:
470
476
  - lib/primer/view_components.rb
471
477
  - lib/primer/view_components/engine.rb
472
478
  - lib/primer/view_components/linters.rb
479
+ - lib/primer/view_components/linters/argument_mappers/button.rb
480
+ - lib/primer/view_components/linters/argument_mappers/conversion_error.rb
481
+ - lib/primer/view_components/linters/argument_mappers/system_arguments.rb
473
482
  - lib/primer/view_components/linters/button_component_migration_counter.rb
474
483
  - lib/primer/view_components/linters/flash_component_migration_counter.rb
475
484
  - lib/primer/view_components/linters/helpers.rb
@@ -1,68 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Primer
4
- # Use `ButtonMarketing` for actions (e.g. in forms). Use links for destinations, or moving from one page to another.
5
- class ButtonMarketingComponent < Primer::Component
6
- DEFAULT_SCHEME = :default
7
- SCHEME_MAPPINGS = {
8
- DEFAULT_SCHEME => "",
9
- :primary => "btn-primary-mktg",
10
- :outline => "btn-outline-mktg",
11
- :transparent => "btn-transparent"
12
- }.freeze
13
- SCHEME_OPTIONS = SCHEME_MAPPINGS.keys
14
-
15
- DEFAULT_VARIANT = :default
16
- VARIANT_MAPPINGS = {
17
- DEFAULT_VARIANT => "",
18
- :large => "btn-large-mktg"
19
- }.freeze
20
- VARIANT_OPTIONS = VARIANT_MAPPINGS.keys
21
-
22
- DEFAULT_TAG = :button
23
- TAG_OPTIONS = [DEFAULT_TAG, :a].freeze
24
-
25
- DEFAULT_TYPE = :button
26
- TYPE_OPTIONS = [DEFAULT_TYPE, :submit].freeze
27
-
28
- # @example Schemes
29
- # <%= render(Primer::ButtonMarketingComponent.new(mr: 2)) { "Default" } %>
30
- # <%= render(Primer::ButtonMarketingComponent.new(scheme: :primary, mr: 2)) { "Primary" } %>
31
- # <%= render(Primer::ButtonMarketingComponent.new(scheme: :outline)) { "Outline" } %>
32
- # <div class="color-bg-canvas-inverse">
33
- # <%= render(Primer::ButtonMarketingComponent.new(scheme: :transparent)) { "Transparent" } %>
34
- # </div>
35
- #
36
- # @example Sizes
37
- # <%= render(Primer::ButtonMarketingComponent.new(mr: 2)) { "Default" } %>
38
- # <%= render(Primer::ButtonMarketingComponent.new(variant: :large)) { "Large" } %>
39
- #
40
- # @param scheme [Symbol] <%= one_of(Primer::ButtonMarketingComponent::SCHEME_OPTIONS) %>
41
- # @param variant [Symbol] <%= one_of(Primer::ButtonMarketingComponent::VARIANT_OPTIONS) %>
42
- # @param tag [Symbol] <%= one_of(Primer::ButtonMarketingComponent::TAG_OPTIONS) %>
43
- # @param type [Symbol] <%= one_of(Primer::ButtonMarketingComponent::TYPE_OPTIONS) %>
44
- # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
45
- def initialize(
46
- scheme: DEFAULT_SCHEME,
47
- variant: DEFAULT_VARIANT,
48
- tag: DEFAULT_TAG,
49
- type: DEFAULT_TYPE,
50
- **system_arguments
51
- )
52
- @system_arguments = system_arguments
53
- @system_arguments[:block] = false
54
- @system_arguments[:tag] = fetch_or_fallback(TAG_OPTIONS, tag, DEFAULT_TAG)
55
- @system_arguments[:type] = fetch_or_fallback(TYPE_OPTIONS, type, DEFAULT_TYPE)
56
- @system_arguments[:classes] = class_names(
57
- "btn-mktg",
58
- SCHEME_MAPPINGS[fetch_or_fallback(SCHEME_OPTIONS, scheme, DEFAULT_SCHEME)],
59
- VARIANT_MAPPINGS[fetch_or_fallback(VARIANT_OPTIONS, variant, DEFAULT_VARIANT)],
60
- system_arguments[:classes]
61
- )
62
- end
63
-
64
- def call
65
- render(Primer::BaseButton.new(**@system_arguments)) { content }
66
- end
67
- end
68
- end
@@ -1,12 +0,0 @@
1
- <%= render Primer::BaseComponent.new(**@system_arguments) do %>
2
- <% if @header.present? %>
3
- <div class="dropdown-header">
4
- <%= @header %>
5
- </div>
6
- <% end %>
7
- <ul>
8
- <% items.each do |item| %>
9
- <%= item %>
10
- <% end %>
11
- </ul>
12
- <% end %>
@@ -1,46 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Primer
4
- module Dropdown
5
- # This component is part of `Dropdown` and should not be
6
- # used as a standalone component.
7
- class MenuComponent < Primer::Component
8
- SCHEME_DEFAULT = :default
9
- SCHEME_MAPPINGS = {
10
- SCHEME_DEFAULT => "",
11
- :dark => "dropdown-menu-dark"
12
- }.freeze
13
-
14
- DIRECTION_DEFAULT = :se
15
- DIRECTION_OPTIONS = [DIRECTION_DEFAULT, :sw, :w, :e, :ne, :s].freeze
16
-
17
- renders_many :items, lambda { |divider: false, **system_arguments|
18
- system_arguments[:tag] = :li
19
- system_arguments[:role] = :none if divider
20
- system_arguments[:classes] = class_names(
21
- system_arguments[:classes],
22
- "dropdown-item" => !divider,
23
- "dropdown-divider" => divider
24
- )
25
-
26
- Primer::BaseComponent.new(**system_arguments)
27
- }
28
-
29
- def initialize(direction: DIRECTION_DEFAULT, scheme: SCHEME_DEFAULT, header: nil, **system_arguments)
30
- @header = header
31
- @direction = direction
32
- @system_arguments = system_arguments
33
-
34
- @system_arguments[:tag] = "details-menu"
35
- @system_arguments[:role] = "menu"
36
-
37
- @system_arguments[:classes] = class_names(
38
- @system_arguments[:classes],
39
- "dropdown-menu",
40
- "dropdown-menu-#{fetch_or_fallback(DIRECTION_OPTIONS, direction, DIRECTION_DEFAULT)}",
41
- SCHEME_MAPPINGS[fetch_or_fallback(SCHEME_MAPPINGS.keys, scheme, SCHEME_DEFAULT)]
42
- )
43
- end
44
- end
45
- end
46
- end
@@ -1,73 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Primer
4
- # `Dropdown` is a lightweight context menu for housing navigation and actions.
5
- # They're great for instances where you don't need the full power (and code) of the select menu.
6
- class DropdownComponent < Primer::Component
7
- # Required trigger for the dropdown. Only accepts a content.
8
- # Its classes can be customized by the `summary_classes` param in the parent component
9
- renders_one :button
10
-
11
- # Required context menu for the dropdown
12
- #
13
- # @param direction [Symbol] <%= one_of(Primer::Dropdown::MenuComponent::DIRECTION_OPTIONS) %>
14
- # @param scheme [Symbol] Pass `:dark` for dark mode theming
15
- # @param header [String] Optional string to display as the header
16
- # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
17
- renders_one :menu, Primer::Dropdown::MenuComponent
18
-
19
- # @example Default
20
- # <div>
21
- # <%= render(Primer::DropdownComponent.new) do |c| %>
22
- # <% c.button do %>
23
- # Dropdown
24
- # <% end %>
25
- #
26
- # <%= c.menu(header: "Options") do |menu|
27
- # menu.item { "Item 1" }
28
- # menu.item { "Item 2" }
29
- # menu.item(divider: true)
30
- # menu.item { "Item 3" }
31
- # menu.item { "Item 4" }
32
- # end %>
33
- # <% end %>
34
- # </div>
35
- #
36
- # @example With Direction
37
- # <div>
38
- # <%= render(Primer::DropdownComponent.new) do |c| %>
39
- # <% c.button do %>
40
- # Dropdown
41
- # <% end %>
42
- #
43
- # <%= c.menu(header: "Options", direction: :s) do |menu|
44
- # menu.item { "Item 1" }
45
- # menu.item { "Item 2" }
46
- # menu.item(divider: true)
47
- # menu.item { "Item 3" }
48
- # menu.item { "Item 4" }
49
- # end %>
50
- # <% end %>
51
- # </div>
52
- #
53
- # @param overlay [Symbol] <%= one_of(Primer::DetailsComponent::OVERLAY_MAPPINGS.keys) %>
54
- # @param reset [Boolean] Whether to hide the default caret on the button
55
- # @param summary_classes [String] Custom classes to add to the button
56
- # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
57
- def initialize(overlay: :default, reset: true, summary_classes: "", **system_arguments)
58
- @system_arguments = system_arguments
59
- @system_arguments[:overlay] = overlay
60
- @system_arguments[:reset] = reset
61
- @system_arguments[:position] = :relative
62
- @system_arguments[:classes] = class_names(
63
- @system_arguments[:classes],
64
- "dropdown"
65
- )
66
- @summary_classes = summary_classes
67
- end
68
-
69
- def render?
70
- button.present? && menu.present?
71
- end
72
- end
73
- end
@@ -1,25 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Primer
4
- # `Text` is a wrapper component that will apply typography styles to the text inside.
5
- class TextComponent < Primer::Component
6
- status :beta
7
-
8
- DEFAULT_TAG = :span
9
-
10
- # @example Default
11
- # <%= render(Primer::TextComponent.new(tag: :p, font_weight: :bold)) { "Bold Text" } %>
12
- # <%= render(Primer::TextComponent.new(tag: :p, color: :text_danger)) { "Danger Text" } %>
13
- #
14
- # @param tag [Symbol]
15
- # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
16
- def initialize(tag: DEFAULT_TAG, **system_arguments)
17
- @system_arguments = system_arguments
18
- @system_arguments[:tag] = tag
19
- end
20
-
21
- def call
22
- render(Primer::BaseComponent.new(**@system_arguments)) { content }
23
- end
24
- end
25
- end