primer_view_components 0.0.40 → 0.0.45

Sign up to get free protection for your applications and to get access to all the features.
Files changed (84) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +239 -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 -41
  7. data/app/components/primer/auto_complete/auto_complete.html.erb +1 -0
  8. data/app/components/primer/{auto_complete/auto_component.d.ts → auto_complete_component.d.ts} +0 -0
  9. data/app/components/primer/{auto_complete/auto_component.js → auto_complete_component.js} +0 -0
  10. data/app/components/primer/avatar_stack_component.rb +2 -2
  11. data/app/components/primer/base_component.rb +31 -21
  12. data/app/components/primer/beta/text.rb +27 -0
  13. data/app/components/primer/blankslate_component.html.erb +1 -0
  14. data/app/components/primer/blankslate_component.rb +65 -46
  15. data/app/components/primer/button_component.rb +3 -2
  16. data/app/components/primer/button_group.rb +1 -1
  17. data/app/components/primer/clipboard_copy.rb +25 -7
  18. data/app/components/primer/clipboard_copy_component.js +13 -2
  19. data/app/components/primer/clipboard_copy_component.ts +15 -2
  20. data/app/components/primer/component.rb +1 -1
  21. data/app/components/primer/details_component.rb +12 -1
  22. data/app/components/primer/details_menu_component.d.ts +1 -0
  23. data/app/components/primer/details_menu_component.js +1 -0
  24. data/app/components/primer/dropdown.d.ts +1 -0
  25. data/app/components/primer/{dropdown_component.html.erb → dropdown.html.erb} +2 -1
  26. data/app/components/primer/dropdown.js +1 -0
  27. data/app/components/primer/dropdown.rb +149 -0
  28. data/app/components/primer/dropdown.ts +1 -0
  29. data/app/components/primer/dropdown/menu.d.ts +1 -0
  30. data/app/components/primer/dropdown/menu.html.erb +25 -0
  31. data/app/components/primer/dropdown/menu.js +1 -0
  32. data/app/components/primer/dropdown/menu.rb +99 -0
  33. data/app/components/primer/dropdown/menu.ts +1 -0
  34. data/app/components/primer/flash_component.rb +2 -2
  35. data/app/components/primer/heading_component.rb +1 -1
  36. data/app/components/primer/hidden_text_expander.rb +2 -2
  37. data/app/components/primer/icon_button.rb +1 -1
  38. data/app/components/primer/image.rb +46 -0
  39. data/app/components/primer/image_crop.rb +2 -2
  40. data/app/components/primer/label_component.rb +6 -2
  41. data/app/components/primer/local_time.d.ts +1 -0
  42. data/app/components/primer/local_time.js +1 -0
  43. data/app/components/primer/local_time.rb +59 -0
  44. data/app/components/primer/local_time.ts +1 -0
  45. data/app/components/primer/markdown.rb +6 -2
  46. data/app/components/primer/navigation/tab_component.rb +10 -3
  47. data/app/components/primer/octicon_component.rb +15 -12
  48. data/app/components/primer/primer.d.ts +2 -0
  49. data/app/components/primer/primer.js +2 -0
  50. data/app/components/primer/primer.ts +2 -0
  51. data/app/components/primer/spinner_component.rb +2 -0
  52. data/app/components/primer/tab_nav_component.html.erb +5 -1
  53. data/app/components/primer/tab_nav_component.rb +62 -9
  54. data/app/components/primer/{tooltip_component.rb → tooltip.rb} +10 -8
  55. data/app/components/primer/truncate.rb +6 -2
  56. data/app/components/primer/underline_nav_component.html.erb +1 -1
  57. data/app/components/primer/underline_nav_component.rb +17 -1
  58. data/app/lib/primer/classify.rb +35 -12
  59. data/app/lib/primer/classify/cache.rb +12 -17
  60. data/app/lib/primer/classify/grid.rb +45 -0
  61. data/app/lib/primer/classify/utilities.rb +137 -0
  62. data/app/lib/primer/classify/utilities.yml +1147 -0
  63. data/app/lib/primer/tabbed_component_helper.rb +2 -2
  64. data/app/lib/primer/view_helper.rb +2 -1
  65. data/lib/primer/view_components/engine.rb +2 -0
  66. data/lib/primer/view_components/linters.rb +3 -0
  67. data/lib/primer/view_components/linters/argument_mappers/button.rb +82 -0
  68. data/lib/primer/view_components/linters/argument_mappers/conversion_error.rb +10 -0
  69. data/lib/primer/view_components/linters/argument_mappers/system_arguments.rb +48 -0
  70. data/lib/primer/view_components/linters/button_component_migration_counter.rb +39 -0
  71. data/lib/primer/view_components/linters/flash_component_migration_counter.rb +16 -0
  72. data/lib/primer/view_components/linters/helpers.rb +191 -0
  73. data/lib/primer/view_components/version.rb +1 -1
  74. data/lib/tasks/docs.rake +184 -109
  75. data/lib/tasks/utilities.rake +99 -0
  76. data/lib/yard/docs_helper.rb +12 -2
  77. data/static/statuses.json +10 -6
  78. metadata +65 -14
  79. data/app/components/primer/button_marketing_component.rb +0 -68
  80. data/app/components/primer/dropdown/menu_component.html.erb +0 -12
  81. data/app/components/primer/dropdown/menu_component.rb +0 -46
  82. data/app/components/primer/dropdown_component.rb +0 -73
  83. data/app/components/primer/text_component.rb +0 -25
  84. data/app/lib/primer/classify/spacing.rb +0 -63
@@ -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
@@ -1,63 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Primer
4
- class Classify
5
- # Handler for PrimerCSS spacing classes.
6
- class Spacing
7
- BASE_OPTIONS = (0..6).to_a.freeze
8
- BASE_MAPPINGS = {
9
- my: BASE_OPTIONS,
10
- pb: BASE_OPTIONS,
11
- pl: BASE_OPTIONS,
12
- pr: BASE_OPTIONS,
13
- pt: BASE_OPTIONS,
14
- px: BASE_OPTIONS,
15
- py: BASE_OPTIONS
16
- }.freeze
17
-
18
- MARGIN_DIRECTION_OPTIONS = [*(-6..-1), *BASE_OPTIONS].freeze
19
- MARGIN_DIRECTION_MAPPINGS = {
20
- mb: MARGIN_DIRECTION_OPTIONS,
21
- ml: MARGIN_DIRECTION_OPTIONS,
22
- mr: MARGIN_DIRECTION_OPTIONS,
23
- mt: MARGIN_DIRECTION_OPTIONS
24
- }.freeze
25
-
26
- AUTO_OPTIONS = [*BASE_OPTIONS, :auto].freeze
27
- AUTO_MAPPINGS = {
28
- m: AUTO_OPTIONS,
29
- mx: AUTO_OPTIONS
30
- }.freeze
31
-
32
- RESPONSIVE_OPTIONS = [*BASE_OPTIONS, :responsive].freeze
33
- RESPONSIVE_MAPPINGS = {
34
- p: RESPONSIVE_OPTIONS
35
- }.freeze
36
-
37
- MAPPINGS = {
38
- **BASE_MAPPINGS,
39
- **MARGIN_DIRECTION_MAPPINGS,
40
- **AUTO_MAPPINGS,
41
- **RESPONSIVE_MAPPINGS
42
- }.freeze
43
- KEYS = MAPPINGS.keys.freeze
44
-
45
- class << self
46
- def spacing(key, val, breakpoint)
47
- validate(key, val) unless Rails.env.production?
48
-
49
- return "#{key.to_s.dasherize}#{breakpoint}-n#{val.abs}" if val.is_a?(Numeric) && val.negative?
50
-
51
- "#{key.to_s.dasherize}#{breakpoint}-#{val.to_s.dasherize}"
52
- end
53
-
54
- private
55
-
56
- def validate(key, val)
57
- raise ArgumentError, "#{key} is not a spacing key" unless KEYS.include?(key)
58
- raise ArgumentError, "#{val} is not a valid value for :#{key}. Use one of #{MAPPINGS[key]}" unless MAPPINGS[key].include?(val)
59
- end
60
- end
61
- end
62
- end
63
- end