primer_view_components 0.0.114 → 0.0.115

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 (137) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +36 -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/divider.rb +2 -0
  8. data/app/components/primer/alpha/action_list/heading.rb +2 -0
  9. data/app/components/primer/alpha/action_list/item.rb +8 -6
  10. data/app/components/primer/alpha/action_list.rb +1 -0
  11. data/app/components/primer/alpha/auto_complete/auto_complete.html.erb +1 -1
  12. data/app/components/primer/alpha/auto_complete/item.rb +1 -0
  13. data/app/components/primer/alpha/auto_complete.rb +3 -2
  14. data/app/components/primer/alpha/banner.html.erb +1 -1
  15. data/app/components/primer/alpha/banner.rb +1 -0
  16. data/app/components/primer/alpha/button_marketing.rb +2 -0
  17. data/app/components/primer/alpha/dialog.rb +3 -0
  18. data/app/components/primer/alpha/image.rb +1 -0
  19. data/app/components/primer/alpha/image_crop.html.erb +1 -1
  20. data/app/components/primer/alpha/layout.css +1 -0
  21. data/app/components/primer/alpha/layout.css.json +1 -0
  22. data/app/components/primer/alpha/layout.css.map +1 -0
  23. data/app/components/primer/alpha/layout.pcss +268 -0
  24. data/app/components/primer/{menu_component.css → alpha/menu.css} +0 -0
  25. data/app/components/primer/alpha/menu.css.json +1 -0
  26. data/app/components/primer/alpha/menu.css.map +1 -0
  27. data/app/components/primer/{menu_component.html.erb → alpha/menu.html.erb} +0 -0
  28. data/app/components/primer/{menu_component.pcss → alpha/menu.pcss} +0 -0
  29. data/app/components/primer/alpha/menu.rb +76 -0
  30. data/app/components/primer/{octicon_symbols_component.html.erb → alpha/octicon_symbols.html.erb} +0 -0
  31. data/app/components/primer/alpha/octicon_symbols.rb +61 -0
  32. data/app/components/primer/alpha/text_field.rb +1 -0
  33. data/app/components/primer/alpha/toggle_switch.html.erb +2 -2
  34. data/app/components/primer/alpha/toggle_switch.rb +2 -0
  35. data/app/components/primer/alpha/tool_tip.js +77 -69
  36. data/app/components/primer/alpha/tool_tip.ts +63 -51
  37. data/app/components/primer/alpha/tooltip.rb +2 -0
  38. data/app/components/primer/beta/auto_complete/item.rb +4 -4
  39. data/app/components/primer/beta/auto_complete.rb +3 -3
  40. data/app/components/primer/beta/avatar.rb +1 -0
  41. data/app/components/primer/beta/base_button.rb +1 -0
  42. data/app/components/primer/beta/blankslate.rb +5 -5
  43. data/app/components/primer/beta/button.rb +7 -7
  44. data/app/components/primer/beta/clipboard_copy.html.erb +2 -2
  45. data/app/components/primer/beta/clipboard_copy.rb +1 -0
  46. data/app/components/primer/beta/close_button.rb +2 -1
  47. data/app/components/primer/beta/counter.rb +1 -0
  48. data/app/components/primer/beta/heading.rb +1 -0
  49. data/app/components/primer/beta/icon_button.html.erb +1 -1
  50. data/app/components/primer/beta/icon_button.rb +1 -0
  51. data/app/components/primer/beta/label.rb +1 -0
  52. data/app/components/primer/beta/markdown.rb +1 -0
  53. data/app/components/primer/{octicon_component.html.erb → beta/octicon.html.erb} +0 -0
  54. data/app/components/primer/beta/octicon.rb +88 -0
  55. data/app/components/primer/beta/relative_time.rb +2 -1
  56. data/app/components/primer/{spinner_component.html.erb → beta/spinner.html.erb} +0 -0
  57. data/app/components/primer/beta/spinner.rb +46 -0
  58. data/app/components/primer/beta/text.rb +1 -0
  59. data/app/components/primer/blankslate_component.rb +3 -3
  60. data/app/components/primer/box.rb +1 -0
  61. data/app/components/primer/button_component.rb +3 -3
  62. data/app/components/primer/conditional_wrapper.rb +2 -0
  63. data/app/components/primer/hellip_button.rb +2 -0
  64. data/app/components/primer/icon_button.html.erb +2 -2
  65. data/app/components/primer/icon_button.rb +1 -0
  66. data/app/components/primer/layout_component.rb +2 -0
  67. data/app/components/primer/local_time.rb +3 -0
  68. data/app/components/primer/menu_component.rb +2 -69
  69. data/app/components/primer/navigation/tab_component.rb +2 -2
  70. data/app/components/primer/octicon_component.rb +3 -81
  71. data/app/components/primer/octicon_symbols_component.rb +2 -52
  72. data/app/components/primer/primer.d.ts +2 -0
  73. data/app/components/primer/primer.js +2 -0
  74. data/app/components/primer/primer.pcss +2 -1
  75. data/app/components/primer/primer.ts +2 -0
  76. data/app/components/primer/spinner_component.rb +2 -38
  77. data/app/components/primer/state_component.rb +1 -0
  78. data/app/components/primer/subhead_component.rb +2 -0
  79. data/app/components/primer/tab_container_component.rb +2 -0
  80. data/app/components/primer/time_ago_component.rb +2 -1
  81. data/app/components/primer/timeline_item_component.rb +3 -2
  82. data/app/components/primer/tooltip.rb +1 -0
  83. data/app/components/primer/truncate.rb +2 -0
  84. data/app/forms/immediate_validation_form.rb +29 -0
  85. data/app/forms/multi_input_form.rb +4 -2
  86. data/app/lib/primer/css/layout.css +1 -378
  87. data/app/lib/primer/css/layout.css.json +1 -1
  88. data/app/lib/primer/octicon/cache.rb +1 -1
  89. data/app/lib/primer/view_helper.rb +1 -1
  90. data/lib/primer/deprecations.yml +26 -0
  91. data/lib/primer/forms/builder.rb +48 -8
  92. data/lib/primer/forms/check_box.html.erb +3 -1
  93. data/lib/primer/forms/dsl/input.rb +23 -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/multi.html.erb +6 -2
  100. data/lib/primer/forms/primer_multi_input.d.ts +10 -0
  101. data/lib/primer/forms/primer_multi_input.js +45 -0
  102. data/lib/primer/forms/primer_multi_input.ts +46 -0
  103. data/lib/primer/forms/primer_text_field.d.ts +1 -0
  104. data/lib/primer/forms/primer_text_field.js +62 -0
  105. data/lib/primer/forms/primer_text_field.ts +48 -0
  106. data/lib/primer/forms/radio_button.html.erb +3 -1
  107. data/lib/primer/forms/text_field.html.erb +8 -8
  108. data/lib/primer/forms/text_field.rb +11 -0
  109. data/lib/primer/view_components/linters/close_button_component_migration_counter.rb +1 -1
  110. data/lib/primer/view_components/version.rb +1 -1
  111. data/lib/tasks/docs.rake +5 -5
  112. data/lib/tasks/helpers/ast_traverser.rb +1 -1
  113. data/previews/primer/alpha/action_list_preview.rb +1 -1
  114. data/previews/primer/alpha/auto_complete_preview.rb +62 -6
  115. data/previews/primer/alpha/layout_preview.rb +179 -6
  116. data/previews/primer/{menu_component_preview → alpha/menu_preview}/default.html.erb +3 -3
  117. data/previews/primer/{menu_component_preview → alpha/menu_preview}/playground.html.erb +3 -3
  118. data/previews/primer/alpha/menu_preview.rb +14 -0
  119. data/previews/primer/alpha/toggle_switch_preview.rb +11 -9
  120. data/previews/primer/beta/auto_complete_preview/with_submit_button.html.erb +1 -1
  121. data/previews/primer/beta/auto_complete_preview.rb +19 -17
  122. data/previews/primer/beta/octicon_preview.rb +24 -0
  123. data/previews/primer/beta/spinner_preview.rb +22 -0
  124. data/previews/primer/forms/forms_preview/immediate_validation_form.html.erb +3 -0
  125. data/previews/primer/forms/forms_preview/multi_input_form.html.erb +12 -1
  126. data/previews/primer/forms/forms_preview.rb +2 -0
  127. data/previews/primer/url_helpers.rb +15 -0
  128. data/static/arguments.json +159 -159
  129. data/static/audited_at.json +4 -0
  130. data/static/constants.json +42 -34
  131. data/static/statuses.json +10 -6
  132. metadata +32 -15
  133. data/app/components/primer/menu_component.css.json +0 -1
  134. data/app/components/primer/menu_component.css.map +0 -1
  135. data/previews/primer/menu_component_preview.rb +0 -12
  136. data/previews/primer/octicon_component_preview.rb +0 -22
  137. data/previews/primer/spinner_component_preview.rb +0 -20
@@ -0,0 +1,88 @@
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
+ status :beta
11
+
12
+ SIZE_XSMALL = :xsmall
13
+ SIZE_DEFAULT = :small
14
+ SIZE_MEDIUM = :medium
15
+
16
+ SIZE_MAPPINGS = {
17
+ SIZE_XSMALL => 12,
18
+ SIZE_DEFAULT => 16,
19
+ SIZE_MEDIUM => 24
20
+ }.freeze
21
+ SIZE_OPTIONS = SIZE_MAPPINGS.keys
22
+
23
+ # @example Default
24
+ # <%= render(Primer::Beta::Octicon.new(:check)) %>
25
+ # <%= render(Primer::Beta::Octicon.new(icon: :check)) %>
26
+ #
27
+ # @example Medium
28
+ # <%= render(Primer::Beta::Octicon.new(:people, size: :medium)) %>
29
+ #
30
+ # @example Helper
31
+ # <%= primer_octicon(:check) %>
32
+ #
33
+ # @param icon_name [Symbol, String] Name of <%= link_to_octicons %> to use.
34
+ # @param icon [Symbol, String] Name of <%= link_to_octicons %> to use.
35
+ # @param size [Symbol] <%= one_of(Primer::Beta::Octicon::SIZE_MAPPINGS, sort: false) %>
36
+ # @param use_symbol [Boolean] EXPERIMENTAL (May change or be removed) - Set to true when using with <%= link_to_component(Primer::Alpha::OcticonSymbols) %>.
37
+ # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
38
+ def initialize(icon_name = nil, icon: nil, size: SIZE_DEFAULT, use_symbol: false, **system_arguments)
39
+ icon_key = icon_name || icon
40
+
41
+ # Don't allow sizes under 16px
42
+ if system_arguments[:height].present? && system_arguments[:height].to_i < 16 || system_arguments[:width].present? && system_arguments[:width].to_i < 16
43
+ system_arguments.delete(:height)
44
+ system_arguments.delete(:width)
45
+ end
46
+
47
+ cache_key = Primer::Octicon::Cache.get_key(
48
+ symbol: icon_key,
49
+ size: size,
50
+ height: system_arguments[:height],
51
+ width: system_arguments[:width]
52
+ )
53
+
54
+ @system_arguments = system_arguments
55
+ @system_arguments[:tag] = :svg
56
+ @system_arguments[:aria] ||= {}
57
+ @use_symbol = use_symbol
58
+
59
+ if @system_arguments[:aria][:label] || @system_arguments[:"aria-label"]
60
+ @system_arguments[:role] = "img"
61
+ else
62
+ @system_arguments[:aria][:hidden] = true
63
+ end
64
+
65
+ if (cache_icon = Primer::Octicon::Cache.read(cache_key))
66
+ @icon = cache_icon
67
+ else
68
+ # Filter out classify options to prevent them from becoming invalid html attributes.
69
+ # Note height and width are both classify options and valid html attributes.
70
+ octicon_options = {
71
+ height: @system_arguments[:height] || SIZE_MAPPINGS[fetch_or_fallback(SIZE_OPTIONS, size, SIZE_DEFAULT)],
72
+ width: @system_arguments[:width]
73
+ }
74
+ octicon_options.compact!
75
+
76
+ @icon = Octicons::Octicon.new(icon_key, octicon_options)
77
+ Primer::Octicon::Cache.set(cache_key, @icon)
78
+ end
79
+
80
+ @system_arguments[:classes] = class_names(
81
+ @icon.options[:class],
82
+ @system_arguments[:classes]
83
+ )
84
+ @system_arguments.merge!(@icon.options.except(:class, :'aria-hidden'))
85
+ end
86
+ end
87
+ end
88
+ end
@@ -4,6 +4,7 @@ module Primer
4
4
  module Beta
5
5
  # Formats a timestamp as a localized string or as relative text that auto-updates in the user's browser.
6
6
  class RelativeTime < Primer::Component
7
+ warn_on_deprecated_slot_setter
7
8
  status :beta
8
9
 
9
10
  TENSE_DEFAULT = :auto
@@ -101,7 +102,7 @@ module Primer
101
102
  # @param month [Symbol] What format months should take. <%= one_of(Primer::Beta::RelativeTime::MONTH_OPTIONS) %>
102
103
  # @param year [Symbol] What format years should take. <%= one_of(Primer::Beta::RelativeTime::YEAR_OPTIONS) %>
103
104
  # @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.
105
+ # @param threshold [string] The threshold, in ISO-8601 'durations' format, at which relative time displays become absolute.
105
106
  # @param precision [Symbol] The precision elapsed time should display. <%= one_of(Primer::Beta::RelativeTime::PRECISION_OPTIONS) %>
106
107
  # @param format [Symbol] The format the display should take. <%= one_of(Primer::Beta::RelativeTime::FORMAT_OPTIONS) %>
107
108
  # @param lang [string] The language to use.
@@ -0,0 +1,46 @@
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
+ warn_on_deprecated_slot_setter
8
+ status :beta
9
+
10
+ DEFAULT_SIZE = :medium
11
+ SIZE_MAPPINGS = {
12
+ :small => 16,
13
+ DEFAULT_SIZE => 32,
14
+ :large => 64
15
+ }.freeze
16
+ SIZE_OPTIONS = SIZE_MAPPINGS.keys
17
+ # Setting `box-sizing: content-box` allows consumers to add padding
18
+ # to the spinner without shrinking the icon
19
+ DEFAULT_STYLE = "box-sizing: content-box; color: var(--color-icon-primary);"
20
+
21
+ #
22
+ # @example Default
23
+ # <%= render(Primer::Beta::Spinner.new) %>
24
+ #
25
+ # @example Small
26
+ # <%= render(Primer::Beta::Spinner.new(size: :small)) %>
27
+ #
28
+ # @example Large
29
+ # <%= render(Primer::Beta::Spinner.new(size: :large)) %>
30
+ #
31
+ # @param size [Symbol] <%= one_of(Primer::Beta::Spinner::SIZE_MAPPINGS) %>
32
+ # @param style [String] Custom element styles.
33
+ # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
34
+ def initialize(size: DEFAULT_SIZE, style: DEFAULT_STYLE, **system_arguments)
35
+ @system_arguments = deny_tag_argument(**system_arguments)
36
+ @system_arguments[:tag] = :svg
37
+ @system_arguments[:style] ||= style
38
+ @system_arguments[:animation] = :rotate
39
+ @system_arguments[:width] = SIZE_MAPPINGS[fetch_or_fallback(SIZE_OPTIONS, size, DEFAULT_SIZE)]
40
+ @system_arguments[:height] = SIZE_MAPPINGS[fetch_or_fallback(SIZE_OPTIONS, size, DEFAULT_SIZE)]
41
+ @system_arguments[:viewBox] = "0 0 16 16"
42
+ @system_arguments[:fill] = :none
43
+ end
44
+ end
45
+ end
46
+ end
@@ -4,6 +4,7 @@ module Primer
4
4
  module Beta
5
5
  # `Text` is a wrapper component that will apply typography styles to the text inside.
6
6
  class Text < Primer::Component
7
+ warn_on_deprecated_slot_setter
7
8
  status :beta
8
9
 
9
10
  DEFAULT_TAG = :span
@@ -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.
@@ -3,6 +3,7 @@
3
3
  module Primer
4
4
  # `Box` is a basic wrapper component for most layout related needs.
5
5
  class Box < Primer::Component
6
+ warn_on_deprecated_slot_setter
6
7
  status :stable
7
8
 
8
9
  # @example Default
@@ -28,14 +28,14 @@ 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
41
  alias icon leading_visual_icon # remove alias when all buttons are migrated to new slot names
@@ -22,6 +22,8 @@ module Primer
22
22
  # @param condition [Boolean] Whether or not to wrap the content in a `Primer::BaseComponent`.
23
23
  # @param base_component_arguments [Hash] The arguments to pass to `Primer::BaseComponent`.
24
24
  class ConditionalWrapper < Primer::Component
25
+ warn_on_deprecated_slot_setter
26
+
25
27
  def initialize(condition:, **base_component_arguments)
26
28
  @condition = condition
27
29
  @base_component_arguments = base_component_arguments
@@ -8,6 +8,8 @@ module Primer
8
8
  # * This button is displaying a hellip as its content (The three dots character). Therefore a label is needed for screen readers.
9
9
  # * Set the attribute `aria-label` on the system arguments. E.g. `Primer::HellipButton.new("aria-label": "Expand next part")`
10
10
  class HellipButton < Primer::Component
11
+ warn_on_deprecated_slot_setter
12
+
11
13
  # @example Default
12
14
  # <%= render(Primer::HellipButton.new("aria-label": "No effect")) %>
13
15
  #
@@ -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 %>
@@ -12,6 +12,7 @@ module Primer
12
12
  # Either `aria-label` or `aria-description` will be used for the `Tooltip` text, depending on which one is present.
13
13
  # [Learn more about best functional image practices (WAI Images)](https://www.w3.org/WAI/tutorials/images/functional)
14
14
  class IconButton < Primer::Component
15
+ warn_on_deprecated_slot_setter
15
16
  status :deprecated
16
17
 
17
18
  DEFAULT_SCHEME = :default
@@ -3,6 +3,8 @@
3
3
  module Primer
4
4
  # Use `Layout` to build a main/sidebar layout.
5
5
  class LayoutComponent < Primer::Component
6
+ warn_on_deprecated_slot_setter
7
+
6
8
  # The main content
7
9
  #
8
10
  # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
@@ -3,6 +3,9 @@
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
+ warn_on_deprecated_slot_setter
7
+ status :deprecated
8
+
6
9
  DEFAULT_DIGIT_TYPE = :numeric
7
10
  DIGIT_TYPE_OPTIONS = [DEFAULT_DIGIT_TYPE, :"2-digit"].freeze
8
11
 
@@ -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,8 @@
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
+ warn_on_deprecated_slot_setter
6
+ status :deprecated
85
7
  end
86
8
  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
@@ -3,6 +3,7 @@
3
3
  module Primer
4
4
  # Use `State` for rendering the status of an item.
5
5
  class StateComponent < Primer::Component
6
+ warn_on_deprecated_slot_setter
6
7
  status :beta
7
8
 
8
9
  SCHEME_DEFAULT = :default
@@ -11,6 +11,8 @@ module Primer
11
11
  # The `:heading` slot defaults to rendering a `<div>`. Update the tag to a heading element with the appropriate level to improve page navigation for assistive technologies.
12
12
  # <%= link_to_heading_practices %>
13
13
  class SubheadComponent < Primer::Component
14
+ warn_on_deprecated_slot_setter
15
+
14
16
  status :beta
15
17
 
16
18
  DEFAULT_HEADING_TAG = :div
@@ -6,6 +6,8 @@ module Primer
6
6
  #
7
7
  # This component requires javascript.
8
8
  class TabContainerComponent < Primer::Component
9
+ warn_on_deprecated_slot_setter
10
+
9
11
  # @example Default
10
12
  # <%= render(Primer::TabContainerComponent.new) do %>
11
13
  # <div role="tablist">
@@ -3,7 +3,8 @@
3
3
  module Primer
4
4
  # Use `TimeAgo` to display a time relative to how long ago it was. This component requires JavaScript.
5
5
  class TimeAgoComponent < Primer::Component
6
- status :beta
6
+ warn_on_deprecated_slot_setter
7
+ status :deprecated
7
8
 
8
9
  # @example Default
9
10
  # <%= render(Primer::TimeAgoComponent.new(time: Time.at(628232400))) %>