primer_view_components 0.0.41 → 0.0.46

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (79) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +265 -1
  3. data/app/assets/javascripts/primer_view_components.js +1 -1
  4. data/app/assets/javascripts/primer_view_components.js.map +1 -1
  5. data/app/components/primer/alpha/button_marketing.rb +70 -0
  6. data/app/components/primer/auto_complete.rb +99 -42
  7. data/app/components/primer/auto_complete/auto_complete.html.erb +1 -0
  8. data/app/components/primer/avatar_stack_component.rb +7 -1
  9. data/app/components/primer/base_component.rb +62 -26
  10. data/app/components/primer/beta/text.rb +27 -0
  11. data/app/components/primer/blankslate_component.html.erb +1 -0
  12. data/app/components/primer/blankslate_component.rb +64 -45
  13. data/app/components/primer/border_box_component.rb +3 -0
  14. data/app/components/primer/button_component.rb +3 -2
  15. data/app/components/primer/button_group.rb +1 -1
  16. data/app/components/primer/clipboard_copy.rb +25 -7
  17. data/app/components/primer/component.rb +5 -1
  18. data/app/components/primer/details_component.rb +18 -3
  19. data/app/components/primer/dropdown.d.ts +1 -0
  20. data/app/components/primer/{dropdown_component.html.erb → dropdown.html.erb} +2 -1
  21. data/app/components/primer/dropdown.js +1 -0
  22. data/app/components/primer/dropdown.rb +149 -0
  23. data/app/components/primer/dropdown.ts +1 -0
  24. data/app/components/primer/dropdown/menu.d.ts +1 -0
  25. data/app/components/primer/dropdown/menu.html.erb +25 -0
  26. data/app/components/primer/dropdown/menu.js +1 -0
  27. data/app/components/primer/dropdown/menu.rb +99 -0
  28. data/app/components/primer/dropdown/menu.ts +1 -0
  29. data/app/components/primer/heading_component.rb +1 -1
  30. data/app/components/primer/hidden_text_expander.rb +2 -2
  31. data/app/components/primer/icon_button.rb +1 -1
  32. data/app/components/primer/image_crop.rb +2 -2
  33. data/app/components/primer/markdown.rb +6 -2
  34. data/app/components/primer/menu_component.rb +7 -3
  35. data/app/components/primer/navigation/tab_component.rb +6 -6
  36. data/app/components/primer/octicon_component.rb +4 -3
  37. data/app/components/primer/popover_component.rb +2 -2
  38. data/app/components/primer/primer.d.ts +1 -0
  39. data/app/components/primer/primer.js +1 -0
  40. data/app/components/primer/primer.ts +1 -0
  41. data/app/components/primer/spinner_component.rb +2 -0
  42. data/app/components/primer/tab_nav_component.html.erb +4 -2
  43. data/app/components/primer/tab_nav_component.rb +48 -6
  44. data/app/components/primer/tooltip.rb +1 -1
  45. data/app/components/primer/truncate.rb +6 -2
  46. data/app/components/primer/underline_nav_component.html.erb +1 -1
  47. data/app/components/primer/underline_nav_component.rb +27 -5
  48. data/app/lib/primer/tabbed_component_helper.rb +2 -2
  49. data/{app/lib → lib}/primer/classify.rb +41 -35
  50. data/{app/lib → lib}/primer/classify/cache.rb +16 -35
  51. data/{app/lib → lib}/primer/classify/flex.rb +0 -0
  52. data/{app/lib → lib}/primer/classify/functional_background_colors.rb +2 -0
  53. data/{app/lib → lib}/primer/classify/functional_border_colors.rb +2 -0
  54. data/{app/lib → lib}/primer/classify/functional_colors.rb +0 -0
  55. data/{app/lib → lib}/primer/classify/functional_text_colors.rb +2 -0
  56. data/lib/primer/classify/grid.rb +45 -0
  57. data/lib/primer/classify/utilities.rb +137 -0
  58. data/lib/primer/classify/utilities.yml +1271 -0
  59. data/lib/primer/view_components.rb +1 -0
  60. data/lib/primer/view_components/engine.rb +2 -0
  61. data/lib/primer/view_components/linters.rb +3 -0
  62. data/lib/primer/view_components/linters/argument_mappers/button.rb +82 -0
  63. data/lib/primer/view_components/linters/argument_mappers/conversion_error.rb +10 -0
  64. data/lib/primer/view_components/linters/argument_mappers/system_arguments.rb +47 -0
  65. data/lib/primer/view_components/linters/button_component_migration_counter.rb +39 -0
  66. data/lib/primer/view_components/linters/flash_component_migration_counter.rb +16 -0
  67. data/lib/primer/view_components/linters/helpers.rb +191 -0
  68. data/lib/primer/view_components/version.rb +1 -1
  69. data/lib/tasks/docs.rake +180 -108
  70. data/lib/tasks/utilities.rake +105 -0
  71. data/lib/yard/docs_helper.rb +12 -2
  72. data/static/statuses.json +7 -5
  73. metadata +50 -20
  74. data/app/components/primer/button_marketing_component.rb +0 -68
  75. data/app/components/primer/dropdown/menu_component.html.erb +0 -12
  76. data/app/components/primer/dropdown/menu_component.rb +0 -46
  77. data/app/components/primer/dropdown_component.rb +0 -73
  78. data/app/components/primer/text_component.rb +0 -25
  79. data/app/lib/primer/classify/spacing.rb +0 -63
@@ -1,3 +1,4 @@
1
+ <%= label %>
1
2
  <%= render Primer::BaseComponent.new(**@system_arguments) do %>
2
3
  <%= input %>
3
4
  <%= icon %>
@@ -10,6 +10,9 @@ module Primer
10
10
 
11
11
  DEFAULT_TAG = :div
12
12
  TAG_OPTIONS = [DEFAULT_TAG, :span].freeze
13
+
14
+ DEFAULT_BODY_TAG = :div
15
+ BODY_TAG_OPTIONS = TAG_OPTIONS = [DEFAULT_TAG, :span].freeze
13
16
  # Required list of stacked avatars.
14
17
  #
15
18
  # @param kwargs [Hash] The same arguments as <%= link_to_component(Primer::AvatarComponent) %>.
@@ -40,6 +43,8 @@ module Primer
40
43
  # @param align [Symbol] <%= one_of(Primer::AvatarStackComponent::ALIGN_OPTIONS) %>
41
44
  # @param tooltipped [Boolean] Whether to add a tooltip to the stack or not.
42
45
  # @param body_arguments [Hash] Parameters to add to the Body. If `tooltipped` is set, has the same arguments as <%= link_to_component(Primer::Tooltip) %>.
46
+ # The default tag is <%= pretty_value(Primer::AvatarStackComponent::DEFAULT_BODY_TAG) %> but can be changed using `tag:`
47
+ # to <%= one_of(Primer::AvatarStackComponent::BODY_TAG_OPTIONS, lower: true) %>
43
48
  # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
44
49
  def initialize(tag: DEFAULT_TAG, align: ALIGN_DEFAULT, tooltipped: false, body_arguments: {}, **system_arguments)
45
50
  @align = fetch_or_fallback(ALIGN_OPTIONS, align, ALIGN_DEFAULT)
@@ -47,7 +52,8 @@ module Primer
47
52
  @tooltipped = tooltipped
48
53
  @body_arguments = body_arguments
49
54
 
50
- @body_arguments[:tag] ||= :div
55
+ body_tag = @body_arguments[:tag] || DEFAULT_BODY_TAG
56
+ @body_arguments[:tag] = fetch_or_fallback(BODY_TAG_OPTIONS, body_tag, DEFAULT_BODY_TAG)
51
57
  @body_arguments[:classes] = class_names(
52
58
  "AvatarStack-body",
53
59
  @body_arguments[:classes]
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "primer/classify"
4
+
3
5
  module Primer
4
6
  # All Primer ViewComponents accept a standard set of options called system arguments, mimicking the [styled-system API](https://styled-system.com/table) used by [Primer React](https://primer.style/components/system-props).
5
7
  #
@@ -43,7 +45,7 @@ module Primer
43
45
  #
44
46
  # | Name | Type | Description |
45
47
  # | :- | :- | :- |
46
- # | `animation` | Symbol | <%= one_of([:fade_in, :fade_out, :fade_up, :fade_down, :scale_in, :pulse, :grow_x, :grow]) %> |
48
+ # | `animation` | Symbol | <%= one_of(Primer::Classify::Utilities.mappings(:animation)) %> |
47
49
  #
48
50
  # ## Border
49
51
  #
@@ -61,7 +63,7 @@ module Primer
61
63
  #
62
64
  # | Name | Type | Description |
63
65
  # | :- | :- | :- |
64
- # | `bg` | String, Symbol | Background color. Accepts either a hex value as a String or <%= one_of(Primer::Classify::FunctionalBorderColors::OPTIONS, lower: true) %> |
66
+ # | `bg` | String, Symbol | Background color. Accepts either a hex value as a String or <%= one_of(Primer::Classify::FunctionalBackgroundColors::OPTIONS, lower: true) %> |
65
67
  # | `border_color` | Symbol | Border color. <%= one_of(Primer::Classify::FunctionalBorderColors::OPTIONS) %> |
66
68
  # | `color` | Symbol | Text color. <%= one_of(Primer::Classify::FunctionalTextColors::OPTIONS) %> |
67
69
  #
@@ -83,26 +85,28 @@ module Primer
83
85
  #
84
86
  # | Name | Type | Description |
85
87
  # | :- | :- | :- |
86
- # | `col` | Integer | Number of columns. |
88
+ # | `clearfix` | Boolean | Wether to assign the `clearfix` class. |
89
+ # | `col` | Integer | Number of columns. <%= one_of(Primer::Classify::Grid::COL_VALUES) %> |
90
+ # | `container` | Symbol | Size of the container. <%= one_of(Primer::Classify::Grid::CONTAINER_VALUES) %> |
87
91
  #
88
92
  # ## Layout
89
93
  #
90
94
  # | Name | Type | Description |
91
95
  # | :- | :- | :- |
92
- # | `display` | Symbol | <%= one_of([:none, :block, :flex, :inline, :inline_block, :inline_flex, :table, :table_cell]) %> |
96
+ # | `display` | Symbol | <%= one_of(Primer::Classify::Utilities.mappings(:display)) %> |
93
97
  # | `height` | Symbol | <%= one_of([:fit]) %> |
94
- # | `hide` | Symbol | Hide the element at a specific breakpoint. <%= one_of([:sm, :md, :lg, :xl]) %> |
95
- # | `v` | Symbol | Visibility. <%= one_of([:hidden, :visible]) %> |
96
- # | `vertical_align` | Symbol | <%= one_of([:baseline, :top, :middle, :bottom, :text_top, :text_bottom]) %> |
98
+ # | `hide` | Symbol | Hide the element at a specific breakpoint. <%= one_of(Primer::Classify::Utilities.mappings(:hide)) %> |
99
+ # | `visibility` | Symbol | Visibility. <%= one_of(Primer::Classify::Utilities.mappings(:visibility)) %> |
100
+ # | `vertical_align` | Symbol | <%= one_of(Primer::Classify::Utilities.mappings(:vertical_align)) %> |
97
101
  #
98
102
  # ## Position
99
103
  #
100
104
  # | Name | Type | Description |
101
105
  # | :- | :- | :- |
102
106
  # | `bottom` | Boolean | If `false`, sets `bottom: 0`. |
103
- # | `float` | Symbol | <%= one_of([:left, :right]) %> |
107
+ # | `float` | Symbol | <%= one_of(Primer::Classify::Utilities.mappings(:float)) %> |
104
108
  # | `left` | Boolean | If `false`, sets `left: 0`. |
105
- # | `position` | Symbol | <%= one_of([:relative, :absolute, :fixed]) %> |
109
+ # | `position` | Symbol | <%= one_of(Primer::Classify::Utilities.mappings(:position)) %> |
106
110
  # | `right` | Boolean | If `false`, sets `right: 0`. |
107
111
  # | `top` | Boolean | If `false`, sets `top: 0`. |
108
112
  #
@@ -110,30 +114,33 @@ module Primer
110
114
  #
111
115
  # | Name | Type | Description |
112
116
  # | :- | :- | :- |
113
- # | `m` | Integer | Margin. <%= one_of(Primer::Classify::Spacing::MAPPINGS[:m]) %> |
114
- # | `mb` | Integer | Margin bottom. <%= one_of(Primer::Classify::Spacing::MAPPINGS[:mb]) %> |
115
- # | `ml` | Integer | Margin left. <%= one_of(Primer::Classify::Spacing::MAPPINGS[:ml]) %> |
116
- # | `mr` | Integer | Margin right. <%= one_of(Primer::Classify::Spacing::MAPPINGS[:mr]) %> |
117
- # | `mt` | Integer | Margin top. <%= one_of(Primer::Classify::Spacing::MAPPINGS[:mt]) %> |
118
- # | `mx` | Integer | Horizontal margins. <%= one_of(Primer::Classify::Spacing::MAPPINGS[:mx]) %> |
119
- # | `my` | Integer | Vertical margins. <%= one_of(Primer::Classify::Spacing::MAPPINGS[:my]) %> |
120
- # | `p` | Integer | Padding. <%= one_of(Primer::Classify::Spacing::MAPPINGS[:p]) %> |
121
- # | `pb` | Integer | Padding bottom. <%= one_of(Primer::Classify::Spacing::MAPPINGS[:pb]) %> |
122
- # | `pl` | Integer | Padding left. <%= one_of(Primer::Classify::Spacing::MAPPINGS[:pl]) %> |
123
- # | `pr` | Integer | Padding right. <%= one_of(Primer::Classify::Spacing::MAPPINGS[:pr]) %> |
124
- # | `pt` | Integer | Padding left. <%= one_of(Primer::Classify::Spacing::MAPPINGS[:pt]) %> |
125
- # | `px` | Integer | Horizontal padding. <%= one_of(Primer::Classify::Spacing::MAPPINGS[:px]) %> |
126
- # | `py` | Integer | Vertical padding. <%= one_of(Primer::Classify::Spacing::MAPPINGS[:py]) %> |
117
+ # | `m` | Integer | Margin. <%= one_of(Primer::Classify::Utilities.mappings(:m)) %> |
118
+ # | `mb` | Integer | Margin bottom. <%= one_of(Primer::Classify::Utilities.mappings(:mb)) %> |
119
+ # | `ml` | Integer | Margin left. <%= one_of(Primer::Classify::Utilities.mappings(:ml)) %> |
120
+ # | `mr` | Integer | Margin right. <%= one_of(Primer::Classify::Utilities.mappings(:mr)) %> |
121
+ # | `mt` | Integer | Margin top. <%= one_of(Primer::Classify::Utilities.mappings(:mt)) %> |
122
+ # | `mx` | Integer | Horizontal margins. <%= one_of(Primer::Classify::Utilities.mappings(:mx)) %> |
123
+ # | `my` | Integer | Vertical margins. <%= one_of(Primer::Classify::Utilities.mappings(:my)) %> |
124
+ # | `p` | Integer | Padding. <%= one_of(Primer::Classify::Utilities.mappings(:p)) %> |
125
+ # | `pb` | Integer | Padding bottom. <%= one_of(Primer::Classify::Utilities.mappings(:pb)) %> |
126
+ # | `pl` | Integer | Padding left. <%= one_of(Primer::Classify::Utilities.mappings(:pl)) %> |
127
+ # | `pr` | Integer | Padding right. <%= one_of(Primer::Classify::Utilities.mappings(:pr)) %> |
128
+ # | `pt` | Integer | Padding left. <%= one_of(Primer::Classify::Utilities.mappings(:pt)) %> |
129
+ # | `px` | Integer | Horizontal padding. <%= one_of(Primer::Classify::Utilities.mappings(:px)) %> |
130
+ # | `py` | Integer | Vertical padding. <%= one_of(Primer::Classify::Utilities.mappings(:py)) %> |
127
131
  #
128
132
  # ## Typography
129
133
  #
130
134
  # | Name | Type | Description |
131
135
  # | :- | :- | :- |
132
- # | `font_size` | String, Integer | <%= one_of(["00", 0, 1, 2, 3, 4, 5, 6]) %> |
133
- # | `font_weight` | Symbol | Font weight. <%= one_of([:light, :normal, :bold]) %> |
136
+ # | `font_family` | Symbol | Font weight. <%= one_of([:mono]) %> |
137
+ # | `font_size` | String, Integer, Symbol | <%= one_of(["00", 0, 1, 2, 3, 4, 5, 6, :small, :normal]) %> |
138
+ # | `font_style` | Symbol | Font weight. <%= one_of([:italic]) %> |
139
+ # | `font_weight` | Symbol | Font weight. <%= one_of([:light, :normal, :bold, :emphasized]) %> |
134
140
  # | `text_align` | Symbol | Text alignment. <%= one_of([:left, :right, :center]) %> |
141
+ # | `text_transform` | Symbol | Text alignment. <%= one_of([:uppercase]) %> |
135
142
  # | `underline` | Boolean | Whether text should be underlined. |
136
- # | `word_break` | Symbol | Whether to break words on line breaks. Can only be `:break_all`. |
143
+ # | `word_break` | Symbol | Whether to break words on line breaks. <%= one_of(Primer::Classify::Utilities.mappings(:word_break)) %> |
137
144
  #
138
145
  # ## Other
139
146
  #
@@ -145,6 +152,35 @@ module Primer
145
152
  @tag = tag
146
153
  @system_arguments = system_arguments
147
154
 
155
+ raise ArgumentError, "`class` is an invalid argument. Use `classes` instead." if system_arguments.key?(:class) && !Rails.env.production?
156
+
157
+ if (denylist = system_arguments[:system_arguments_denylist])
158
+ if force_system_arguments? && !ENV["PRIMER_WARNINGS_DISABLED"]
159
+ # Convert denylist from:
160
+ # { [:p, :pt] => "message" } to:
161
+ # { p: "message", pt: "message" }
162
+ unpacked_denylist =
163
+ denylist.each_with_object({}) do |(keys, value), memo|
164
+ keys.each { |key| memo[key] = value }
165
+ end
166
+
167
+ violations = unpacked_denylist.keys & @system_arguments.keys
168
+
169
+ if violations.any?
170
+ message = "Found #{violations.count} #{'violation'.pluralize(violations)}:"
171
+ violations.each do |violation|
172
+ message += "\n The #{violation} system argument is not allowed here. #{unpacked_denylist[violation]}"
173
+ end
174
+
175
+ raise(ArgumentError, message)
176
+ end
177
+ end
178
+
179
+ # Remove :system_arguments_denylist key and any denied keys from system arguments
180
+ @system_arguments.except!(:system_arguments_denylist)
181
+ @system_arguments.except!(*denylist.keys.flatten)
182
+ end
183
+
148
184
  @result = Primer::Classify.call(**@system_arguments.merge(classes: classes))
149
185
 
150
186
  @system_arguments[:"data-view-component"] = true
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Primer
4
+ module Beta
5
+ # `Text` is a wrapper component that will apply typography styles to the text inside.
6
+ class Text < Primer::Component
7
+ status :beta
8
+
9
+ DEFAULT_TAG = :span
10
+
11
+ # @example Default
12
+ # <%= render(Primer::Beta::Text.new(tag: :p, font_weight: :bold)) { "Bold Text" } %>
13
+ # <%= render(Primer::Beta::Text.new(tag: :p, color: :text_danger)) { "Danger Text" } %>
14
+ #
15
+ # @param tag [Symbol]
16
+ # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
17
+ def initialize(tag: DEFAULT_TAG, **system_arguments)
18
+ @system_arguments = system_arguments
19
+ @system_arguments[:tag] = tag
20
+ end
21
+
22
+ def call
23
+ render(Primer::BaseComponent.new(**@system_arguments)) { content }
24
+ end
25
+ end
26
+ end
27
+ end
@@ -1,3 +1,4 @@
1
+ <%# erblint:counter ButtonComponentMigrationCounter 1 %>
1
2
  <%= render Primer::BaseComponent.new(**@system_arguments) do %>
2
3
  <% if spinner.present? %>
3
4
  <%= spinner %>
@@ -23,61 +23,79 @@ module Primer
23
23
  # description: "Description",
24
24
  # ) %>
25
25
  #
26
- # @example Icon|Add an `icon` to give additional context. Refer to the [Octicons](https://primer.style/octicons/) documentation to choose an icon.
27
- # <%= render Primer::BlankslateComponent.new(
28
- # icon: :globe,
29
- # title: "Title",
30
- # description: "Description",
31
- # ) %>
26
+ # @example Icon
27
+ # @description
28
+ # Add an `icon` to give additional context. Refer to the [Octicons](https://primer.style/octicons/) documentation to choose an icon.
29
+ # @code
30
+ # <%= render Primer::BlankslateComponent.new(
31
+ # icon: :globe,
32
+ # title: "Title",
33
+ # description: "Description",
34
+ # ) %>
32
35
  #
33
- # @example Loading|Add a [SpinnerComponent](https://primer.style/view-components/components/spinner) to the blankslate in place of an icon.
34
- # <%= render Primer::BlankslateComponent.new(
35
- # title: "Title",
36
- # description: "Description",
37
- # ) do |component| %>
38
- # <% component.spinner(size: :large) %>
39
- # <% end %>
36
+ # @example Loading
37
+ # @description
38
+ # Add a [SpinnerComponent](https://primer.style/view-components/components/spinner) to the blankslate in place of an icon.
39
+ # @code
40
+ # <%= render Primer::BlankslateComponent.new(
41
+ # title: "Title",
42
+ # description: "Description",
43
+ # ) do |component| %>
44
+ # <% component.spinner(size: :large) %>
45
+ # <% end %>
40
46
  #
41
- # @example Custom content|Pass custom content as a block in place of `description`.
42
- # <%= render Primer::BlankslateComponent.new(
43
- # title: "Title",
44
- # ) do %>
45
- # <em>Your custom content here</em>
46
- # <% end %>
47
+ # @example Custom content
48
+ # @description
49
+ # Pass custom content as a block in place of `description`.
50
+ # @code
51
+ # <%= render Primer::BlankslateComponent.new(
52
+ # title: "Title",
53
+ # ) do %>
54
+ # <em>Your custom content here</em>
55
+ # <% end %>
47
56
  #
48
- # @example Action button|Provide a button to guide users to take action from the blankslate. The button appears below the description and custom content.
49
- # <%= render Primer::BlankslateComponent.new(
50
- # icon: :book,
51
- # title: "Welcome to the mona wiki!",
52
- # description: "Wikis provide a place in your repository to lay out the roadmap of your project, show the current status, and document software better, together.",
57
+ # @example Action button
58
+ # @description
59
+ # Provide a button to guide users to take action from the blankslate. The button appears below the description and custom content.
60
+ # @code
61
+ # <%= render Primer::BlankslateComponent.new(
62
+ # icon: :book,
63
+ # title: "Welcome to the mona wiki!",
64
+ # description: "Wikis provide a place in your repository to lay out the roadmap of your project, show the current status, and document software better, together.",
53
65
  #
54
- # button_text: "Create the first page",
55
- # button_url: "https://github.com/monalisa/mona/wiki/_new",
56
- # ) %>
66
+ # button_text: "Create the first page",
67
+ # button_url: "https://github.com/monalisa/mona/wiki/_new",
68
+ # ) %>
57
69
  #
58
- # @example Link|Add an additional link to help users learn more about a feature. The link will be shown at the very bottom:
59
- # <%= render Primer::BlankslateComponent.new(
60
- # icon: :book,
61
- # title: "Welcome to the mona wiki!",
62
- # description: "Wikis provide a place in your repository to lay out the roadmap of your project, show the current status, and document software better, together.",
63
- # link_text: "Learn more about wikis",
64
- # link_url: "https://docs.github.com/en/github/building-a-strong-community/about-wikis",
65
- # ) %>
70
+ # @example Link
71
+ # @description
72
+ # Add an additional link to help users learn more about a feature. The link will be shown at the very bottom:
73
+ # @code
74
+ # <%= render Primer::BlankslateComponent.new(
75
+ # icon: :book,
76
+ # title: "Welcome to the mona wiki!",
77
+ # description: "Wikis provide a place in your repository to lay out the roadmap of your project, show the current status, and document software better, together.",
78
+ # link_text: "Learn more about wikis",
79
+ # link_url: "https://docs.github.com/en/github/building-a-strong-community/about-wikis",
80
+ # ) %>
66
81
  #
67
- # @example Variations|There are a few variations of how the Blankslate appears: `narrow` adds a maximum width, `large` increases the font size, and `spacious` adds extra padding.
68
- # <%= render Primer::BlankslateComponent.new(
69
- # icon: :book,
70
- # title: "Welcome to the mona wiki!",
71
- # description: "Wikis provide a place in your repository to lay out the roadmap of your project, show the current status, and document software better, together.",
72
- # narrow: true,
73
- # large: true,
74
- # spacious: true,
75
- # ) %>
82
+ # @example Variations
83
+ # @description
84
+ # There are a few variations of how the Blankslate appears: `narrow` adds a maximum width, `large` increases the font size, and `spacious` adds extra padding.
85
+ # @code
86
+ # <%= render Primer::BlankslateComponent.new(
87
+ # icon: :book,
88
+ # title: "Welcome to the mona wiki!",
89
+ # description: "Wikis provide a place in your repository to lay out the roadmap of your project, show the current status, and document software better, together.",
90
+ # narrow: true,
91
+ # large: true,
92
+ # spacious: true,
93
+ # ) %>
76
94
  #
77
95
  # @param title [String] Text that appears in a larger bold font.
78
96
  # @param title_tag [Symbol] HTML tag to use for title.
79
97
  # @param icon [Symbol] Octicon icon to use at top of component.
80
- # @param icon_size [Symbol] <%= one_of(Primer::OcticonComponent::SIZE_MAPPINGS) %>
98
+ # @param icon_size [Symbol] <%= one_of(Primer::OcticonComponent::SIZE_MAPPINGS, sort: false) %>
81
99
  # @param image_src [String] Image to display.
82
100
  # @param image_alt [String] Alt text for image.
83
101
  # @param description [String] Text that appears below the title. Typically a whole sentence.
@@ -89,6 +107,7 @@ module Primer
89
107
  # @param narrow [Boolean] Adds a maximum width.
90
108
  # @param large [Boolean] Increases the font size.
91
109
  # @param spacious [Boolean] Adds extra padding.
110
+ # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
92
111
  def initialize(
93
112
  title: "",
94
113
  title_tag: :h3,
@@ -11,6 +11,7 @@ module Primer
11
11
  :condensed => "Box--condensed",
12
12
  :spacious => "Box--spacious"
13
13
  }.freeze
14
+ PADDING_SUGGESTION = "Perhaps you could consider using :padding options of #{PADDING_MAPPINGS.keys.to_sentence}?"
14
15
 
15
16
  # Optional Header.
16
17
  #
@@ -111,6 +112,8 @@ module Primer
111
112
  PADDING_MAPPINGS[fetch_or_fallback(PADDING_MAPPINGS.keys, padding, DEFAULT_PADDING)],
112
113
  system_arguments[:classes]
113
114
  )
115
+
116
+ @system_arguments[:system_arguments_denylist] = { [:p, :pt, :pb, :pr, :pl] => PADDING_SUGGESTION }
114
117
  end
115
118
 
116
119
  def render?
@@ -78,11 +78,12 @@ module Primer
78
78
  #
79
79
  # @param scheme [Symbol] <%= one_of(Primer::ButtonComponent::SCHEME_OPTIONS) %>
80
80
  # @param variant [Symbol] <%= one_of(Primer::ButtonComponent::VARIANT_OPTIONS) %>
81
- # @param tag [Symbol] <%= one_of(Primer::BaseButton::TAG_OPTIONS) %>
82
- # @param type [Symbol] <%= one_of(Primer::BaseButton::TYPE_OPTIONS) %>
81
+ # @param tag [Symbol] (Primer::BaseButton::DEFAULT_TAG) <%= one_of(Primer::BaseButton::TAG_OPTIONS) %>
82
+ # @param type [Symbol] (Primer::BaseButton::DEFAULT_TYPE) <%= one_of(Primer::BaseButton::TYPE_OPTIONS) %>
83
83
  # @param group_item [Boolean] Whether button is part of a ButtonGroup.
84
84
  # @param block [Boolean] Whether button is full-width with `display: block`.
85
85
  # @param caret [Boolean] Whether or not to render a caret.
86
+ # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
86
87
  def initialize(
87
88
  scheme: DEFAULT_SCHEME,
88
89
  variant: DEFAULT_VARIANT,
@@ -22,7 +22,7 @@ module Primer
22
22
  # <% component.button(scheme: :primary) { "Primary" } %>
23
23
  # <% component.button(scheme: :danger) { "Danger" } %>
24
24
  # <% component.button(scheme: :outline) { "Outline" } %>
25
- # <% component.button(classes: "my-class") { "Custom class" } %>
25
+ # <% component.button(classes: "custom-class") { "Custom class" } %>
26
26
  # <% end %>
27
27
  #
28
28
  # @example Variants
@@ -2,25 +2,43 @@
2
2
 
3
3
  module Primer
4
4
  # Use `ClipboardCopy` to copy element text content or input values to the clipboard.
5
+ #
6
+ # @accessibility
7
+ # Always set an accessible label to help the user interact with the component.
5
8
  class ClipboardCopy < Primer::Component
6
9
  status :alpha
7
10
 
8
11
  # @example Default
9
- # <%= render(Primer::ClipboardCopy.new(value: "Text to copy", label: "Copy text to the system clipboard")) %>
12
+ # <%= render(Primer::ClipboardCopy.new(value: "Text to copy", "aria-label": "Copy text to the system clipboard")) %>
10
13
  #
11
14
  # @example With text instead of icons
12
- # <%= render(Primer::ClipboardCopy.new(value: "Text to copy", label: "Copy text to the system clipboard")) do %>
15
+ # <%= render(Primer::ClipboardCopy.new(value: "Text to copy", "aria-label": "Copy text to the system clipboard")) do %>
13
16
  # Click to copy!
14
17
  # <% end %>
15
18
  #
16
- # @param label [String] String that will be read to screenreaders when the component is focused
17
- # @param value [String] Text to copy into the users clipboard when they click the component
19
+ # @example Copying from an element
20
+ # <%= render(Primer::ClipboardCopy.new(for: "blob-path", "aria-label": "Copy text to the system clipboard")) %>
21
+ # <div id="blob-path">src/index.js</div>
22
+ #
23
+ # @param aria-label [String] String that will be read to screenreaders when the component is focused
24
+ # @param value [String] Text to copy into the users clipboard when they click the component.
25
+ # @param for [String] Element id from where to get the copied value.
18
26
  # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
19
- def initialize(label:, value:, **system_arguments)
27
+ def initialize(value: nil, **system_arguments)
20
28
  @system_arguments = system_arguments
29
+ @value = value
30
+
31
+ validate!
32
+
21
33
  @system_arguments[:tag] = "clipboard-copy"
22
- @system_arguments[:value] = value
23
- @system_arguments[:"aria-label"] = label
34
+ @system_arguments[:value] = value if value.present?
35
+ end
36
+
37
+ private
38
+
39
+ def validate!
40
+ validate_aria_label
41
+ raise ArgumentError, "Must provide either `value` or `for`" if @value.nil? && @system_arguments[:for].nil?
24
42
  end
25
43
  end
26
44
  end
@@ -5,7 +5,7 @@ require "view_component/version"
5
5
  module Primer
6
6
  # @private
7
7
  class Component < ViewComponent::Base
8
- include ViewComponent::SlotableV2 unless ViewComponent::VERSION::STRING.to_f >= 2.28
8
+ include ViewComponent::SlotableV2 unless ViewComponent::Base < ViewComponent::SlotableV2
9
9
  include ClassNameHelper
10
10
  include FetchOrFallbackHelper
11
11
  include TestSelectorHelper
@@ -15,6 +15,10 @@ module Primer
15
15
 
16
16
  private
17
17
 
18
+ def force_system_arguments?
19
+ Rails.application.config.primer_view_components.force_system_arguments
20
+ end
21
+
18
22
  def deprecated_component_warning(new_class: nil, version: nil)
19
23
  return if Rails.env.production? || silence_deprecations?
20
24