primer_view_components 0.0.113 → 0.0.115

Sign up to get free protection for your applications and to get access to all the features.
Files changed (147) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +44 -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 +291 -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/markdown.rb +2 -283
  69. data/app/components/primer/menu_component.rb +2 -69
  70. data/app/components/primer/navigation/tab_component.rb +2 -2
  71. data/app/components/primer/octicon_component.rb +3 -81
  72. data/app/components/primer/octicon_symbols_component.rb +2 -52
  73. data/app/components/primer/primer.d.ts +2 -0
  74. data/app/components/primer/primer.js +2 -0
  75. data/app/components/primer/primer.pcss +2 -3
  76. data/app/components/primer/primer.ts +2 -0
  77. data/app/components/primer/spinner_component.rb +2 -38
  78. data/app/components/primer/state_component.rb +1 -0
  79. data/app/components/primer/subhead_component.rb +2 -0
  80. data/app/components/primer/tab_container_component.rb +2 -0
  81. data/app/components/primer/time_ago_component.rb +2 -1
  82. data/app/components/primer/timeline_item_component.rb +3 -2
  83. data/app/components/primer/tooltip.rb +1 -0
  84. data/app/components/primer/truncate.rb +2 -0
  85. data/app/forms/immediate_validation_form.rb +29 -0
  86. data/app/forms/multi_input_form.rb +4 -2
  87. data/app/lib/primer/css/layout.css +1 -378
  88. data/app/lib/primer/css/layout.css.json +1 -1
  89. data/app/lib/primer/octicon/cache.rb +1 -1
  90. data/app/lib/primer/view_helper.rb +1 -1
  91. data/lib/primer/deprecations.yml +30 -0
  92. data/lib/primer/forms/builder.rb +48 -8
  93. data/lib/primer/forms/check_box.html.erb +3 -1
  94. data/lib/primer/forms/dsl/input.rb +23 -1
  95. data/lib/primer/forms/dsl/multi_input.rb +6 -9
  96. data/lib/primer/forms/dsl/select_list_input.rb +1 -1
  97. data/lib/primer/forms/dsl/text_field_input.rb +31 -1
  98. data/lib/primer/forms/form_control.html.erb +17 -13
  99. data/lib/primer/forms/form_control.rb +2 -0
  100. data/lib/primer/forms/multi.html.erb +6 -2
  101. data/lib/primer/forms/primer_multi_input.d.ts +10 -0
  102. data/lib/primer/forms/primer_multi_input.js +45 -0
  103. data/lib/primer/forms/primer_multi_input.ts +46 -0
  104. data/lib/primer/forms/primer_text_field.d.ts +1 -0
  105. data/lib/primer/forms/primer_text_field.js +62 -0
  106. data/lib/primer/forms/primer_text_field.ts +48 -0
  107. data/lib/primer/forms/radio_button.html.erb +3 -1
  108. data/lib/primer/forms/text_field.html.erb +8 -8
  109. data/lib/primer/forms/text_field.rb +11 -0
  110. data/lib/primer/view_components/linters/close_button_component_migration_counter.rb +1 -1
  111. data/lib/primer/view_components/version.rb +1 -1
  112. data/lib/tasks/docs.rake +6 -6
  113. data/lib/tasks/helpers/ast_traverser.rb +1 -1
  114. data/previews/primer/alpha/action_list_preview.rb +1 -1
  115. data/previews/primer/alpha/auto_complete_preview.rb +62 -6
  116. data/previews/primer/alpha/layout_preview.rb +179 -6
  117. data/previews/primer/{menu_component_preview → alpha/menu_preview}/default.html.erb +3 -3
  118. data/previews/primer/{menu_component_preview → alpha/menu_preview}/playground.html.erb +3 -3
  119. data/previews/primer/alpha/menu_preview.rb +14 -0
  120. data/previews/primer/alpha/toggle_switch_preview.rb +11 -9
  121. data/previews/primer/beta/auto_complete_preview/with_submit_button.html.erb +1 -1
  122. data/previews/primer/beta/auto_complete_preview.rb +19 -17
  123. data/previews/primer/{markdown_preview.rb → beta/markdown_preview.rb} +14 -12
  124. data/previews/primer/beta/octicon_preview.rb +24 -0
  125. data/previews/primer/beta/spinner_preview.rb +22 -0
  126. data/previews/primer/forms/forms_preview/immediate_validation_form.html.erb +3 -0
  127. data/previews/primer/forms/forms_preview/multi_input_form.html.erb +12 -1
  128. data/previews/primer/forms/forms_preview.rb +2 -0
  129. data/previews/primer/url_helpers.rb +15 -0
  130. data/static/arguments.json +178 -178
  131. data/static/audited_at.json +5 -0
  132. data/static/constants.json +50 -40
  133. data/static/statuses.json +12 -7
  134. metadata +34 -24
  135. data/app/components/primer/beta/button_group.css +0 -1
  136. data/app/components/primer/beta/button_group.css.json +0 -1
  137. data/app/components/primer/beta/button_group.css.map +0 -1
  138. data/app/components/primer/beta/button_group.pcss +0 -92
  139. data/app/components/primer/button_component.css +0 -1
  140. data/app/components/primer/button_component.css.json +0 -1
  141. data/app/components/primer/button_component.css.map +0 -1
  142. data/app/components/primer/button_component.pcss +0 -557
  143. data/app/components/primer/menu_component.css.json +0 -1
  144. data/app/components/primer/menu_component.css.map +0 -1
  145. data/previews/primer/menu_component_preview.rb +0 -12
  146. data/previews/primer/octicon_component_preview.rb +0 -22
  147. data/previews/primer/spinner_component_preview.rb +0 -20
@@ -0,0 +1,291 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Primer
4
+ module Beta
5
+ # Use `Markdown` to wrap markdown content.
6
+ class Markdown < Primer::Component
7
+ warn_on_deprecated_slot_setter
8
+ status :beta
9
+
10
+ DEFAULT_TAG = :div
11
+ TAG_OPTIONS = [DEFAULT_TAG, :article, :td].freeze
12
+ # @example Default
13
+ # <%= render(Primer::Beta::Markdown.new) do %>
14
+ # <p>Text can be <b>bold</b>, <i>italic</i>, or <s>strikethrough</s>. <a href="https://github.com">Links </a> should be blue with no underlines (unless hovered over).</p>
15
+ #
16
+ # <p>There should be whitespace between paragraphs. There should be whitespace between paragraphs. There should be whitespace between paragraphs. There should be whitespace between paragraphs.</p>
17
+ #
18
+ # <p>There should be whitespace between paragraphs. There should be whitespace between paragraphs. There should be whitespace between paragraphs. There should be whitespace between paragraphs.</p>
19
+ #
20
+ # <blockquote>
21
+ # <p>There should be no margin above this first sentence.</p>
22
+ # <p>Blockquotes should be a lighter gray with a gray border along the left side.</p>
23
+ # <p>There should be no margin below this final sentence.</p>
24
+ # </blockquote>
25
+ #
26
+ # <h1>Header 1</h1>
27
+ #
28
+ # <p>This is a normal paragraph following a header. Bacon ipsum dolor sit amet t-bone doner shank drumstick, pork belly porchetta chuck sausage brisket ham hock rump pig. Chuck kielbasa leberkas, pork bresaola ham hock filet mignon cow shoulder short ribs biltong.</p>
29
+ #
30
+ # <h2>Header 2</h2>
31
+ #
32
+ # <blockquote>This is a blockquote following a header. Bacon ipsum dolor sit amet t-bone doner shank drumstick, pork belly porchetta chuck sausage brisket ham hock rump pig. Chuck kielbasa leberkas, pork bresaola ham hock filet mignon cow shoulder short ribs biltong.</blockquote>
33
+ #
34
+ # <h3>Header 3</h3>
35
+ #
36
+ # <pre><code>This is a code block following a header.</code></pre>
37
+ #
38
+ # <h4>Header 4</h4>
39
+ #
40
+ # <ul>
41
+ # <li>This is an unordered list following a header.</li>
42
+ # <li>This is an unordered list following a header.</li>
43
+ # <li>This is an unordered list following a header.</li>
44
+ # </ul>
45
+ #
46
+ # <h5>Header 5</h5>
47
+ #
48
+ # <ol>
49
+ # <li>This is an ordered list following a header.</li>
50
+ # <li>This is an ordered list following a header.</li>
51
+ # <li>This is an ordered list following a header.</li>
52
+ # </ol>
53
+ #
54
+ # <h6>Header 6</h6>
55
+ #
56
+ # <table>
57
+ # <thead>
58
+ # <tr>
59
+ # <th>What</th>
60
+ # <th>Follows</th>
61
+ # </tr>
62
+ # </thead>
63
+ # <tbody>
64
+ # <tr>
65
+ # <td>A table</td>
66
+ # <td>A header</td>
67
+ # </tr>
68
+ # <tr>
69
+ # <td>A table</td>
70
+ # <td>A header</td>
71
+ # </tr>
72
+ # <tr>
73
+ # <td>A table</td>
74
+ # <td>A header</td>
75
+ # </tr>
76
+ # </tbody>
77
+ # </table>
78
+ #
79
+ # <hr />
80
+ #
81
+ # <p>There's a horizontal rule above and below this.</p>
82
+ #
83
+ # <hr />
84
+ #
85
+ # <p>Here is an unordered list:</p>
86
+ #
87
+ # <ul>
88
+ # <li>Salt-n-Pepa</li>
89
+ # <li>Bel Biv DeVoe</li>
90
+ # <li>Kid 'N Play</li>
91
+ # </ul>
92
+ #
93
+ # <p>And an ordered list:</p>
94
+ #
95
+ # <ol>
96
+ # <li>Michael Jackson</li>
97
+ # <li>Michael Bolton</li>
98
+ # <li>Michael Bublé</li>
99
+ # </ol>
100
+ #
101
+ # <p>And an unordered task list:</p>
102
+ #
103
+ # <ul>
104
+ # <li><input type="checkbox" id="create-markdown" checked /><label for="create-markdown">Create a sample markdown document</label><br></li>
105
+ # <li><input type="checkbox" id="tasks-list" checked /><label for="tasks-list">Add tasks list to it</label><br></li>
106
+ # <li><input type="checkbox" id="take-vacation" checked /><label for="take-vacation">Take a vacation</label><br></li>
107
+ # </ul>
108
+ #
109
+ # <p>And a "mixed" task list:</p>
110
+ #
111
+ # <ul>
112
+ # <li><input type="checkbox"id="steal-underpants"/><label for="steal-underpants">Steal underpants</label></li>
113
+ # <li>?</li>
114
+ # <li><input type="checkbox"id="profit"/><label for="profit">Profit!</label></li>
115
+ # </ul>
116
+ #
117
+ # And a nested list:
118
+ #
119
+ # <ul>
120
+ # <li>Jackson 5
121
+ # <ul>
122
+ # <li>Michael</li>
123
+ # <li>Tito</li>
124
+ # <li>Jackie</li>
125
+ # <li>Marlon</li>
126
+ # <li>Jermaine</li>
127
+ # </ul>
128
+ # </li>
129
+ # <li>TMNT
130
+ # <ul>
131
+ # <li>Leonardo</li>
132
+ # <li>Michelangelo</li>
133
+ # <li>Donatello</li>
134
+ # <li>Raphael</li>
135
+ # </ul>
136
+ # </li>
137
+ # </ul>
138
+ #
139
+ # <p>Definition lists can be used with HTML syntax. Definition terms are bold and italic.</p>
140
+ #
141
+ # <dl>
142
+ # <dt>Name</dt>
143
+ # <dd>Godzilla</dd>
144
+ # <dt>Born</dt>
145
+ # <dd>1952</dd>
146
+ # <dt>Birthplace</dt>
147
+ # <dd>Japan</dd>
148
+ # <dt>Color</dt>
149
+ # <dd>Green</dd>
150
+ # </dl>
151
+ #
152
+ # <hr />
153
+ #
154
+ # <p>Tables should have bold headings and alternating shaded rows.</p>
155
+ #
156
+ # <table>
157
+ # <thead>
158
+ # <tr>
159
+ # <th>Artist</th>
160
+ # <th>Album</th>
161
+ # <th>Year</th>
162
+ # </tr>
163
+ # </thead>
164
+ # <tbody>
165
+ # <tr>
166
+ # <td>David Bowie</td>
167
+ # <td>Scary Monsters</td>
168
+ # <td>1980</td>
169
+ # </tr>
170
+ # <tr>
171
+ # <td>Prince</td>
172
+ # <td>Purple Rain</td>
173
+ # <td>1982</td>
174
+ # </tr>
175
+ # <tr>
176
+ # <td>Beastie Boys</td>
177
+ # <td>License to Ill</td>
178
+ # <td>1986</td>
179
+ # </tr>
180
+ # <tr>
181
+ # <td>Janet Jackson</td>
182
+ # <td>Rhythm Nation 1814</td>
183
+ # <td>1989</td>
184
+ # </tr>
185
+ # </tbody>
186
+ # </table>
187
+ #
188
+ # <p>If a table is too wide, it should condense down and/or scroll horizontally.</p>
189
+ #
190
+ # <table>
191
+ # <thead>
192
+ # <tr>
193
+ # <th>Artist</th>
194
+ # <th>Album</th>
195
+ # <th>Year</th>
196
+ # <th>Label</th>
197
+ # <th>Songs</th>
198
+ # </tr>
199
+ # </thead>
200
+ # <tbody>
201
+ # <tr>
202
+ # <td>David Bowie</td>
203
+ # <td>Scary Monsters</td>
204
+ # <td>1980</td>
205
+ # <td>RCA Records</td>
206
+ # <td>It's No Game (No. 1), Up the Hill Backwards, Scary Monsters (And Super Creeps), Ashes to Ashes, Fashion, Teenage Wildlife, Scream Like a Baby, Kingdom Come, Because You're Young, It's No Game (No. 2)</td>
207
+ # </tr>
208
+ # <tr>
209
+ # <td>Prince</td>
210
+ # <td>Purple Rain</td>
211
+ # <td>1982</td>
212
+ # <td>Warner Brothers Records</td>
213
+ # <td>Let's Go Crazy, Take Me With U, The Beautiful Ones, Computer Blue, Darling Nikki, When Doves Cry, I Would Die 4 U, Baby I'm a Star, Purple Rain</td>
214
+ # </tr>
215
+ # <tr>
216
+ # <td>Beastie Boys</td>
217
+ # <td>License to Ill</td>
218
+ # <td>1986</td>
219
+ # <td>Def Jam</td>
220
+ # <td>Rhymin &amp; Stealin, The New Style, She's Crafty, Posse in Effect, Slow Ride, Girls, Fight for Your Right, No Sleep till Brooklyn, Paul Revere, "Hold It Now, Hit It", Brass Monkey, Slow and Low, Time to Get Ill</td>
221
+ # </tr>
222
+ # <tr>
223
+ # <td>Janet Jackson</td>
224
+ # <td>Rhythm Nation 1814</td>
225
+ # <td>1989</td>
226
+ # <td>A&amp;M</td>
227
+ # <td>Interlude: Pledge, Rhythm Nation, Interlude: T.V., State of the World, Interlude: Race, The Knowledge, Interlude: Let's Dance, Miss You Much, Interlude: Come Back, Love Will Never Do (Without You), Livin' in a World (They Didn't Make), Alright, Interlude: Hey Baby, Escapade, Interlude: No Acid, Black Cat, Lonely, Come Back to Me, Someday Is Tonight, Interlude: Livin'...In Complete Darkness</td>
228
+ # </tr>
229
+ # </tbody>
230
+ # </table>
231
+ #
232
+ # <hr />
233
+ #
234
+ # <p>Code snippets like <code>var foo = "bar";</code> can be shown inline.</p>
235
+ #
236
+ # <p>Also, <code>this should vertically align</code> <s><code>with this</code></s> <s>and this</s>.</p>
237
+ #
238
+ # <p>Code can also be shown in a block element.</p>
239
+ #
240
+ # <pre><code>var foo = "bar";</code></pre>
241
+ #
242
+ # <p>Code can also use syntax highlighting.</p>
243
+ #
244
+ # <pre><code>var foo = "bar";</code></pre>
245
+ #
246
+ # <pre tabindex="0"><code>Long, single-line code blocks should not wrap. They should horizontally scroll if they are too long. This line should be long enough to demonstrate this.</code></pre>
247
+ #
248
+ # <pre tabindex="0"><code>var foo = "The same thing is true for code with syntax highlighting. A single line of code should horizontally scroll if it is really long.";</code></pre>
249
+ #
250
+ # <p>Inline code inside table cells should still be distinguishable.</p>
251
+ #
252
+ # <table>
253
+ # <thead>
254
+ # <tr>
255
+ # <th>Language</th>
256
+ # <th>Code</th>
257
+ # </tr>
258
+ # </thead>
259
+ # <tbody>
260
+ # <tr>
261
+ # <td>JavasScript</td>
262
+ # <td><code>var foo = "bar";</code></td>
263
+ # </tr>
264
+ # <tr>
265
+ # <td>Ruby</td>
266
+ # <td><code>foo = "bar"</code></td>
267
+ # </tr>
268
+ # </tbody>
269
+ # </table>
270
+ #
271
+ # <pre><code>This is the final element on the page and there should be no margin below this.</code></pre>
272
+ # <% end %>
273
+ #
274
+ # @param tag [Symbol] <%= one_of(Primer::Beta::Markdown::TAG_OPTIONS) %>
275
+ # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
276
+ def initialize(tag: DEFAULT_TAG, **system_arguments)
277
+ @system_arguments = system_arguments
278
+ @system_arguments[:tag] = fetch_or_fallback(TAG_OPTIONS, tag, DEFAULT_TAG)
279
+
280
+ @system_arguments[:classes] = class_names(
281
+ "markdown-body",
282
+ system_arguments[:classes]
283
+ )
284
+ end
285
+
286
+ def call
287
+ render(Primer::BaseComponent.new(**@system_arguments)) { content }
288
+ end
289
+ end
290
+ end
291
+ end
@@ -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