primer_view_components 0.0.61 → 0.0.65

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 (80) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +746 -613
  3. data/app/components/primer/alpha/border_box/header.rb +1 -2
  4. data/app/components/primer/alpha/button_marketing.rb +4 -4
  5. data/app/components/primer/alpha/tab_nav.rb +1 -1
  6. data/app/components/primer/alpha/tab_panels.rb +2 -2
  7. data/app/components/primer/alpha/underline_nav.rb +2 -1
  8. data/app/components/primer/alpha/underline_panels.rb +2 -2
  9. data/app/components/primer/base_component.rb +8 -36
  10. data/app/components/primer/beta/auto_complete/item.rb +1 -1
  11. data/app/components/primer/beta/auto_complete.rb +4 -2
  12. data/app/components/primer/beta/avatar.rb +1 -1
  13. data/app/components/primer/beta/blankslate.html.erb +2 -2
  14. data/app/components/primer/beta/blankslate.rb +7 -6
  15. data/app/components/primer/beta/breadcrumbs.rb +2 -2
  16. data/app/components/primer/beta/text.rb +1 -1
  17. data/app/components/primer/border_box_component.rb +1 -1
  18. data/app/components/primer/box_component.rb +3 -2
  19. data/app/components/primer/button_component.html.erb +3 -9
  20. data/app/components/primer/button_component.rb +61 -28
  21. data/app/components/primer/button_group.rb +9 -15
  22. data/app/components/primer/clipboard_copy.rb +1 -1
  23. data/app/components/primer/close_button.rb +1 -1
  24. data/app/components/primer/component.rb +77 -0
  25. data/app/components/primer/counter_component.rb +1 -1
  26. data/app/components/primer/details_component.rb +1 -1
  27. data/app/components/primer/dropdown/menu.rb +1 -1
  28. data/app/components/primer/dropdown.html.erb +0 -1
  29. data/app/components/primer/dropdown.rb +2 -1
  30. data/app/components/primer/dropdown_menu_component.rb +1 -1
  31. data/app/components/primer/flash_component.rb +3 -2
  32. data/app/components/primer/flex_component.rb +16 -16
  33. data/app/components/primer/flex_item_component.rb +1 -1
  34. data/app/components/primer/hellip_button.rb +1 -1
  35. data/app/components/primer/hidden_text_expander.rb +1 -1
  36. data/app/components/primer/image.rb +3 -3
  37. data/app/components/primer/image_crop.rb +2 -1
  38. data/app/components/primer/label_component.rb +23 -13
  39. data/app/components/primer/layout_component.rb +1 -0
  40. data/app/components/primer/local_time.rb +1 -1
  41. data/app/components/primer/markdown.rb +1 -1
  42. data/app/components/primer/menu_component.rb +2 -1
  43. data/app/components/primer/navigation/tab_component.rb +1 -0
  44. data/app/components/primer/octicon_component.rb +4 -2
  45. data/app/components/primer/octicon_symbols_component.rb +2 -2
  46. data/app/components/primer/popover_component.rb +3 -3
  47. data/app/components/primer/progress_bar_component.rb +7 -6
  48. data/app/components/primer/spinner_component.html.erb +4 -7
  49. data/app/components/primer/spinner_component.rb +1 -1
  50. data/app/components/primer/subhead_component.rb +3 -1
  51. data/app/components/primer/tab_container_component.rb +1 -1
  52. data/app/components/primer/time_ago_component.rb +1 -1
  53. data/app/components/primer/timeline_item_component.rb +4 -3
  54. data/app/components/primer/tooltip.rb +1 -0
  55. data/app/lib/primer/octicon/cache.rb +4 -10
  56. data/lib/primer/classify/utilities.rb +17 -44
  57. data/lib/primer/classify/utilities.yml +298 -68
  58. data/lib/primer/classify.rb +92 -178
  59. data/lib/primer/view_components/engine.rb +1 -0
  60. data/lib/primer/view_components/linters/argument_mappers/button.rb +4 -4
  61. data/lib/primer/view_components/linters/blankslate_api_migration.rb +11 -5
  62. data/lib/primer/view_components/version.rb +1 -1
  63. data/lib/rubocop/cop/primer/deprecated_arguments.rb +1 -1
  64. data/lib/rubocop/cop/primer/deprecated_button_arguments.rb +51 -0
  65. data/lib/rubocop/cop/primer/deprecated_label_schemes.rb +68 -0
  66. data/lib/rubocop/cop/primer/deprecated_layout_component.rb +30 -0
  67. data/lib/rubocop/cop/primer/primer_octicon.rb +1 -3
  68. data/lib/tasks/custom_utilities.yml +298 -0
  69. data/lib/tasks/docs.rake +1 -1
  70. data/lib/tasks/utilities.rake +21 -4
  71. data/static/arguments.yml +16 -7
  72. data/static/classes.yml +19 -18
  73. data/static/constants.json +25 -15
  74. metadata +10 -12
  75. data/app/components/primer/auto_complete/auto_complete.d.ts +0 -1
  76. data/app/components/primer/auto_complete/auto_complete.js +0 -1
  77. data/app/components/primer/auto_complete/auto_component.d.ts +0 -1
  78. data/app/components/primer/auto_complete/auto_component.js +0 -1
  79. data/lib/primer/classify/cache.rb +0 -109
  80. data/lib/primer/classify/flex.rb +0 -111
@@ -6,6 +6,7 @@ module Primer
6
6
  # @private
7
7
  class Component < ViewComponent::Base
8
8
  include ViewComponent::SlotableV2 unless ViewComponent::Base < ViewComponent::SlotableV2
9
+ include ViewComponent::PolymorphicSlots
9
10
  include ClassNameHelper
10
11
  include FetchOrFallbackHelper
11
12
  include TestSelectorHelper
@@ -14,12 +15,18 @@ module Primer
14
15
  include Status::Dsl
15
16
  include Audited::Dsl
16
17
 
18
+ INVALID_ARIA_LABEL_TAGS = [:div, :span, :p].freeze
19
+
17
20
  private
18
21
 
19
22
  def raise_on_invalid_options?
20
23
  Rails.application.config.primer_view_components.raise_on_invalid_options
21
24
  end
22
25
 
26
+ def raise_on_invalid_aria?
27
+ Rails.application.config.primer_view_components.raise_on_invalid_aria
28
+ end
29
+
23
30
  def deprecated_component_warning(new_class: nil, version: nil)
24
31
  return if Rails.env.production? || silence_deprecations?
25
32
 
@@ -42,5 +49,75 @@ module Primer
42
49
  def silence_deprecations?
43
50
  Rails.application.config.primer_view_components.silence_deprecations
44
51
  end
52
+
53
+ def check_denylist(denylist = [], **arguments)
54
+ if should_raise_error?
55
+
56
+ # Convert denylist from:
57
+ # { [:p, :pt] => "message" } to:
58
+ # { p: "message", pt: "message" }
59
+ unpacked_denylist =
60
+ denylist.each_with_object({}) do |(keys, value), memo|
61
+ keys.each { |key| memo[key] = value }
62
+ end
63
+
64
+ violations = unpacked_denylist.keys & arguments.keys
65
+
66
+ if violations.any?
67
+ message = "Found #{violations.count} #{'violation'.pluralize(violations)}:"
68
+ violations.each do |violation|
69
+ message += "\n The #{violation} argument is not allowed here. #{unpacked_denylist[violation]}"
70
+ end
71
+
72
+ raise(ArgumentError, message)
73
+ end
74
+ end
75
+
76
+ arguments
77
+ end
78
+
79
+ def validate_arguments(tag:, denylist_name: :system_arguments_denylist, **arguments)
80
+ deny_single_argument(:class, "Use `classes` instead.", **arguments)
81
+
82
+ if (denylist = arguments[denylist_name])
83
+ check_denylist(denylist, **arguments)
84
+
85
+ # Remove :system_arguments_denylist key and any denied keys from system arguments
86
+ arguments.except!(denylist_name)
87
+ arguments.except!(*denylist.keys.flatten)
88
+ end
89
+
90
+ deny_aria_label(tag: tag, arguments: arguments)
91
+
92
+ arguments
93
+ end
94
+
95
+ def deny_single_argument(key, help_text, **arguments)
96
+ raise ArgumentError, "`#{key}` is an invalid argument. #{help_text}" \
97
+ if should_raise_error? && arguments.key?(key)
98
+
99
+ arguments.except!(key)
100
+ end
101
+
102
+ def deny_aria_label(tag:, arguments:)
103
+ return arguments.except!(:skip_aria_label_check) if arguments[:skip_aria_label_check]
104
+ return if arguments[:role]
105
+ return unless aria(:label, arguments)
106
+ return unless INVALID_ARIA_LABEL_TAGS.include?(tag)
107
+
108
+ raise ArgumentError, "Don't use `aria-label` on `#{tag}` elements. See https://www.tpgi.com/short-note-on-aria-label-aria-labelledby-and-aria-describedby/" if should_raise_aria_error?
109
+ end
110
+
111
+ def deny_tag_argument(**arguments)
112
+ deny_single_argument(:tag, "This component has a fixed tag.", **arguments)
113
+ end
114
+
115
+ def should_raise_error?
116
+ raise_on_invalid_options? && !ENV["PRIMER_WARNINGS_DISABLED"]
117
+ end
118
+
119
+ def should_raise_aria_error?
120
+ raise_on_invalid_aria? && !ENV["PRIMER_WARNINGS_DISABLED"]
121
+ end
45
122
  end
46
123
  end
@@ -51,7 +51,7 @@ module Primer
51
51
  @hide_if_zero = hide_if_zero
52
52
  @text = text
53
53
  @round = round
54
- @system_arguments = system_arguments
54
+ @system_arguments = deny_tag_argument(**system_arguments)
55
55
 
56
56
  @has_limit = !@limit.nil?
57
57
  @system_arguments[:title] = title
@@ -52,7 +52,7 @@ module Primer
52
52
  # @param reset [Boolean] Defatuls to false. If set to true, it will remove the default caret and remove style from the summary element
53
53
  # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
54
54
  def initialize(overlay: NO_OVERLAY, reset: false, **system_arguments)
55
- @system_arguments = system_arguments
55
+ @system_arguments = deny_tag_argument(**system_arguments)
56
56
  @system_arguments[:tag] = :details
57
57
  @system_arguments[:classes] = class_names(
58
58
  system_arguments[:classes],
@@ -33,7 +33,7 @@ module Primer
33
33
  @direction = direction
34
34
  @as = fetch_or_fallback(AS_OPTIONS, as, AS_DEFAULT)
35
35
 
36
- @system_arguments = system_arguments
36
+ @system_arguments = deny_tag_argument(**system_arguments)
37
37
  @system_arguments[:tag] = "details-menu"
38
38
  @system_arguments[:role] = "menu"
39
39
 
@@ -1,7 +1,6 @@
1
1
  <%= render(Primer::DetailsComponent.new(**@system_arguments)) do |c| %>
2
2
  <% c.summary(**@button_arguments) do %>
3
3
  <%= button %>
4
- <% if @with_caret %><div class="dropdown-caret"></div><% end %>
5
4
  <% end %>
6
5
 
7
6
  <% c.body do %>
@@ -9,6 +9,7 @@ module Primer
9
9
  renders_one :button, lambda { |**system_arguments, &block|
10
10
  @button_arguments = system_arguments
11
11
  @button_arguments[:button] = true
12
+ @button_arguments[:dropdown] = @with_caret
12
13
 
13
14
  view_context.capture { block&.call }
14
15
  }
@@ -87,7 +88,7 @@ module Primer
87
88
  #
88
89
  # @example Customizing the button
89
90
  # <%= render(Primer::Dropdown.new) do |c| %>
90
- # <% c.button(scheme: :primary, variant: :small) do %>
91
+ # <% c.button(scheme: :primary, size: :small) do %>
91
92
  # Dropdown
92
93
  # <% end %>
93
94
  #
@@ -42,7 +42,7 @@ module Primer
42
42
  def initialize(direction: DIRECTION_DEFAULT, scheme: SCHEME_DEFAULT, header: nil, **system_arguments)
43
43
  @header = header
44
44
  @direction = direction
45
- @system_arguments = system_arguments
45
+ @system_arguments = deny_tag_argument(**system_arguments)
46
46
 
47
47
  @system_arguments[:tag] = "details-menu"
48
48
  @system_arguments[:role] = "menu"
@@ -9,6 +9,7 @@ module Primer
9
9
  #
10
10
  # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
11
11
  renders_one :action, lambda { |**system_arguments|
12
+ deny_tag_argument(**system_arguments)
12
13
  system_arguments[:tag] = :div
13
14
  system_arguments[:classes] = class_names(system_arguments[:classes], "flash-action")
14
15
 
@@ -41,7 +42,7 @@ module Primer
41
42
  # <%= render(Primer::FlashComponent.new) do |component| %>
42
43
  # This is a flash message with actions!
43
44
  # <% component.action do %>
44
- # <%= render(Primer::ButtonComponent.new(variant: :small)) { "Take action" } %>
45
+ # <%= render(Primer::ButtonComponent.new(size: :small)) { "Take action" } %>
45
46
  # <% end %>
46
47
  # <% end %>
47
48
  #
@@ -54,7 +55,7 @@ module Primer
54
55
  def initialize(full: false, spacious: false, dismissible: false, icon: nil, scheme: DEFAULT_SCHEME, **system_arguments)
55
56
  @icon = icon
56
57
  @dismissible = dismissible
57
- @system_arguments = system_arguments
58
+ @system_arguments = deny_tag_argument(**system_arguments)
58
59
  @system_arguments[:tag] = :div
59
60
  @system_arguments[:classes] = class_names(
60
61
  @system_arguments[:classes],
@@ -61,31 +61,31 @@ module Primer
61
61
  ALLOWED_DIRECTIONS = [DEFAULT_DIRECTION, :column, :column_reverse, :row, :row_reverse].freeze
62
62
 
63
63
  # @example Default
64
- # <%= render(Primer::FlexComponent.new(bg: :tertiary)) do %>
65
- # <%= render(Primer::BoxComponent.new(p: 5, bg: :secondary, classes: "border")) { "Item 1" } %>
66
- # <%= render(Primer::BoxComponent.new(p: 5, bg: :secondary, classes: "border")) { "Item 2" } %>
67
- # <%= render(Primer::BoxComponent.new(p: 5, bg: :secondary, classes: "border")) { "Item 3" } %>
64
+ # <%= render(Primer::FlexComponent.new(bg: :subtle)) do %>
65
+ # <%= render(Primer::BoxComponent.new(p: 5, bg: :subtle, classes: "border")) { "Item 1" } %>
66
+ # <%= render(Primer::BoxComponent.new(p: 5, bg: :subtle, classes: "border")) { "Item 2" } %>
67
+ # <%= render(Primer::BoxComponent.new(p: 5, bg: :subtle, classes: "border")) { "Item 3" } %>
68
68
  # <% end %>
69
69
  #
70
70
  # @example Justify center
71
- # <%= render(Primer::FlexComponent.new(justify_content: :center, bg: :tertiary)) do %>
72
- # <%= render(Primer::BoxComponent.new(p: 5, bg: :secondary, classes: "border")) { "Item 1" } %>
73
- # <%= render(Primer::BoxComponent.new(p: 5, bg: :secondary, classes: "border")) { "Item 2" } %>
74
- # <%= render(Primer::BoxComponent.new(p: 5, bg: :secondary, classes: "border")) { "Item 3" } %>
71
+ # <%= render(Primer::FlexComponent.new(justify_content: :center, bg: :subtle)) do %>
72
+ # <%= render(Primer::BoxComponent.new(p: 5, bg: :subtle, classes: "border")) { "Item 1" } %>
73
+ # <%= render(Primer::BoxComponent.new(p: 5, bg: :subtle, classes: "border")) { "Item 2" } %>
74
+ # <%= render(Primer::BoxComponent.new(p: 5, bg: :subtle, classes: "border")) { "Item 3" } %>
75
75
  # <% end %>
76
76
  #
77
77
  # @example Align end
78
- # <%= render(Primer::FlexComponent.new(align_items: :end, bg: :tertiary)) do %>
79
- # <%= render(Primer::BoxComponent.new(p: 5, bg: :secondary, classes: "border")) { "Item 1" } %>
80
- # <%= render(Primer::BoxComponent.new(p: 5, bg: :secondary, classes: "border")) { "Item 2" } %>
81
- # <%= render(Primer::BoxComponent.new(p: 5, bg: :secondary, classes: "border")) { "Item 3" } %>
78
+ # <%= render(Primer::FlexComponent.new(align_items: :end, bg: :subtle)) do %>
79
+ # <%= render(Primer::BoxComponent.new(p: 5, bg: :subtle, classes: "border")) { "Item 1" } %>
80
+ # <%= render(Primer::BoxComponent.new(p: 5, bg: :subtle, classes: "border")) { "Item 2" } %>
81
+ # <%= render(Primer::BoxComponent.new(p: 5, bg: :subtle, classes: "border")) { "Item 3" } %>
82
82
  # <% end %>
83
83
  #
84
84
  # @example Direction column
85
- # <%= render(Primer::FlexComponent.new(direction: :column, bg: :tertiary)) do %>
86
- # <%= render(Primer::BoxComponent.new(p: 5, bg: :secondary, classes: "border")) { "Item 1" } %>
87
- # <%= render(Primer::BoxComponent.new(p: 5, bg: :secondary, classes: "border")) { "Item 2" } %>
88
- # <%= render(Primer::BoxComponent.new(p: 5, bg: :secondary, classes: "border")) { "Item 3" } %>
85
+ # <%= render(Primer::FlexComponent.new(direction: :column, bg: :subtle)) do %>
86
+ # <%= render(Primer::BoxComponent.new(p: 5, bg: :subtle, classes: "border")) { "Item 1" } %>
87
+ # <%= render(Primer::BoxComponent.new(p: 5, bg: :subtle, classes: "border")) { "Item 2" } %>
88
+ # <%= render(Primer::BoxComponent.new(p: 5, bg: :subtle, classes: "border")) { "Item 3" } %>
89
89
  # <% end %>
90
90
  #
91
91
  # @param justify_content [Symbol] Use this param to distribute space between and around flex items along the main axis of the container. <%= one_of(Primer::FlexComponent::JUSTIFY_CONTENT_OPTIONS) %>
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Primer
4
4
  # Use `FlexItem` to specify the ability of a flex item to alter its
5
- # dimensions to fill available space
5
+ # dimensions to fill available space.
6
6
  #
7
7
  # @deprecated
8
8
  # Use <%= link_to_component(Primer::BoxComponent) %> instead.
@@ -20,7 +20,7 @@ module Primer
20
20
  # @param inline [Boolean] Whether or not the button is inline.
21
21
  # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
22
22
  def initialize(inline: false, **system_arguments)
23
- @system_arguments = system_arguments
23
+ @system_arguments = deny_tag_argument(**system_arguments)
24
24
 
25
25
  validate_aria_label
26
26
 
@@ -22,7 +22,7 @@ module Primer
22
22
  # @param button_arguments [Hash] <%= link_to_system_arguments_docs %> for the button element.
23
23
  # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
24
24
  def initialize(inline: false, button_arguments: {}, **system_arguments)
25
- @system_arguments = system_arguments
25
+ @system_arguments = deny_tag_argument(**system_arguments)
26
26
  @button_arguments = button_arguments
27
27
 
28
28
  @system_arguments[:tag] = :span
@@ -27,10 +27,10 @@ module Primer
27
27
  # @param lazy [Boolean] Whether or not to lazily load the image.
28
28
  # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
29
29
  def initialize(src:, alt:, lazy: false, **system_arguments)
30
- @system_arguments = system_arguments
30
+ @system_arguments = deny_tag_argument(**system_arguments)
31
31
 
32
+ @src = src
32
33
  @system_arguments[:tag] = :img
33
- @system_arguments[:src] = src
34
34
  @system_arguments[:alt] = alt
35
35
 
36
36
  return unless lazy
@@ -40,7 +40,7 @@ module Primer
40
40
  end
41
41
 
42
42
  def call
43
- render(Primer::BaseComponent.new(**@system_arguments))
43
+ render(Primer::BaseComponent.new(src: image_path(@src), **@system_arguments))
44
44
  end
45
45
  end
46
46
  end
@@ -6,6 +6,7 @@ module Primer
6
6
  # A loading indicator that is shown while the image is loading.
7
7
  # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
8
8
  renders_one :loading, lambda { |**system_arguments|
9
+ deny_tag_argument(**system_arguments)
9
10
  system_arguments[:tag] = :div
10
11
  system_arguments[:"data-loading-slot"] = true
11
12
 
@@ -27,7 +28,7 @@ module Primer
27
28
  # @param rounded [Boolean] If the crop mask should be a circle. Defaults to true.
28
29
  # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
29
30
  def initialize(src:, rounded: true, **system_arguments)
30
- @system_arguments = system_arguments
31
+ @system_arguments = deny_tag_argument(**system_arguments)
31
32
  @system_arguments[:tag] = "image-crop"
32
33
  @system_arguments[:src] = src
33
34
  @system_arguments[:rounded] = true if rounded
@@ -11,19 +11,26 @@ module Primer
11
11
  DEFAULT_TAG = :span
12
12
  TAG_OPTIONS = [DEFAULT_TAG, :summary, :a, :div].freeze
13
13
 
14
+ DEFAULT_SCHEME = :default
14
15
  SCHEME_MAPPINGS = {
15
- primary: "Label--primary",
16
- secondary: "Label--secondary",
17
- info: "Label--info",
18
- success: "Label--success",
19
- warning: "Label--warning",
20
- danger: "Label--danger",
16
+ DEFAULT_SCHEME => "",
17
+ :primary => "Label--primary",
18
+ :secondary => "Label--secondary",
19
+ :accent => "Label--accent",
20
+ :success => "Label--success",
21
+ :attention => "Label--attention",
22
+ :danger => "Label--danger",
23
+ :severe => "Label--severe",
24
+ :done => "Label--done",
25
+ :sponsors => "Label--sponsors",
21
26
  # deprecated
22
- orange: "Label--orange",
23
- purple: "Label--purple"
27
+ :info => "Label--info",
28
+ :warning => "Label--warning",
29
+ :orange => "Label--orange",
30
+ :purple => "Label--purple"
24
31
  }.freeze
25
- DEPRECATED_SCHEME_OPTIONS = [:orange, :purple].freeze
26
- SCHEME_OPTIONS = ([*SCHEME_MAPPINGS.keys, nil] - DEPRECATED_SCHEME_OPTIONS).freeze
32
+ DEPRECATED_SCHEME_OPTIONS = [:info, :warning, :orange, :purple].freeze
33
+ SCHEME_OPTIONS = (SCHEME_MAPPINGS.keys - DEPRECATED_SCHEME_OPTIONS).freeze
27
34
 
28
35
  VARIANT_MAPPINGS = {
29
36
  large: "Label--large",
@@ -35,10 +42,13 @@ module Primer
35
42
  # <%= render(Primer::LabelComponent.new) { "Default" } %>
36
43
  # <%= render(Primer::LabelComponent.new(scheme: :primary)) { "Primary" } %>
37
44
  # <%= render(Primer::LabelComponent.new(scheme: :secondary)) { "Secondary" } %>
38
- # <%= render(Primer::LabelComponent.new(scheme: :info)) { "Info" } %>
45
+ # <%= render(Primer::LabelComponent.new(scheme: :accent)) { "Accent" } %>
39
46
  # <%= render(Primer::LabelComponent.new(scheme: :success)) { "Success" } %>
40
- # <%= render(Primer::LabelComponent.new(scheme: :warning)) { "Warning" } %>
47
+ # <%= render(Primer::LabelComponent.new(scheme: :attention)) { "Attention" } %>
41
48
  # <%= render(Primer::LabelComponent.new(scheme: :danger)) { "Danger" } %>
49
+ # <%= render(Primer::LabelComponent.new(scheme: :severe)) { "Severe" } %>
50
+ # <%= render(Primer::LabelComponent.new(scheme: :done)) { "Done" } %>
51
+ # <%= render(Primer::LabelComponent.new(scheme: :sponsors)) { "Sponsors" } %>
42
52
  #
43
53
  # @example Variants
44
54
  # <%= render(Primer::LabelComponent.new) { "Default" } %>
@@ -48,7 +58,7 @@ module Primer
48
58
  # @param scheme [Symbol] <%= one_of(Primer::LabelComponent::SCHEME_MAPPINGS.keys) %>
49
59
  # @param variant [Symbol] <%= one_of(Primer::LabelComponent::VARIANT_OPTIONS) %>
50
60
  # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
51
- def initialize(tag: DEFAULT_TAG, scheme: nil, variant: nil, **system_arguments)
61
+ def initialize(tag: DEFAULT_TAG, scheme: DEFAULT_SCHEME, variant: nil, **system_arguments)
52
62
  @system_arguments = system_arguments
53
63
  @system_arguments[:tag] = fetch_or_fallback(TAG_OPTIONS, tag, DEFAULT_TAG)
54
64
  @system_arguments[:classes] = class_names(
@@ -7,6 +7,7 @@ module Primer
7
7
  #
8
8
  # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
9
9
  renders_one :main, lambda { |**system_arguments|
10
+ deny_tag_argument(**system_arguments)
10
11
  system_arguments[:classes] = class_names("flex-shrink-0", system_arguments[:classes])
11
12
  system_arguments[:col] = (@responsive ? [12, nil, @main_col] : @main_col)
12
13
  system_arguments[:mb] = (@responsive ? [4, nil, 0] : nil)
@@ -33,7 +33,7 @@ module Primer
33
33
  # @param time_zone_name [Symbol] <%= one_of(Primer::LocalTime::TEXT_TYPE_OPTIONS) %>
34
34
  # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
35
35
  def initialize(datetime:, initial_text: nil, weekday: DEFAULT_TEXT_TYPE, year: DEFAULT_DIGIT_TYPE, month: DEFAULT_TEXT_TYPE, day: DEFAULT_DIGIT_TYPE, hour: DEFAULT_DIGIT_TYPE, minute: DEFAULT_DIGIT_TYPE, second: DEFAULT_DIGIT_TYPE, time_zone_name: DEFAULT_TEXT_TYPE, **system_arguments)
36
- @system_arguments = system_arguments
36
+ @system_arguments = deny_tag_argument(**system_arguments)
37
37
 
38
38
  @datetime = datetime
39
39
 
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Primer
4
- # Use `Markdown` to wrap markdown content
4
+ # Use `Markdown` to wrap markdown content.
5
5
  class Markdown < Primer::Component
6
6
  status :beta
7
7
 
@@ -26,6 +26,7 @@ module Primer
26
26
  # @param selected [Boolean] Whether the item is the current selection
27
27
  # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
28
28
  renders_many :items, lambda { |href:, selected: false, **system_arguments|
29
+ deny_tag_argument(**system_arguments)
29
30
  system_arguments[:tag] = :a
30
31
  system_arguments[:href] = href
31
32
  system_arguments[:"aria-current"] = :page if selected
@@ -58,7 +59,7 @@ module Primer
58
59
  #
59
60
  # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
60
61
  def initialize(**system_arguments)
61
- @system_arguments = system_arguments
62
+ @system_arguments = deny_tag_argument(**system_arguments)
62
63
  @system_arguments[:tag] = :nav
63
64
  @system_arguments[:classes] = class_names(
64
65
  "menu",
@@ -20,6 +20,7 @@ module Primer
20
20
  renders_one :panel, lambda { |**system_arguments|
21
21
  return unless @with_panel
22
22
 
23
+ deny_tag_argument(**system_arguments)
23
24
  system_arguments[:id] = @panel_id
24
25
  system_arguments[:tag] = :div
25
26
  system_arguments[:role] ||= :tabpanel
@@ -65,8 +65,10 @@ module Primer
65
65
  # Filter out classify options to prevent them from becoming invalid html attributes.
66
66
  # Note height and width are both classify options and valid html attributes.
67
67
  octicon_options = {
68
- height: SIZE_MAPPINGS[fetch_or_fallback(SIZE_OPTIONS, size, SIZE_DEFAULT)]
69
- }.merge(@system_arguments.slice(:height, :width))
68
+ height: @system_arguments[:height] || SIZE_MAPPINGS[fetch_or_fallback(SIZE_OPTIONS, size, SIZE_DEFAULT)],
69
+ width: @system_arguments[:width]
70
+ }
71
+ octicon_options.compact!
70
72
 
71
73
  @icon = Octicons::Octicon.new(icon_key, octicon_options)
72
74
  Primer::Octicon::Cache.set(cache_key, @icon)
@@ -6,8 +6,8 @@ module Primer
6
6
  # OcticonSymbols renders a symbol dictionary using a list of <%= link_to_octicons %>.
7
7
  class OcticonSymbolsComponent < Primer::Component
8
8
  # @example Symbol dictionary
9
- # <%= render(Primer::OcticonComponent.new(icon: :check, use_symbol: true, color: :icon_success)) %>
10
- # <%= render(Primer::OcticonComponent.new(icon: :check, use_symbol: true, color: :text_danger)) %>
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
11
  # <%= render(Primer::OcticonComponent.new(icon: :check, use_symbol: true, size: :medium)) %>
12
12
  # <%= render(Primer::OcticonSymbolsComponent.new(icons: [{ symbol: :check }, { symbol: :check, size: :medium }])) %>
13
13
  #
@@ -108,15 +108,15 @@ module Primer
108
108
  #
109
109
  # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
110
110
  def initialize(**system_arguments)
111
- @system_arguments = system_arguments
111
+ @system_arguments = deny_tag_argument(**system_arguments)
112
112
  @system_arguments[:tag] = :div
113
113
  @system_arguments[:classes] = class_names(
114
114
  system_arguments[:classes],
115
115
  "Popover"
116
116
  )
117
117
  @system_arguments[:position] ||= :relative
118
- @system_arguments[:right] = false unless system_arguments.key?(:right)
119
- @system_arguments[:left] = false unless system_arguments.key?(:left)
118
+ @system_arguments[:right] = false unless @system_arguments.delete(:right)
119
+ @system_arguments[:left] = false unless @system_arguments.delete(:left)
120
120
  end
121
121
 
122
122
  def render?
@@ -10,7 +10,8 @@ module Primer
10
10
  # @param percentage [Integer] The percent complete
11
11
  # @param bg [Symbol] The background color
12
12
  # @param kwargs [Hash] The same arguments as <%= link_to_system_arguments_docs %>.
13
- renders_many :items, lambda { |percentage: 0, bg: :success_inverse, **system_arguments|
13
+ renders_many :items, lambda { |percentage: 0, bg: :success_emphasis, **system_arguments|
14
+ deny_tag_argument(**system_arguments)
14
15
  system_arguments[:tag] = :span
15
16
  system_arguments[:bg] = bg
16
17
  system_arguments[:style] = join_style_arguments(system_arguments[:style], "width: #{percentage}%;")
@@ -35,25 +36,25 @@ module Primer
35
36
  #
36
37
  # @example Small
37
38
  # <%= render(Primer::ProgressBarComponent.new(size: :small)) do |component| %>
38
- # <% component.item(bg: :info_inverse, percentage: 50) %>
39
+ # <% component.item(bg: :accent_emphasis, percentage: 50) %>
39
40
  # <% end %>
40
41
  #
41
42
  # @example Large
42
43
  # <%= render(Primer::ProgressBarComponent.new(size: :large)) do |component| %>
43
- # <% component.item(bg: :danger_inverse, percentage: 75) %>
44
+ # <% component.item(bg: :danger_emphasis, percentage: 75) %>
44
45
  # <% end %>
45
46
  #
46
47
  # @example Multiple items
47
48
  # <%= render(Primer::ProgressBarComponent.new) do |component| %>
48
49
  # <% component.item(percentage: 10) %>
49
- # <% component.item(bg: :info_inverse, percentage: 20) %>
50
- # <% component.item(bg: :danger_inverse, percentage: 30) %>
50
+ # <% component.item(bg: :accent_emphasis, percentage: 20) %>
51
+ # <% component.item(bg: :danger_emphasis, percentage: 30) %>
51
52
  # <% end %>
52
53
  #
53
54
  # @param size [Symbol] <%= one_of(Primer::ProgressBarComponent::SIZE_OPTIONS) %> Increases height.
54
55
  # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
55
56
  def initialize(size: SIZE_DEFAULT, **system_arguments)
56
- @system_arguments = system_arguments
57
+ @system_arguments = deny_tag_argument(**system_arguments)
57
58
  @system_arguments[:classes] = class_names(
58
59
  @system_arguments[:classes],
59
60
  "Progress",
@@ -1,7 +1,4 @@
1
- <span role="status">
2
- <span class="sr-only">Loading</span>
3
- <%= render Primer::BaseComponent.new(**@system_arguments) do %>
4
- <circle cx="8" cy="8" r="7" stroke="currentColor" stroke-opacity="0.25" stroke-width="2" vector-effect="non-scaling-stroke" />
5
- <path d="M15 8a7.002 7.002 0 00-7-7" stroke="currentColor" stroke-width="2" stroke-linecap="round" vector-effect="non-scaling-stroke" />
6
- <% end %>
7
- </span>
1
+ <%= render Primer::BaseComponent.new(**@system_arguments) do %>
2
+ <circle cx="8" cy="8" r="7" stroke="currentColor" stroke-opacity="0.25" stroke-width="2" vector-effect="non-scaling-stroke" />
3
+ <path d="M15 8a7.002 7.002 0 00-7-7" stroke="currentColor" stroke-width="2" stroke-linecap="round" vector-effect="non-scaling-stroke" />
4
+ <% end %>
@@ -30,7 +30,7 @@ module Primer
30
30
  # @param style [String] Custom element styles.
31
31
  # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
32
32
  def initialize(size: DEFAULT_SIZE, style: DEFAULT_STYLE, **system_arguments)
33
- @system_arguments = system_arguments
33
+ @system_arguments = deny_tag_argument(**system_arguments)
34
34
  @system_arguments[:tag] = :svg
35
35
  @system_arguments[:style] ||= style
36
36
  @system_arguments[:animation] = :rotate
@@ -36,6 +36,7 @@ module Primer
36
36
  #
37
37
  # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
38
38
  renders_one :actions, lambda { |**system_arguments|
39
+ deny_tag_argument(**system_arguments)
39
40
  system_arguments[:tag] = :div
40
41
  system_arguments[:classes] = class_names(system_arguments[:classes], "Subhead-actions")
41
42
 
@@ -46,6 +47,7 @@ module Primer
46
47
  #
47
48
  # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
48
49
  renders_one :description, lambda { |**system_arguments|
50
+ deny_tag_argument(**system_arguments)
49
51
  system_arguments[:tag] = :div
50
52
  system_arguments[:classes] = class_names(system_arguments[:classes], "Subhead-description")
51
53
 
@@ -111,7 +113,7 @@ module Primer
111
113
  # @param hide_border [Boolean] Whether to hide the border under the heading.
112
114
  # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
113
115
  def initialize(spacious: false, hide_border: false, **system_arguments)
114
- @system_arguments = system_arguments
116
+ @system_arguments = deny_tag_argument(**system_arguments)
115
117
 
116
118
  @system_arguments[:tag] = :div
117
119
  @system_arguments[:classes] =
@@ -26,7 +26,7 @@ module Primer
26
26
  #
27
27
  # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
28
28
  def initialize(**system_arguments)
29
- @system_arguments = system_arguments
29
+ @system_arguments = deny_tag_argument(**system_arguments)
30
30
  @system_arguments[:tag] = "tab-container"
31
31
  end
32
32
 
@@ -12,7 +12,7 @@ module Primer
12
12
  # @param micro [Boolean] If true then the text will be formatted in "micro" mode, using as few characters as possible
13
13
  # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
14
14
  def initialize(time:, micro: false, **system_arguments)
15
- @system_arguments = system_arguments
15
+ @system_arguments = deny_tag_argument(**system_arguments)
16
16
  @system_arguments[:datetime] = time.utc.iso8601
17
17
  @system_arguments[:classes] = class_names("no-wrap", @system_arguments[:classes])
18
18
  @system_arguments[:tag] = "time-ago"
@@ -27,6 +27,7 @@ module Primer
27
27
  #
28
28
  # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
29
29
  renders_one :body, lambda { |**system_arguments|
30
+ deny_tag_argument(**system_arguments)
30
31
  system_arguments[:tag] = :div
31
32
  system_arguments[:classes] = class_names(
32
33
  "TimelineItem-body",
@@ -40,7 +41,7 @@ module Primer
40
41
  # <div style="padding-left: 60px">
41
42
  # <%= render(Primer::TimelineItemComponent.new) do |component| %>
42
43
  # <% component.avatar(src: "https://github.com/github.png", alt: "github") %>
43
- # <% component.badge(bg: :success_inverse, color: :text_white, icon: :check) %>
44
+ # <% component.badge(bg: :success_emphasis, color: :on_emphasis, icon: :check) %>
44
45
  # <% component.body { "Success!" } %>
45
46
  # <% end %>
46
47
  # </div>
@@ -48,7 +49,7 @@ module Primer
48
49
  # @param condensed [Boolean] Reduce the vertical padding and remove the background from the badge item. Most commonly used in commits.
49
50
  # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
50
51
  def initialize(condensed: false, **system_arguments)
51
- @system_arguments = system_arguments
52
+ @system_arguments = deny_tag_argument(**system_arguments)
52
53
  @system_arguments[:tag] = :div
53
54
  @system_arguments[:classes] = class_names(
54
55
  "TimelineItem",
@@ -67,7 +68,7 @@ module Primer
67
68
  def initialize(icon: nil, **system_arguments)
68
69
  @icon = icon
69
70
 
70
- @system_arguments = system_arguments
71
+ @system_arguments = deny_tag_argument(**system_arguments)
71
72
  @system_arguments[:tag] = :div
72
73
  @system_arguments[:classes] = class_names(
73
74
  "TimelineItem-badge",
@@ -72,6 +72,7 @@ module Primer
72
72
  @system_arguments = system_arguments
73
73
  @system_arguments[:tag] ||= :span # rubocop:disable Primer/NoTagMemoize
74
74
  @system_arguments[:aria] = { label: label }
75
+ @system_arguments[:skip_aria_label_check] = true
75
76
 
76
77
  @system_arguments[:classes] = class_names(
77
78
  @system_arguments[:classes],