primer_view_components 0.0.41 → 0.0.46

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (79) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +265 -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/button_marketing.rb +70 -0
  6. data/app/components/primer/auto_complete.rb +99 -42
  7. data/app/components/primer/auto_complete/auto_complete.html.erb +1 -0
  8. data/app/components/primer/avatar_stack_component.rb +7 -1
  9. data/app/components/primer/base_component.rb +62 -26
  10. data/app/components/primer/beta/text.rb +27 -0
  11. data/app/components/primer/blankslate_component.html.erb +1 -0
  12. data/app/components/primer/blankslate_component.rb +64 -45
  13. data/app/components/primer/border_box_component.rb +3 -0
  14. data/app/components/primer/button_component.rb +3 -2
  15. data/app/components/primer/button_group.rb +1 -1
  16. data/app/components/primer/clipboard_copy.rb +25 -7
  17. data/app/components/primer/component.rb +5 -1
  18. data/app/components/primer/details_component.rb +18 -3
  19. data/app/components/primer/dropdown.d.ts +1 -0
  20. data/app/components/primer/{dropdown_component.html.erb → dropdown.html.erb} +2 -1
  21. data/app/components/primer/dropdown.js +1 -0
  22. data/app/components/primer/dropdown.rb +149 -0
  23. data/app/components/primer/dropdown.ts +1 -0
  24. data/app/components/primer/dropdown/menu.d.ts +1 -0
  25. data/app/components/primer/dropdown/menu.html.erb +25 -0
  26. data/app/components/primer/dropdown/menu.js +1 -0
  27. data/app/components/primer/dropdown/menu.rb +99 -0
  28. data/app/components/primer/dropdown/menu.ts +1 -0
  29. data/app/components/primer/heading_component.rb +1 -1
  30. data/app/components/primer/hidden_text_expander.rb +2 -2
  31. data/app/components/primer/icon_button.rb +1 -1
  32. data/app/components/primer/image_crop.rb +2 -2
  33. data/app/components/primer/markdown.rb +6 -2
  34. data/app/components/primer/menu_component.rb +7 -3
  35. data/app/components/primer/navigation/tab_component.rb +6 -6
  36. data/app/components/primer/octicon_component.rb +4 -3
  37. data/app/components/primer/popover_component.rb +2 -2
  38. data/app/components/primer/primer.d.ts +1 -0
  39. data/app/components/primer/primer.js +1 -0
  40. data/app/components/primer/primer.ts +1 -0
  41. data/app/components/primer/spinner_component.rb +2 -0
  42. data/app/components/primer/tab_nav_component.html.erb +4 -2
  43. data/app/components/primer/tab_nav_component.rb +48 -6
  44. data/app/components/primer/tooltip.rb +1 -1
  45. data/app/components/primer/truncate.rb +6 -2
  46. data/app/components/primer/underline_nav_component.html.erb +1 -1
  47. data/app/components/primer/underline_nav_component.rb +27 -5
  48. data/app/lib/primer/tabbed_component_helper.rb +2 -2
  49. data/{app/lib → lib}/primer/classify.rb +41 -35
  50. data/{app/lib → lib}/primer/classify/cache.rb +16 -35
  51. data/{app/lib → lib}/primer/classify/flex.rb +0 -0
  52. data/{app/lib → lib}/primer/classify/functional_background_colors.rb +2 -0
  53. data/{app/lib → lib}/primer/classify/functional_border_colors.rb +2 -0
  54. data/{app/lib → lib}/primer/classify/functional_colors.rb +0 -0
  55. data/{app/lib → lib}/primer/classify/functional_text_colors.rb +2 -0
  56. data/lib/primer/classify/grid.rb +45 -0
  57. data/lib/primer/classify/utilities.rb +137 -0
  58. data/lib/primer/classify/utilities.yml +1271 -0
  59. data/lib/primer/view_components.rb +1 -0
  60. data/lib/primer/view_components/engine.rb +2 -0
  61. data/lib/primer/view_components/linters.rb +3 -0
  62. data/lib/primer/view_components/linters/argument_mappers/button.rb +82 -0
  63. data/lib/primer/view_components/linters/argument_mappers/conversion_error.rb +10 -0
  64. data/lib/primer/view_components/linters/argument_mappers/system_arguments.rb +47 -0
  65. data/lib/primer/view_components/linters/button_component_migration_counter.rb +39 -0
  66. data/lib/primer/view_components/linters/flash_component_migration_counter.rb +16 -0
  67. data/lib/primer/view_components/linters/helpers.rb +191 -0
  68. data/lib/primer/view_components/version.rb +1 -1
  69. data/lib/tasks/docs.rake +180 -108
  70. data/lib/tasks/utilities.rake +105 -0
  71. data/lib/yard/docs_helper.rb +12 -2
  72. data/static/statuses.json +7 -5
  73. metadata +50 -20
  74. data/app/components/primer/button_marketing_component.rb +0 -68
  75. data/app/components/primer/dropdown/menu_component.html.erb +0 -12
  76. data/app/components/primer/dropdown/menu_component.rb +0 -46
  77. data/app/components/primer/dropdown_component.rb +0 -73
  78. data/app/components/primer/text_component.rb +0 -25
  79. data/app/lib/primer/classify/spacing.rb +0 -63
@@ -0,0 +1,105 @@
1
+ # frozen_string_literal: true
2
+
3
+ namespace :utilities do
4
+ task :build do
5
+ require "yaml"
6
+ require "json"
7
+ require File.expand_path("./../../demo/config/environment.rb", __dir__)
8
+
9
+ # Keys that are looked for to be included in the utilities.yml file
10
+ SUPPORTED_KEYS = %i[
11
+ anim
12
+ d
13
+ float
14
+ hide
15
+ m mt mr mb ml mx my
16
+ p pt pr pb pl px py
17
+ position
18
+ wb
19
+ v
20
+ ].freeze
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
+ }.freeze
30
+
31
+ BREAKPOINTS = [nil, "sm", "md", "lg", "xl"].freeze
32
+
33
+ css_data =
34
+ JSON.parse(
35
+ File.read(
36
+ File.join(
37
+ __FILE__.split("lib/tasks/utilities.rake")[0], "/node_modules/@primer/css/dist/stats/utilities.json"
38
+ )
39
+ )
40
+ )["selectors"]["values"]
41
+
42
+ output = {}
43
+
44
+ css_data.each do |selector|
45
+ selector.sub!(/^./, "")
46
+ # Next if selector has ancestors or sibling selectors
47
+ next if selector.match?(/[:><~\[\.]/)
48
+ next unless SUPPORTED_KEYS.any? { |key| selector.start_with?("#{key}-") }
49
+
50
+ # Dupe so we still have the selector at the end of slicing it up
51
+ classname = selector.dup
52
+ key = ""
53
+
54
+ # Look for a replacement key
55
+ REPLACEMENT_KEYS.each do |k, v|
56
+ next unless classname.match?(Regexp.new(k))
57
+
58
+ key = v
59
+ classname.sub!(Regexp.new(k + "-"), "")
60
+ end
61
+
62
+ # If we didn't find a replacement, grab the first text before hyphen
63
+ if classname == selector
64
+ key = classname.split("-").first
65
+ classname.sub!(/^[^-]+-/, "")
66
+ end
67
+
68
+ # Check if the next bit of the classname is a breakpoint
69
+ if classname.match?(/^(sm-|md-|lg-|xl-)/)
70
+ breakpoint = classname.split("-").first
71
+ classname.sub!(/^[^-]+-/, "")
72
+ end
73
+
74
+ # Change the rest from hypens to underscores
75
+ classname.sub!(/\-/, "_")
76
+
77
+ # convert padding/margin negative values ie n7 to -7
78
+ classname.sub!(/^n/, "-") if classname.match?(/^n[0-9]/)
79
+
80
+ key = key.to_sym
81
+
82
+ classname = if classname.match?(/\A[-+]?[0-9]+\z/)
83
+ classname.to_i
84
+ else
85
+ classname.to_sym
86
+ end
87
+
88
+ if output[key].nil?
89
+ output[key] = { classname => Array.new(5, nil) }
90
+ elsif output[key][classname].nil?
91
+ output[key][classname] = Array.new(5, nil)
92
+ end
93
+
94
+ output[key][classname][BREAKPOINTS.index(breakpoint)] = selector
95
+ end
96
+
97
+ output.transform_values! do |x|
98
+ x.transform_values { |y| y.reverse.drop_while(&:nil?).reverse }
99
+ end
100
+
101
+ File.open("lib/primer/classify/utilities.yml", "w") do |f|
102
+ f.puts YAML.dump(output)
103
+ end
104
+ end
105
+ end
@@ -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",
@@ -43,8 +46,7 @@
43
46
  "Primer::StateComponent": "beta",
44
47
  "Primer::SubheadComponent": "beta",
45
48
  "Primer::TabContainerComponent": "alpha",
46
- "Primer::TabNavComponent": "alpha",
47
- "Primer::TextComponent": "beta",
49
+ "Primer::TabNavComponent": "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.41
4
+ version: 0.0.46
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: 2021-05-17 00:00:00.000000000 Z
11
+ date: 2021-06-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionview
@@ -142,6 +142,20 @@ dependencies:
142
142
  - - '='
143
143
  - !ruby/object:Gem::Version
144
144
  version: '0.13'
145
+ - !ruby/object:Gem::Dependency
146
+ name: erb_lint
147
+ requirement: !ruby/object:Gem::Requirement
148
+ requirements:
149
+ - - ">="
150
+ - !ruby/object:Gem::Version
151
+ version: '0'
152
+ type: :development
153
+ prerelease: false
154
+ version_requirements: !ruby/object:Gem::Requirement
155
+ requirements:
156
+ - - ">="
157
+ - !ruby/object:Gem::Version
158
+ version: '0'
145
159
  - !ruby/object:Gem::Dependency
146
160
  name: listen
147
161
  requirement: !ruby/object:Gem::Requirement
@@ -324,7 +338,7 @@ dependencies:
324
338
  - - "~>"
325
339
  - !ruby/object:Gem::Version
326
340
  version: 0.9.25
327
- description:
341
+ description:
328
342
  email:
329
343
  - opensource+primer_view_components@github.com
330
344
  executables: []
@@ -336,6 +350,7 @@ files:
336
350
  - README.md
337
351
  - app/assets/javascripts/primer_view_components.js
338
352
  - app/assets/javascripts/primer_view_components.js.map
353
+ - app/components/primer/alpha/button_marketing.rb
339
354
  - app/components/primer/auto_complete.rb
340
355
  - app/components/primer/auto_complete/auto_complete.d.ts
341
356
  - app/components/primer/auto_complete/auto_complete.html.erb
@@ -349,6 +364,7 @@ files:
349
364
  - app/components/primer/avatar_stack_component.rb
350
365
  - app/components/primer/base_button.rb
351
366
  - app/components/primer/base_component.rb
367
+ - app/components/primer/beta/text.rb
352
368
  - app/components/primer/blankslate_component.html.erb
353
369
  - app/components/primer/blankslate_component.rb
354
370
  - app/components/primer/border_box_component.html.erb
@@ -360,7 +376,6 @@ files:
360
376
  - app/components/primer/button_component.rb
361
377
  - app/components/primer/button_group.html.erb
362
378
  - app/components/primer/button_group.rb
363
- - app/components/primer/button_marketing_component.rb
364
379
  - app/components/primer/clipboard_copy.html.erb
365
380
  - app/components/primer/clipboard_copy.rb
366
381
  - app/components/primer/clipboard_copy_component.d.ts
@@ -371,10 +386,16 @@ files:
371
386
  - app/components/primer/counter_component.rb
372
387
  - app/components/primer/details_component.html.erb
373
388
  - app/components/primer/details_component.rb
374
- - app/components/primer/dropdown/menu_component.html.erb
375
- - app/components/primer/dropdown/menu_component.rb
376
- - app/components/primer/dropdown_component.html.erb
377
- - 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
378
399
  - app/components/primer/dropdown_menu_component.html.erb
379
400
  - app/components/primer/dropdown_menu_component.rb
380
401
  - app/components/primer/flash_component.html.erb
@@ -425,7 +446,6 @@ files:
425
446
  - app/components/primer/tab_container_component.ts
426
447
  - app/components/primer/tab_nav_component.html.erb
427
448
  - app/components/primer/tab_nav_component.rb
428
- - app/components/primer/text_component.rb
429
449
  - app/components/primer/time_ago_component.d.ts
430
450
  - app/components/primer/time_ago_component.js
431
451
  - app/components/primer/time_ago_component.rb
@@ -437,14 +457,6 @@ files:
437
457
  - app/components/primer/underline_nav_component.html.erb
438
458
  - app/components/primer/underline_nav_component.rb
439
459
  - app/lib/primer/class_name_helper.rb
440
- - app/lib/primer/classify.rb
441
- - app/lib/primer/classify/cache.rb
442
- - app/lib/primer/classify/flex.rb
443
- - app/lib/primer/classify/functional_background_colors.rb
444
- - app/lib/primer/classify/functional_border_colors.rb
445
- - app/lib/primer/classify/functional_colors.rb
446
- - app/lib/primer/classify/functional_text_colors.rb
447
- - app/lib/primer/classify/spacing.rb
448
460
  - app/lib/primer/fetch_or_fallback_helper.rb
449
461
  - app/lib/primer/join_style_arguments_helper.rb
450
462
  - app/lib/primer/octicon/cache.rb
@@ -452,12 +464,30 @@ files:
452
464
  - app/lib/primer/tabbed_component_helper.rb
453
465
  - app/lib/primer/test_selector_helper.rb
454
466
  - app/lib/primer/view_helper.rb
467
+ - lib/primer/classify.rb
468
+ - lib/primer/classify/cache.rb
469
+ - lib/primer/classify/flex.rb
470
+ - lib/primer/classify/functional_background_colors.rb
471
+ - lib/primer/classify/functional_border_colors.rb
472
+ - lib/primer/classify/functional_colors.rb
473
+ - lib/primer/classify/functional_text_colors.rb
474
+ - lib/primer/classify/grid.rb
475
+ - lib/primer/classify/utilities.rb
476
+ - lib/primer/classify/utilities.yml
455
477
  - lib/primer/view_components.rb
456
478
  - lib/primer/view_components/engine.rb
479
+ - lib/primer/view_components/linters.rb
480
+ - lib/primer/view_components/linters/argument_mappers/button.rb
481
+ - lib/primer/view_components/linters/argument_mappers/conversion_error.rb
482
+ - lib/primer/view_components/linters/argument_mappers/system_arguments.rb
483
+ - lib/primer/view_components/linters/button_component_migration_counter.rb
484
+ - lib/primer/view_components/linters/flash_component_migration_counter.rb
485
+ - lib/primer/view_components/linters/helpers.rb
457
486
  - lib/primer/view_components/version.rb
458
487
  - lib/tasks/coverage.rake
459
488
  - lib/tasks/docs.rake
460
489
  - lib/tasks/statuses.rake
490
+ - lib/tasks/utilities.rake
461
491
  - lib/yard/docs_helper.rb
462
492
  - lib/yard/renders_many_handler.rb
463
493
  - lib/yard/renders_one_handler.rb
@@ -467,7 +497,7 @@ licenses:
467
497
  - MIT
468
498
  metadata:
469
499
  allowed_push_host: https://rubygems.org
470
- post_install_message:
500
+ post_install_message:
471
501
  rdoc_options: []
472
502
  require_paths:
473
503
  - lib
@@ -483,7 +513,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
483
513
  version: '0'
484
514
  requirements: []
485
515
  rubygems_version: 3.1.2
486
- signing_key:
516
+ signing_key:
487
517
  specification_version: 4
488
518
  summary: ViewComponents for the Primer Design System
489
519
  test_files: []
@@ -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