primer_view_components 0.0.114 → 0.0.116

Sign up to get free protection for your applications and to get access to all the features.
Files changed (143) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +52 -0
  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/assets/styles/primer_view_components.css +2 -2
  6. data/app/assets/styles/primer_view_components.css.map +1 -1
  7. data/app/components/primer/alpha/action_list/item.rb +6 -6
  8. data/app/components/primer/alpha/auto_complete/auto_complete.html.erb +1 -1
  9. data/app/components/primer/alpha/auto_complete.rb +10 -10
  10. data/app/components/primer/alpha/banner.html.erb +1 -1
  11. data/app/components/primer/alpha/dialog.rb +2 -0
  12. data/app/components/primer/alpha/dropdown/menu.rb +2 -0
  13. data/app/components/primer/alpha/dropdown.html.erb +3 -3
  14. data/app/components/primer/alpha/image_crop.html.erb +1 -1
  15. data/app/components/primer/alpha/layout.css +1 -0
  16. data/app/components/primer/alpha/layout.css.json +1 -0
  17. data/app/components/primer/alpha/layout.css.map +1 -0
  18. data/app/components/primer/alpha/layout.pcss +268 -0
  19. data/app/components/primer/alpha/layout.rb +1 -1
  20. data/app/components/primer/{menu_component.css → alpha/menu.css} +0 -0
  21. data/app/components/primer/alpha/menu.css.json +1 -0
  22. data/app/components/primer/alpha/menu.css.map +1 -0
  23. data/app/components/primer/{menu_component.html.erb → alpha/menu.html.erb} +0 -0
  24. data/app/components/primer/{menu_component.pcss → alpha/menu.pcss} +0 -0
  25. data/app/components/primer/alpha/menu.rb +76 -0
  26. data/app/components/primer/{octicon_symbols_component.html.erb → alpha/octicon_symbols.html.erb} +0 -0
  27. data/app/components/primer/alpha/octicon_symbols.rb +59 -0
  28. data/app/components/primer/alpha/segmented_control.css +1 -1
  29. data/app/components/primer/alpha/segmented_control.css.json +1 -1
  30. data/app/components/primer/alpha/segmented_control.css.map +1 -1
  31. data/app/components/primer/alpha/segmented_control.pcss +12 -0
  32. data/app/components/primer/alpha/segmented_control.rb +5 -5
  33. data/app/components/primer/alpha/tab_panels.rb +6 -6
  34. data/app/components/primer/alpha/toggle_switch.html.erb +2 -2
  35. data/app/components/primer/alpha/toggle_switch.rb +6 -6
  36. data/app/components/primer/alpha/tool_tip.js +77 -69
  37. data/app/components/primer/alpha/tool_tip.ts +63 -51
  38. data/app/components/primer/alpha/underline_panels.rb +6 -6
  39. data/app/components/primer/beta/auto_complete/item.rb +5 -4
  40. data/app/components/primer/beta/auto_complete.rb +15 -13
  41. data/app/components/primer/beta/avatar_stack.rb +2 -0
  42. data/app/components/primer/beta/blankslate.rb +48 -47
  43. data/app/components/primer/beta/border_box/header.rb +2 -0
  44. data/app/components/primer/beta/border_box.rb +2 -0
  45. data/app/components/primer/beta/breadcrumbs.rb +1 -0
  46. data/app/components/primer/beta/button.css +1 -1
  47. data/app/components/primer/beta/button.css.json +1 -1
  48. data/app/components/primer/beta/button.css.map +1 -1
  49. data/app/components/primer/beta/button.pcss +5 -0
  50. data/app/components/primer/beta/button.rb +8 -7
  51. data/app/components/primer/beta/button_group.rb +3 -0
  52. data/app/components/primer/beta/clipboard_copy.html.erb +2 -2
  53. data/app/components/primer/beta/close_button.rb +1 -1
  54. data/app/components/primer/beta/details.rb +6 -3
  55. data/app/components/primer/beta/flash.rb +1 -0
  56. data/app/components/primer/beta/icon_button.html.erb +1 -1
  57. data/app/components/primer/beta/link.rb +1 -0
  58. data/app/components/primer/{octicon_component.html.erb → beta/octicon.html.erb} +0 -0
  59. data/app/components/primer/beta/octicon.rb +89 -0
  60. data/app/components/primer/beta/popover.rb +1 -0
  61. data/app/components/primer/beta/progress_bar.rb +7 -7
  62. data/app/components/primer/beta/relative_time.rb +1 -1
  63. data/app/components/primer/{spinner_component.html.erb → beta/spinner.html.erb} +0 -0
  64. data/app/components/primer/beta/spinner.rb +45 -0
  65. data/app/components/primer/beta/truncate.rb +3 -2
  66. data/app/components/primer/blankslate_component.rb +3 -3
  67. data/app/components/primer/button_component.rb +5 -5
  68. data/app/components/primer/component.rb +1 -0
  69. data/app/components/primer/dropdown_menu_component.rb +3 -3
  70. data/app/components/primer/icon_button.html.erb +2 -2
  71. data/app/components/primer/local_time.rb +2 -0
  72. data/app/components/primer/menu_component.rb +2 -69
  73. data/app/components/primer/navigation/tab_component.rb +2 -2
  74. data/app/components/primer/octicon_component.rb +2 -81
  75. data/app/components/primer/octicon_symbols_component.rb +2 -52
  76. data/app/components/primer/primer.d.ts +2 -0
  77. data/app/components/primer/primer.js +2 -0
  78. data/app/components/primer/primer.pcss +2 -1
  79. data/app/components/primer/primer.ts +2 -0
  80. data/app/components/primer/spinner_component.rb +2 -38
  81. data/app/components/primer/time_ago_component.rb +1 -1
  82. data/app/components/primer/timeline_item_component.rb +2 -2
  83. data/app/forms/immediate_validation_form.rb +29 -0
  84. data/app/forms/multi_input_form.rb +4 -2
  85. data/app/lib/primer/css/layout.css +1 -378
  86. data/app/lib/primer/css/layout.css.json +1 -1
  87. data/app/lib/primer/octicon/cache.rb +1 -1
  88. data/app/lib/primer/view_helper.rb +1 -1
  89. data/lib/primer/deprecations.yml +26 -0
  90. data/lib/primer/forms/builder.rb +47 -8
  91. data/lib/primer/forms/check_box.html.erb +3 -1
  92. data/lib/primer/forms/dsl/form_reference_input.rb +25 -2
  93. data/lib/primer/forms/dsl/input.rb +50 -1
  94. data/lib/primer/forms/dsl/multi_input.rb +6 -9
  95. data/lib/primer/forms/dsl/select_list_input.rb +1 -1
  96. data/lib/primer/forms/dsl/text_field_input.rb +31 -1
  97. data/lib/primer/forms/form_control.html.erb +17 -13
  98. data/lib/primer/forms/form_control.rb +2 -0
  99. data/lib/primer/forms/form_reference.html.erb +1 -1
  100. data/lib/primer/forms/form_reference.rb +4 -0
  101. data/lib/primer/forms/multi.html.erb +6 -2
  102. data/lib/primer/forms/primer_multi_input.d.ts +10 -0
  103. data/lib/primer/forms/primer_multi_input.js +45 -0
  104. data/lib/primer/forms/primer_multi_input.ts +46 -0
  105. data/lib/primer/forms/primer_text_field.d.ts +1 -0
  106. data/lib/primer/forms/primer_text_field.js +62 -0
  107. data/lib/primer/forms/primer_text_field.ts +48 -0
  108. data/lib/primer/forms/radio_button.html.erb +3 -1
  109. data/lib/primer/forms/text_field.html.erb +8 -8
  110. data/lib/primer/forms/text_field.rb +11 -0
  111. data/lib/primer/view_components/linters/close_button_component_migration_counter.rb +1 -1
  112. data/lib/primer/view_components/version.rb +1 -1
  113. data/lib/tasks/docs.rake +5 -5
  114. data/lib/tasks/helpers/ast_traverser.rb +1 -1
  115. data/previews/primer/alpha/action_list_preview.rb +1 -1
  116. data/previews/primer/alpha/auto_complete_preview.rb +62 -6
  117. data/previews/primer/alpha/layout_preview.rb +179 -6
  118. data/previews/primer/{menu_component_preview → alpha/menu_preview}/default.html.erb +3 -3
  119. data/previews/primer/{menu_component_preview → alpha/menu_preview}/playground.html.erb +3 -3
  120. data/previews/primer/alpha/menu_preview.rb +14 -0
  121. data/previews/primer/alpha/tab_panels_preview.rb +8 -8
  122. data/previews/primer/alpha/toggle_switch_preview.rb +11 -9
  123. data/previews/primer/beta/auto_complete_preview/with_submit_button.html.erb +1 -1
  124. data/previews/primer/beta/auto_complete_preview.rb +19 -17
  125. data/previews/primer/beta/details_preview.rb +6 -6
  126. data/previews/primer/beta/octicon_preview.rb +24 -0
  127. data/previews/primer/beta/spinner_preview.rb +22 -0
  128. data/previews/primer/forms/forms_preview/immediate_validation_form.html.erb +3 -0
  129. data/previews/primer/forms/forms_preview/multi_input_form.html.erb +12 -1
  130. data/previews/primer/forms/forms_preview.rb +2 -0
  131. data/previews/primer/local_time_component_preview.rb +3 -0
  132. data/previews/primer/time_ago_component_preview.rb +3 -0
  133. data/previews/primer/url_helpers.rb +15 -0
  134. data/static/arguments.json +159 -159
  135. data/static/audited_at.json +4 -0
  136. data/static/constants.json +42 -34
  137. data/static/statuses.json +10 -6
  138. metadata +32 -15
  139. data/app/components/primer/menu_component.css.json +0 -1
  140. data/app/components/primer/menu_component.css.map +0 -1
  141. data/previews/primer/menu_component_preview.rb +0 -12
  142. data/previews/primer/octicon_component_preview.rb +0 -22
  143. data/previews/primer/spinner_component_preview.rb +0 -20
@@ -0,0 +1,89 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "octicons"
4
+
5
+ module Primer
6
+ module Beta
7
+ # `Octicon` renders an <%= link_to_octicons %> with <%= link_to_system_arguments_docs %>.
8
+ # `Octicon` can also be rendered with the `primer_octicon` helper, which accepts the same arguments.
9
+ class Octicon < Primer::Component
10
+ warn_on_deprecated_slot_setter
11
+ status :beta
12
+
13
+ SIZE_XSMALL = :xsmall
14
+ SIZE_DEFAULT = :small
15
+ SIZE_MEDIUM = :medium
16
+
17
+ SIZE_MAPPINGS = {
18
+ SIZE_XSMALL => 12,
19
+ SIZE_DEFAULT => 16,
20
+ SIZE_MEDIUM => 24
21
+ }.freeze
22
+ SIZE_OPTIONS = SIZE_MAPPINGS.keys
23
+
24
+ # @example Default
25
+ # <%= render(Primer::Beta::Octicon.new(:check)) %>
26
+ # <%= render(Primer::Beta::Octicon.new(icon: :check)) %>
27
+ #
28
+ # @example Medium
29
+ # <%= render(Primer::Beta::Octicon.new(:people, size: :medium)) %>
30
+ #
31
+ # @example Helper
32
+ # <%= primer_octicon(:check) %>
33
+ #
34
+ # @param icon_name [Symbol, String] Name of <%= link_to_octicons %> to use.
35
+ # @param icon [Symbol, String] Name of <%= link_to_octicons %> to use.
36
+ # @param size [Symbol] <%= one_of(Primer::Beta::Octicon::SIZE_MAPPINGS, sort: false) %>
37
+ # @param use_symbol [Boolean] EXPERIMENTAL (May change or be removed) - Set to true when using with <%= link_to_component(Primer::Alpha::OcticonSymbols) %>.
38
+ # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
39
+ def initialize(icon_name = nil, icon: nil, size: SIZE_DEFAULT, use_symbol: false, **system_arguments)
40
+ icon_key = icon_name || icon
41
+
42
+ # Don't allow sizes under 16px
43
+ if system_arguments[:height].present? && system_arguments[:height].to_i < 16 || system_arguments[:width].present? && system_arguments[:width].to_i < 16
44
+ system_arguments.delete(:height)
45
+ system_arguments.delete(:width)
46
+ end
47
+
48
+ cache_key = Primer::Octicon::Cache.get_key(
49
+ symbol: icon_key,
50
+ size: size,
51
+ height: system_arguments[:height],
52
+ width: system_arguments[:width]
53
+ )
54
+
55
+ @system_arguments = system_arguments
56
+ @system_arguments[:tag] = :svg
57
+ @system_arguments[:aria] ||= {}
58
+ @use_symbol = use_symbol
59
+
60
+ if @system_arguments[:aria][:label] || @system_arguments[:"aria-label"]
61
+ @system_arguments[:role] = "img"
62
+ else
63
+ @system_arguments[:aria][:hidden] = true
64
+ end
65
+
66
+ if (cache_icon = Primer::Octicon::Cache.read(cache_key))
67
+ @icon = cache_icon
68
+ else
69
+ # Filter out classify options to prevent them from becoming invalid html attributes.
70
+ # Note height and width are both classify options and valid html attributes.
71
+ octicon_options = {
72
+ height: @system_arguments[:height] || SIZE_MAPPINGS[fetch_or_fallback(SIZE_OPTIONS, size, SIZE_DEFAULT)],
73
+ width: @system_arguments[:width]
74
+ }
75
+ octicon_options.compact!
76
+
77
+ @icon = Octicons::Octicon.new(icon_key, octicon_options)
78
+ Primer::Octicon::Cache.set(cache_key, @icon)
79
+ end
80
+
81
+ @system_arguments[:classes] = class_names(
82
+ @icon.options[:class],
83
+ @system_arguments[:classes]
84
+ )
85
+ @system_arguments.merge!(@icon.options.except(:class, :'aria-hidden'))
86
+ end
87
+ end
88
+ end
89
+ end
@@ -6,6 +6,7 @@ module Primer
6
6
  #
7
7
  # By default, the popover renders with absolute positioning, meaning it should usually be wrapped in an element with a relative position in order to be positioned properly. To render the popover with relative positioning, use the relative property.
8
8
  class Popover < Primer::Component
9
+ warn_on_deprecated_slot_setter
9
10
  status :beta
10
11
 
11
12
  CARET_DEFAULT = :top
@@ -32,24 +32,24 @@ module Primer
32
32
  SIZE_OPTIONS = SIZE_MAPPINGS.keys
33
33
  # @example Default
34
34
  # <%= render(Primer::Beta::ProgressBar.new) do |component| %>
35
- # <% component.item(percentage: 25) %>
35
+ # <% component.with_item(percentage: 25) %>
36
36
  # <% end %>
37
37
  #
38
38
  # @example Small
39
39
  # <%= render(Primer::Beta::ProgressBar.new(size: :small)) do |component| %>
40
- # <% component.item(bg: :accent_emphasis, percentage: 50) %>
40
+ # <% component.with_item(bg: :accent_emphasis, percentage: 50) %>
41
41
  # <% end %>
42
42
  #
43
43
  # @example Large
44
44
  # <%= render(Primer::Beta::ProgressBar.new(size: :large)) do |component| %>
45
- # <% component.item(bg: :danger_emphasis, percentage: 75) %>
45
+ # <% component.with_item(bg: :danger_emphasis, percentage: 75) %>
46
46
  # <% end %>
47
47
  #
48
48
  # @example Multiple items
49
49
  # <%= render(Primer::Beta::ProgressBar.new) do |component| %>
50
- # <% component.item(percentage: 10) %>
51
- # <% component.item(bg: :accent_emphasis, percentage: 20) %>
52
- # <% component.item(bg: :danger_emphasis, percentage: 30) %>
50
+ # <% component.with_item(percentage: 10) %>
51
+ # <% component.with_item(bg: :accent_emphasis, percentage: 20) %>
52
+ # <% component.with_item(bg: :danger_emphasis, percentage: 30) %>
53
53
  # <% end %>
54
54
  #
55
55
  # @param size [Symbol] <%= one_of(Primer::Beta::ProgressBar::SIZE_OPTIONS) %> Increases height.
@@ -65,7 +65,7 @@ module Primer
65
65
  end
66
66
 
67
67
  def render?
68
- items.any?
68
+ items?
69
69
  end
70
70
  end
71
71
  end
@@ -101,7 +101,7 @@ module Primer
101
101
  # @param month [Symbol] What format months should take. <%= one_of(Primer::Beta::RelativeTime::MONTH_OPTIONS) %>
102
102
  # @param year [Symbol] What format years should take. <%= one_of(Primer::Beta::RelativeTime::YEAR_OPTIONS) %>
103
103
  # @param time_zone_name [Symbol] What format the time zone should take. <%= one_of(Primer::Beta::RelativeTime::TIMEZONENAME_OPTIONS) %>
104
- # @param threshold [string] The threshold at which relative time displays become absolute.
104
+ # @param threshold [string] The threshold, in ISO-8601 'durations' format, at which relative time displays become absolute.
105
105
  # @param precision [Symbol] The precision elapsed time should display. <%= one_of(Primer::Beta::RelativeTime::PRECISION_OPTIONS) %>
106
106
  # @param format [Symbol] The format the display should take. <%= one_of(Primer::Beta::RelativeTime::FORMAT_OPTIONS) %>
107
107
  # @param lang [string] The language to use.
@@ -0,0 +1,45 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Primer
4
+ module Beta
5
+ # Use `Spinner` to let users know that content is being loaded.
6
+ class Spinner < Primer::Component
7
+ status :beta
8
+
9
+ DEFAULT_SIZE = :medium
10
+ SIZE_MAPPINGS = {
11
+ :small => 16,
12
+ DEFAULT_SIZE => 32,
13
+ :large => 64
14
+ }.freeze
15
+ SIZE_OPTIONS = SIZE_MAPPINGS.keys
16
+ # Setting `box-sizing: content-box` allows consumers to add padding
17
+ # to the spinner without shrinking the icon
18
+ DEFAULT_STYLE = "box-sizing: content-box; color: var(--color-icon-primary);"
19
+
20
+ #
21
+ # @example Default
22
+ # <%= render(Primer::Beta::Spinner.new) %>
23
+ #
24
+ # @example Small
25
+ # <%= render(Primer::Beta::Spinner.new(size: :small)) %>
26
+ #
27
+ # @example Large
28
+ # <%= render(Primer::Beta::Spinner.new(size: :large)) %>
29
+ #
30
+ # @param size [Symbol] <%= one_of(Primer::Beta::Spinner::SIZE_MAPPINGS) %>
31
+ # @param style [String] Custom element styles.
32
+ # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
33
+ def initialize(size: DEFAULT_SIZE, style: DEFAULT_STYLE, **system_arguments)
34
+ @system_arguments = deny_tag_argument(**system_arguments)
35
+ @system_arguments[:tag] = :svg
36
+ @system_arguments[:style] ||= style
37
+ @system_arguments[:animation] = :rotate
38
+ @system_arguments[:width] = SIZE_MAPPINGS[fetch_or_fallback(SIZE_OPTIONS, size, DEFAULT_SIZE)]
39
+ @system_arguments[:height] = SIZE_MAPPINGS[fetch_or_fallback(SIZE_OPTIONS, size, DEFAULT_SIZE)]
40
+ @system_arguments[:viewBox] = "0 0 16 16"
41
+ @system_arguments[:fill] = :none
42
+ end
43
+ end
44
+ end
45
+ end
@@ -4,6 +4,7 @@ module Primer
4
4
  module Beta
5
5
  # Use `Truncate` to shorten overflowing text with an ellipsis.
6
6
  class Truncate < Primer::Component
7
+ warn_on_deprecated_slot_setter
7
8
  status :beta
8
9
 
9
10
  # Text slot used for the truncated text.
@@ -77,11 +78,11 @@ module Primer
77
78
  def before_render
78
79
  return unless content.present? && items.empty?
79
80
 
80
- item { content }
81
+ with_item { content }
81
82
  end
82
83
 
83
84
  def render?
84
- items.any?
85
+ items?
85
86
  end
86
87
 
87
88
  # This component is part of `Primer::Beta::Truncate` and should not be
@@ -10,10 +10,10 @@ module Primer
10
10
 
11
11
  # Optional Spinner.
12
12
  #
13
- # @param kwargs [Hash] The same arguments as <%= link_to_component(Primer::SpinnerComponent) %>.
13
+ # @param kwargs [Hash] The same arguments as <%= link_to_component(Primer::Beta::Spinner) %>.
14
14
  renders_one :spinner, lambda { |**system_arguments|
15
15
  system_arguments[:mb] ||= 3
16
- Primer::SpinnerComponent.new(**system_arguments)
16
+ Primer::Beta::Spinner.new(**system_arguments)
17
17
  }
18
18
 
19
19
  #
@@ -95,7 +95,7 @@ module Primer
95
95
  # @param title [String] Text that appears in a larger bold font.
96
96
  # @param title_tag [Symbol] HTML tag to use for title.
97
97
  # @param icon [Symbol] Octicon icon to use at top of component.
98
- # @param icon_size [Symbol] <%= one_of(Primer::OcticonComponent::SIZE_MAPPINGS, sort: false) %>
98
+ # @param icon_size [Symbol] <%= one_of(Primer::Beta::Octicon::SIZE_MAPPINGS, sort: false) %>
99
99
  # @param image_src [String] Image to display.
100
100
  # @param image_alt [String] Alt text for image.
101
101
  # @param description [String] Text that appears below the title. Typically a whole sentence.
@@ -28,17 +28,17 @@ module Primer
28
28
  #
29
29
  # Use:
30
30
  #
31
- # - `leading_visual_icon` for a <%= link_to_component(Primer::OcticonComponent) %>.
31
+ # - `leading_visual_icon` for a <%= link_to_component(Primer::Beta::Octicon) %>.
32
32
  #
33
- # @param system_arguments [Hash] Same arguments as <%= link_to_component(Primer::OcticonComponent) %>.
33
+ # @param system_arguments [Hash] Same arguments as <%= link_to_component(Primer::Beta::Octicon) %>.
34
34
  renders_one :leading_visual, types: {
35
35
  icon: lambda { |**system_arguments|
36
36
  system_arguments[:mr] = 2
37
37
 
38
- Primer::OcticonComponent.new(**system_arguments)
38
+ Primer::Beta::Octicon.new(**system_arguments)
39
39
  }
40
40
  }
41
- alias icon leading_visual_icon # remove alias when all buttons are migrated to new slot names
41
+ alias icon with_leading_visual_icon # remove alias when all buttons are migrated to new slot names
42
42
 
43
43
  # Trailing visuals appear to the right of the button text.
44
44
  #
@@ -54,7 +54,7 @@ module Primer
54
54
  Primer::Beta::Counter.new(**system_arguments)
55
55
  }
56
56
  }
57
- alias counter trailing_visual_counter # remove alias when all buttons are migrated to new slot names
57
+ alias counter with_trailing_visual_counter # remove alias when all buttons are migrated to new slot names
58
58
 
59
59
  # `Tooltip` that appears on mouse hover or keyboard focus over the button. Use tooltips sparingly and as a last resort.
60
60
  # **Important:** This tooltip defaults to `type: :description`. In a few scenarios, `type: :label` may be more appropriate.
@@ -6,6 +6,7 @@ module Primer
6
6
  # @private
7
7
  # :nocov:
8
8
  class Component < ViewComponent::Base
9
+ warn_on_deprecated_slot_setter
9
10
  include ViewComponent::SlotableV2 unless ViewComponent::Base < ViewComponent::SlotableV2
10
11
  include ViewComponent::PolymorphicSlots unless ViewComponent::Base < ViewComponent::PolymorphicSlots
11
12
  include ClassNameHelper
@@ -18,12 +18,12 @@ module Primer
18
18
 
19
19
  # @example With a header
20
20
  # <div>
21
- # <%= render(Primer::Beta::Details.new(overlay: :default, reset: true, position: :relative)) do |c| %>
22
- # <% c.summary do %>
21
+ # <%= render(Primer::Beta::Details.new(overlay: :default, reset: true, position: :relative)) do |component| %>
22
+ # <% component.with_summary do %>
23
23
  # Dropdown
24
24
  # <% end %>
25
25
  #
26
- # <% c.body do %>
26
+ # <% component.with_body do %>
27
27
  # <%= render(Primer::DropdownMenuComponent.new(header: "Options")) do %>
28
28
  # <ul>
29
29
  # <li><a class="dropdown-item" href="#url">Dropdown item</a></li>
@@ -1,12 +1,12 @@
1
1
  <% if render_tooltip? %>
2
2
  <%= render Primer::BaseComponent.new(tag: :div, position: :relative, display: :inline_block) do %>
3
3
  <%= render Primer::Beta::BaseButton.new(**@system_arguments) do -%>
4
- <%= render Primer::OcticonComponent.new(icon: @icon) %>
4
+ <%= render Primer::Beta::Octicon.new(icon: @icon) %>
5
5
  <% end -%>
6
6
  <%= render Primer::Alpha::Tooltip.new(**@tooltip_arguments) %>
7
7
  <% end %>
8
8
  <% else %>
9
9
  <%= render Primer::Beta::BaseButton.new(**@system_arguments) do -%>
10
- <%= render Primer::OcticonComponent.new(icon: @icon) %>
10
+ <%= render Primer::Beta::Octicon.new(icon: @icon) %>
11
11
  <% end -%>
12
12
  <% end %>
@@ -3,6 +3,8 @@
3
3
  module Primer
4
4
  # Use `LocalTime` to format a date and time in the user's preferred locale format. This component requires JavaScript.
5
5
  class LocalTime < Primer::Component
6
+ status :deprecated
7
+
6
8
  DEFAULT_DIGIT_TYPE = :numeric
7
9
  DIGIT_TYPE_OPTIONS = [DEFAULT_DIGIT_TYPE, :"2-digit"].freeze
8
10
 
@@ -1,74 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Primer
4
- # Use `Menu` to create vertical lists of navigational links.
5
- class MenuComponent < Primer::Component
6
- HEADING_TAG_OPTIONS = [:h1, :h2, :h3, :h4, :h5, :h6].freeze
7
- HEADING_TAG_FALLBACK = :h2
8
-
9
- # Optional menu heading
10
- #
11
- # @param tag [Symbol] <%= one_of(Primer::MenuComponent::HEADING_TAG_OPTIONS) %>
12
- # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
13
- renders_one :heading, lambda { |tag:, **system_arguments|
14
- system_arguments[:tag] = fetch_or_fallback(HEADING_TAG_OPTIONS, tag, HEADING_TAG_FALLBACK)
15
- system_arguments[:classes] = class_names(
16
- "menu-heading",
17
- system_arguments[:classes]
18
- )
19
-
20
- Primer::BaseComponent.new(**system_arguments)
21
- }
22
-
23
- # Required list of navigational links
24
- #
25
- # @param href [String] URL to be used for the Link
26
- # @param selected [Boolean] Whether the item is the current selection
27
- # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
28
- renders_many :items, lambda { |href:, selected: false, **system_arguments|
29
- deny_tag_argument(**system_arguments)
30
- system_arguments[:tag] = :a
31
- system_arguments[:href] = href
32
- system_arguments[:"aria-current"] = :page if selected
33
- system_arguments[:classes] = class_names(
34
- "menu-item",
35
- system_arguments[:classes]
36
- )
37
-
38
- Primer::BaseComponent.new(**system_arguments)
39
- }
40
-
41
- # @example Default
42
- # <%= render(Primer::MenuComponent.new) do |c| %>
43
- # <% c.with_heading(tag: :h2) do %>
44
- # Heading
45
- # <% end %>
46
- # <% c.with_item(selected: true, href: "#url") do %>
47
- # Item 1
48
- # <% end %>
49
- # <% c.with_item(href: "#url") do %>
50
- # <%= render(Primer::OcticonComponent.new("check")) %>
51
- # With Icon
52
- # <% end %>
53
- # <% c.with_item(href: "#url") do %>
54
- # <%= render(Primer::OcticonComponent.new("check")) %>
55
- # With Icon and Counter
56
- # <%= render(Primer::Beta::Counter.new(count: 25)) %>
57
- # <% end %>
58
- # <% end %>
59
- #
60
- # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
61
- def initialize(**system_arguments)
62
- @system_arguments = deny_tag_argument(**system_arguments)
63
- @system_arguments[:tag] = :nav
64
- @system_arguments[:classes] = class_names(
65
- "menu",
66
- @system_arguments[:classes]
67
- )
68
- end
69
-
70
- def render?
71
- items.any?
72
- end
4
+ class MenuComponent < Primer::Alpha::Menu
5
+ status :deprecated
73
6
  end
74
7
  end
@@ -41,13 +41,13 @@ module Primer
41
41
 
42
42
  # Icon to be rendered in the Tab left.
43
43
  #
44
- # @param kwargs [Hash] The same arguments as <%= link_to_component(Primer::OcticonComponent) %>.
44
+ # @param kwargs [Hash] The same arguments as <%= link_to_component(Primer::Beta::Octicon) %>.
45
45
  renders_one :icon, lambda { |icon = nil, **system_arguments|
46
46
  system_arguments[:classes] = class_names(
47
47
  @icon_classes,
48
48
  system_arguments[:classes]
49
49
  )
50
- Primer::OcticonComponent.new(icon, **system_arguments)
50
+ Primer::Beta::Octicon.new(icon, **system_arguments)
51
51
  }
52
52
 
53
53
  # The Tab's text.
@@ -1,86 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "octicons"
4
-
5
3
  module Primer
6
- # `Octicon` renders an <%= link_to_octicons %> with <%= link_to_system_arguments_docs %>.
7
- # `Octicon` can also be rendered with the `primer_octicon` helper, which accepts the same arguments.
8
- class OcticonComponent < Primer::Component
9
- status :beta
10
-
11
- SIZE_XSMALL = :xsmall
12
- SIZE_DEFAULT = :small
13
- SIZE_MEDIUM = :medium
14
-
15
- SIZE_MAPPINGS = {
16
- SIZE_XSMALL => 12,
17
- SIZE_DEFAULT => 16,
18
- SIZE_MEDIUM => 24
19
- }.freeze
20
- SIZE_OPTIONS = SIZE_MAPPINGS.keys
21
-
22
- # @example Default
23
- # <%= render(Primer::OcticonComponent.new(:check)) %>
24
- # <%= render(Primer::OcticonComponent.new(icon: :check)) %>
25
- #
26
- # @example Medium
27
- # <%= render(Primer::OcticonComponent.new(:people, size: :medium)) %>
28
- #
29
- # @example Helper
30
- # <%= primer_octicon(:check) %>
31
- #
32
- # @param icon_name [Symbol, String] Name of <%= link_to_octicons %> to use.
33
- # @param icon [Symbol, String] Name of <%= link_to_octicons %> to use.
34
- # @param size [Symbol] <%= one_of(Primer::OcticonComponent::SIZE_MAPPINGS, sort: false) %>
35
- # @param use_symbol [Boolean] EXPERIMENTAL (May change or be removed) - Set to true when using with <%= link_to_component(Primer::OcticonSymbolsComponent) %>.
36
- # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
37
- def initialize(icon_name = nil, icon: nil, size: SIZE_DEFAULT, use_symbol: false, **system_arguments)
38
- icon_key = icon_name || icon
39
-
40
- # Don't allow sizes under 16px
41
- if system_arguments[:height].present? && system_arguments[:height].to_i < 16 || system_arguments[:width].present? && system_arguments[:width].to_i < 16
42
- system_arguments.delete(:height)
43
- system_arguments.delete(:width)
44
- end
45
-
46
- cache_key = Primer::Octicon::Cache.get_key(
47
- symbol: icon_key,
48
- size: size,
49
- height: system_arguments[:height],
50
- width: system_arguments[:width]
51
- )
52
-
53
- @system_arguments = system_arguments
54
- @system_arguments[:tag] = :svg
55
- @system_arguments[:aria] ||= {}
56
- @use_symbol = use_symbol
57
-
58
- if @system_arguments[:aria][:label] || @system_arguments[:"aria-label"]
59
- @system_arguments[:role] = "img"
60
- else
61
- @system_arguments[:aria][:hidden] = true
62
- end
63
-
64
- if (cache_icon = Primer::Octicon::Cache.read(cache_key))
65
- @icon = cache_icon
66
- else
67
- # Filter out classify options to prevent them from becoming invalid html attributes.
68
- # Note height and width are both classify options and valid html attributes.
69
- octicon_options = {
70
- height: @system_arguments[:height] || SIZE_MAPPINGS[fetch_or_fallback(SIZE_OPTIONS, size, SIZE_DEFAULT)],
71
- width: @system_arguments[:width]
72
- }
73
- octicon_options.compact!
74
-
75
- @icon = Octicons::Octicon.new(icon_key, octicon_options)
76
- Primer::Octicon::Cache.set(cache_key, @icon)
77
- end
78
-
79
- @system_arguments[:classes] = class_names(
80
- @icon.options[:class],
81
- @system_arguments[:classes]
82
- )
83
- @system_arguments.merge!(@icon.options.except(:class, :'aria-hidden'))
84
- end
4
+ class OcticonComponent < Primer::Beta::Octicon
5
+ status :deprecated
85
6
  end
86
7
  end
@@ -1,57 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "octicons"
4
-
5
3
  module Primer
6
- # OcticonSymbols renders a symbol dictionary using a list of <%= link_to_octicons %>.
7
- class OcticonSymbolsComponent < Primer::Component
8
- # @example Symbol dictionary
9
- # <%= render(Primer::OcticonComponent.new(icon: :check, use_symbol: true, color: :success)) %>
10
- # <%= render(Primer::OcticonComponent.new(icon: :check, use_symbol: true, color: :danger)) %>
11
- # <%= render(Primer::OcticonComponent.new(icon: :check, use_symbol: true, size: :medium)) %>
12
- # <%= render(Primer::OcticonSymbolsComponent.new(icons: [{ symbol: :check }, { symbol: :check, size: :medium }])) %>
13
- #
14
- # @param icons [Array<Hash>] List of icons to render, in the format { symbol: :icon_name, size: :small }
15
- def initialize(icons: [])
16
- @icons = {}
17
- icons.each do |icon|
18
- symbol = icon[:symbol]
19
- size = Primer::OcticonComponent::SIZE_MAPPINGS[
20
- fetch_or_fallback(Primer::OcticonComponent::SIZE_OPTIONS, icon[:size] || Primer::OcticonComponent::SIZE_DEFAULT, Primer::OcticonComponent::SIZE_DEFAULT)
21
- ]
22
-
23
- cache_key = Primer::Octicon::Cache.get_key(symbol: symbol, size: size)
24
-
25
- if (cache_icon = Primer::Octicon::Cache.read(cache_key))
26
- icon_instance = cache_icon
27
- else
28
- icon_instance = Octicons::Octicon.new(symbol, height: size)
29
-
30
- Primer::Octicon::Cache.set(cache_key, icon_instance)
31
- end
32
-
33
- # Don't put the same icon twice
34
- @icons[[symbol, icon_instance.height]] = icon_instance if @icons[[symbol, icon_instance.height]].nil?
35
- end
36
- end
37
-
38
- def render?
39
- @icons.any?
40
- end
41
-
42
- def symbol_tags
43
- safe_join(
44
- @icons.values.map do |icon|
45
- content_tag(
46
- :symbol,
47
- icon.path.html_safe, # rubocop:disable Rails/OutputSafety
48
- id: "octicon_#{icon.symbol}_#{icon.height}",
49
- viewBox: icon.options[:viewBox],
50
- width: icon.width,
51
- height: icon.height
52
- )
53
- end
54
- )
55
- end
4
+ class OcticonSymbolsComponent < Primer::Alpha::OcticonSymbols
5
+ status :deprecated
56
6
  end
57
7
  end
@@ -11,3 +11,5 @@ import './beta/clipboard_copy';
11
11
  import './local_time';
12
12
  import './tab_container_component';
13
13
  import './time_ago_component';
14
+ import '../../../lib/primer/forms/primer_multi_input';
15
+ import '../../../lib/primer/forms/primer_text_field';
@@ -11,3 +11,5 @@ import './beta/clipboard_copy';
11
11
  import './local_time';
12
12
  import './tab_container_component';
13
13
  import './time_ago_component';
14
+ import '../../../lib/primer/forms/primer_multi_input';
15
+ import '../../../lib/primer/forms/primer_text_field';
@@ -6,12 +6,14 @@
6
6
  @import "./alpha/banner.pcss";
7
7
  @import "./alpha/dialog.pcss";
8
8
  @import "./alpha/dropdown.pcss";
9
+ @import "./alpha/layout.pcss";
9
10
  @import "./alpha/tab_nav.pcss";
10
11
  @import "./alpha/text_field.pcss";
11
12
  @import "./alpha/button_marketing.pcss";
12
13
  @import "./alpha/toggle_switch.pcss";
13
14
  @import "./alpha/underline_nav.pcss";
14
15
  @import "./alpha/segmented_control.pcss";
16
+ @import "./alpha/menu.pcss";
15
17
 
16
18
  /* beta */
17
19
  @import "./beta/avatar.pcss";
@@ -29,7 +31,6 @@
29
31
  @import "./beta/truncate.pcss";
30
32
 
31
33
  /* to be renamed */
32
- @import "./menu_component.pcss";
33
34
  @import "./state_component.pcss";
34
35
  @import "./subhead_component.pcss";
35
36
  @import "./timeline_item_component.pcss";
@@ -11,3 +11,5 @@ import './beta/clipboard_copy'
11
11
  import './local_time'
12
12
  import './tab_container_component'
13
13
  import './time_ago_component'
14
+ import '../../../lib/primer/forms/primer_multi_input'
15
+ import '../../../lib/primer/forms/primer_text_field'
@@ -1,43 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Primer
4
- # Use `Spinner` to let users know that content is being loaded.
5
- class SpinnerComponent < Primer::Component
6
- status :beta
7
-
8
- DEFAULT_SIZE = :medium
9
- SIZE_MAPPINGS = {
10
- :small => 16,
11
- DEFAULT_SIZE => 32,
12
- :large => 64
13
- }.freeze
14
- SIZE_OPTIONS = SIZE_MAPPINGS.keys
15
- # Setting `box-sizing: content-box` allows consumers to add padding
16
- # to the spinner without shrinking the icon
17
- DEFAULT_STYLE = "box-sizing: content-box; color: var(--color-icon-primary);"
18
-
19
- #
20
- # @example Default
21
- # <%= render(Primer::SpinnerComponent.new) %>
22
- #
23
- # @example Small
24
- # <%= render(Primer::SpinnerComponent.new(size: :small)) %>
25
- #
26
- # @example Large
27
- # <%= render(Primer::SpinnerComponent.new(size: :large)) %>
28
- #
29
- # @param size [Symbol] <%= one_of(Primer::SpinnerComponent::SIZE_MAPPINGS) %>
30
- # @param style [String] Custom element styles.
31
- # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
32
- def initialize(size: DEFAULT_SIZE, style: DEFAULT_STYLE, **system_arguments)
33
- @system_arguments = deny_tag_argument(**system_arguments)
34
- @system_arguments[:tag] = :svg
35
- @system_arguments[:style] ||= style
36
- @system_arguments[:animation] = :rotate
37
- @system_arguments[:width] = SIZE_MAPPINGS[fetch_or_fallback(SIZE_OPTIONS, size, DEFAULT_SIZE)]
38
- @system_arguments[:height] = SIZE_MAPPINGS[fetch_or_fallback(SIZE_OPTIONS, size, DEFAULT_SIZE)]
39
- @system_arguments[:viewBox] = "0 0 16 16"
40
- @system_arguments[:fill] = :none
41
- end
4
+ class SpinnerComponent < Primer::Beta::Spinner
5
+ status :deprecated
42
6
  end
43
7
  end