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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +44 -0
- data/app/assets/javascripts/primer_view_components.js +1 -1
- data/app/assets/javascripts/primer_view_components.js.map +1 -1
- data/app/assets/styles/primer_view_components.css +2 -2
- data/app/assets/styles/primer_view_components.css.map +1 -1
- data/app/components/primer/alpha/action_list/divider.rb +2 -0
- data/app/components/primer/alpha/action_list/heading.rb +2 -0
- data/app/components/primer/alpha/action_list/item.rb +8 -6
- data/app/components/primer/alpha/action_list.rb +1 -0
- data/app/components/primer/alpha/auto_complete/auto_complete.html.erb +1 -1
- data/app/components/primer/alpha/auto_complete/item.rb +1 -0
- data/app/components/primer/alpha/auto_complete.rb +3 -2
- data/app/components/primer/alpha/banner.html.erb +1 -1
- data/app/components/primer/alpha/banner.rb +1 -0
- data/app/components/primer/alpha/button_marketing.rb +2 -0
- data/app/components/primer/alpha/dialog.rb +3 -0
- data/app/components/primer/alpha/image.rb +1 -0
- data/app/components/primer/alpha/image_crop.html.erb +1 -1
- data/app/components/primer/alpha/layout.css +1 -0
- data/app/components/primer/alpha/layout.css.json +1 -0
- data/app/components/primer/alpha/layout.css.map +1 -0
- data/app/components/primer/alpha/layout.pcss +268 -0
- data/app/components/primer/{menu_component.css → alpha/menu.css} +0 -0
- data/app/components/primer/alpha/menu.css.json +1 -0
- data/app/components/primer/alpha/menu.css.map +1 -0
- data/app/components/primer/{menu_component.html.erb → alpha/menu.html.erb} +0 -0
- data/app/components/primer/{menu_component.pcss → alpha/menu.pcss} +0 -0
- data/app/components/primer/alpha/menu.rb +76 -0
- data/app/components/primer/{octicon_symbols_component.html.erb → alpha/octicon_symbols.html.erb} +0 -0
- data/app/components/primer/alpha/octicon_symbols.rb +61 -0
- data/app/components/primer/alpha/text_field.rb +1 -0
- data/app/components/primer/alpha/toggle_switch.html.erb +2 -2
- data/app/components/primer/alpha/toggle_switch.rb +2 -0
- data/app/components/primer/alpha/tool_tip.js +77 -69
- data/app/components/primer/alpha/tool_tip.ts +63 -51
- data/app/components/primer/alpha/tooltip.rb +2 -0
- data/app/components/primer/beta/auto_complete/item.rb +4 -4
- data/app/components/primer/beta/auto_complete.rb +3 -3
- data/app/components/primer/beta/avatar.rb +1 -0
- data/app/components/primer/beta/base_button.rb +1 -0
- data/app/components/primer/beta/blankslate.rb +5 -5
- data/app/components/primer/beta/button.rb +7 -7
- data/app/components/primer/beta/clipboard_copy.html.erb +2 -2
- data/app/components/primer/beta/clipboard_copy.rb +1 -0
- data/app/components/primer/beta/close_button.rb +2 -1
- data/app/components/primer/beta/counter.rb +1 -0
- data/app/components/primer/beta/heading.rb +1 -0
- data/app/components/primer/beta/icon_button.html.erb +1 -1
- data/app/components/primer/beta/icon_button.rb +1 -0
- data/app/components/primer/beta/label.rb +1 -0
- data/app/components/primer/beta/markdown.rb +291 -0
- data/app/components/primer/{octicon_component.html.erb → beta/octicon.html.erb} +0 -0
- data/app/components/primer/beta/octicon.rb +88 -0
- data/app/components/primer/beta/relative_time.rb +2 -1
- data/app/components/primer/{spinner_component.html.erb → beta/spinner.html.erb} +0 -0
- data/app/components/primer/beta/spinner.rb +46 -0
- data/app/components/primer/beta/text.rb +1 -0
- data/app/components/primer/blankslate_component.rb +3 -3
- data/app/components/primer/box.rb +1 -0
- data/app/components/primer/button_component.rb +3 -3
- data/app/components/primer/conditional_wrapper.rb +2 -0
- data/app/components/primer/hellip_button.rb +2 -0
- data/app/components/primer/icon_button.html.erb +2 -2
- data/app/components/primer/icon_button.rb +1 -0
- data/app/components/primer/layout_component.rb +2 -0
- data/app/components/primer/local_time.rb +3 -0
- data/app/components/primer/markdown.rb +2 -283
- data/app/components/primer/menu_component.rb +2 -69
- data/app/components/primer/navigation/tab_component.rb +2 -2
- data/app/components/primer/octicon_component.rb +3 -81
- data/app/components/primer/octicon_symbols_component.rb +2 -52
- data/app/components/primer/primer.d.ts +2 -0
- data/app/components/primer/primer.js +2 -0
- data/app/components/primer/primer.pcss +2 -3
- data/app/components/primer/primer.ts +2 -0
- data/app/components/primer/spinner_component.rb +2 -38
- data/app/components/primer/state_component.rb +1 -0
- data/app/components/primer/subhead_component.rb +2 -0
- data/app/components/primer/tab_container_component.rb +2 -0
- data/app/components/primer/time_ago_component.rb +2 -1
- data/app/components/primer/timeline_item_component.rb +3 -2
- data/app/components/primer/tooltip.rb +1 -0
- data/app/components/primer/truncate.rb +2 -0
- data/app/forms/immediate_validation_form.rb +29 -0
- data/app/forms/multi_input_form.rb +4 -2
- data/app/lib/primer/css/layout.css +1 -378
- data/app/lib/primer/css/layout.css.json +1 -1
- data/app/lib/primer/octicon/cache.rb +1 -1
- data/app/lib/primer/view_helper.rb +1 -1
- data/lib/primer/deprecations.yml +30 -0
- data/lib/primer/forms/builder.rb +48 -8
- data/lib/primer/forms/check_box.html.erb +3 -1
- data/lib/primer/forms/dsl/input.rb +23 -1
- data/lib/primer/forms/dsl/multi_input.rb +6 -9
- data/lib/primer/forms/dsl/select_list_input.rb +1 -1
- data/lib/primer/forms/dsl/text_field_input.rb +31 -1
- data/lib/primer/forms/form_control.html.erb +17 -13
- data/lib/primer/forms/form_control.rb +2 -0
- data/lib/primer/forms/multi.html.erb +6 -2
- data/lib/primer/forms/primer_multi_input.d.ts +10 -0
- data/lib/primer/forms/primer_multi_input.js +45 -0
- data/lib/primer/forms/primer_multi_input.ts +46 -0
- data/lib/primer/forms/primer_text_field.d.ts +1 -0
- data/lib/primer/forms/primer_text_field.js +62 -0
- data/lib/primer/forms/primer_text_field.ts +48 -0
- data/lib/primer/forms/radio_button.html.erb +3 -1
- data/lib/primer/forms/text_field.html.erb +8 -8
- data/lib/primer/forms/text_field.rb +11 -0
- data/lib/primer/view_components/linters/close_button_component_migration_counter.rb +1 -1
- data/lib/primer/view_components/version.rb +1 -1
- data/lib/tasks/docs.rake +6 -6
- data/lib/tasks/helpers/ast_traverser.rb +1 -1
- data/previews/primer/alpha/action_list_preview.rb +1 -1
- data/previews/primer/alpha/auto_complete_preview.rb +62 -6
- data/previews/primer/alpha/layout_preview.rb +179 -6
- data/previews/primer/{menu_component_preview → alpha/menu_preview}/default.html.erb +3 -3
- data/previews/primer/{menu_component_preview → alpha/menu_preview}/playground.html.erb +3 -3
- data/previews/primer/alpha/menu_preview.rb +14 -0
- data/previews/primer/alpha/toggle_switch_preview.rb +11 -9
- data/previews/primer/beta/auto_complete_preview/with_submit_button.html.erb +1 -1
- data/previews/primer/beta/auto_complete_preview.rb +19 -17
- data/previews/primer/{markdown_preview.rb → beta/markdown_preview.rb} +14 -12
- data/previews/primer/beta/octicon_preview.rb +24 -0
- data/previews/primer/beta/spinner_preview.rb +22 -0
- data/previews/primer/forms/forms_preview/immediate_validation_form.html.erb +3 -0
- data/previews/primer/forms/forms_preview/multi_input_form.html.erb +12 -1
- data/previews/primer/forms/forms_preview.rb +2 -0
- data/previews/primer/url_helpers.rb +15 -0
- data/static/arguments.json +178 -178
- data/static/audited_at.json +5 -0
- data/static/constants.json +50 -40
- data/static/statuses.json +12 -7
- metadata +34 -24
- data/app/components/primer/beta/button_group.css +0 -1
- data/app/components/primer/beta/button_group.css.json +0 -1
- data/app/components/primer/beta/button_group.css.map +0 -1
- data/app/components/primer/beta/button_group.pcss +0 -92
- data/app/components/primer/button_component.css +0 -1
- data/app/components/primer/button_component.css.json +0 -1
- data/app/components/primer/button_component.css.map +0 -1
- data/app/components/primer/button_component.pcss +0 -557
- data/app/components/primer/menu_component.css.json +0 -1
- data/app/components/primer/menu_component.css.map +0 -1
- data/previews/primer/menu_component_preview.rb +0 -12
- data/previews/primer/octicon_component_preview.rb +0 -22
- data/previews/primer/spinner_component_preview.rb +0 -20
@@ -1,288 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Primer
|
4
|
-
|
5
|
-
|
6
|
-
status :beta
|
7
|
-
|
8
|
-
DEFAULT_TAG = :div
|
9
|
-
TAG_OPTIONS = [DEFAULT_TAG, :article, :td].freeze
|
10
|
-
# @example Default
|
11
|
-
# <%= render(Primer::Markdown.new) do %>
|
12
|
-
# <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>
|
13
|
-
#
|
14
|
-
# <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>
|
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
|
-
# <blockquote>
|
19
|
-
# <p>There should be no margin above this first sentence.</p>
|
20
|
-
# <p>Blockquotes should be a lighter gray with a gray border along the left side.</p>
|
21
|
-
# <p>There should be no margin below this final sentence.</p>
|
22
|
-
# </blockquote>
|
23
|
-
#
|
24
|
-
# <h1>Header 1</h1>
|
25
|
-
#
|
26
|
-
# <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>
|
27
|
-
#
|
28
|
-
# <h2>Header 2</h2>
|
29
|
-
#
|
30
|
-
# <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>
|
31
|
-
#
|
32
|
-
# <h3>Header 3</h3>
|
33
|
-
#
|
34
|
-
# <pre><code>This is a code block following a header.</code></pre>
|
35
|
-
#
|
36
|
-
# <h4>Header 4</h4>
|
37
|
-
#
|
38
|
-
# <ul>
|
39
|
-
# <li>This is an unordered list following a header.</li>
|
40
|
-
# <li>This is an unordered list following a header.</li>
|
41
|
-
# <li>This is an unordered list following a header.</li>
|
42
|
-
# </ul>
|
43
|
-
#
|
44
|
-
# <h5>Header 5</h5>
|
45
|
-
#
|
46
|
-
# <ol>
|
47
|
-
# <li>This is an ordered list following a header.</li>
|
48
|
-
# <li>This is an ordered list following a header.</li>
|
49
|
-
# <li>This is an ordered list following a header.</li>
|
50
|
-
# </ol>
|
51
|
-
#
|
52
|
-
# <h6>Header 6</h6>
|
53
|
-
#
|
54
|
-
# <table>
|
55
|
-
# <thead>
|
56
|
-
# <tr>
|
57
|
-
# <th>What</th>
|
58
|
-
# <th>Follows</th>
|
59
|
-
# </tr>
|
60
|
-
# </thead>
|
61
|
-
# <tbody>
|
62
|
-
# <tr>
|
63
|
-
# <td>A table</td>
|
64
|
-
# <td>A header</td>
|
65
|
-
# </tr>
|
66
|
-
# <tr>
|
67
|
-
# <td>A table</td>
|
68
|
-
# <td>A header</td>
|
69
|
-
# </tr>
|
70
|
-
# <tr>
|
71
|
-
# <td>A table</td>
|
72
|
-
# <td>A header</td>
|
73
|
-
# </tr>
|
74
|
-
# </tbody>
|
75
|
-
# </table>
|
76
|
-
#
|
77
|
-
# <hr />
|
78
|
-
#
|
79
|
-
# <p>There's a horizontal rule above and below this.</p>
|
80
|
-
#
|
81
|
-
# <hr />
|
82
|
-
#
|
83
|
-
# <p>Here is an unordered list:</p>
|
84
|
-
#
|
85
|
-
# <ul>
|
86
|
-
# <li>Salt-n-Pepa</li>
|
87
|
-
# <li>Bel Biv DeVoe</li>
|
88
|
-
# <li>Kid 'N Play</li>
|
89
|
-
# </ul>
|
90
|
-
#
|
91
|
-
# <p>And an ordered list:</p>
|
92
|
-
#
|
93
|
-
# <ol>
|
94
|
-
# <li>Michael Jackson</li>
|
95
|
-
# <li>Michael Bolton</li>
|
96
|
-
# <li>Michael Bublé</li>
|
97
|
-
# </ol>
|
98
|
-
#
|
99
|
-
# <p>And an unordered task list:</p>
|
100
|
-
#
|
101
|
-
# <ul>
|
102
|
-
# <li><input type="checkbox" id="create-markdown" checked /><label for="create-markdown">Create a sample markdown document</label><br></li>
|
103
|
-
# <li><input type="checkbox" id="tasks-list" checked /><label for="tasks-list">Add tasks list to it</label><br></li>
|
104
|
-
# <li><input type="checkbox" id="take-vacation" checked /><label for="take-vacation">Take a vacation</label><br></li>
|
105
|
-
# </ul>
|
106
|
-
#
|
107
|
-
# <p>And a "mixed" task list:</p>
|
108
|
-
#
|
109
|
-
# <ul>
|
110
|
-
# <li><input type="checkbox"id="steal-underpants"/><label for="steal-underpants">Steal underpants</label></li>
|
111
|
-
# <li>?</li>
|
112
|
-
# <li><input type="checkbox"id="profit"/><label for="profit">Profit!</label></li>
|
113
|
-
# </ul>
|
114
|
-
#
|
115
|
-
# And a nested list:
|
116
|
-
#
|
117
|
-
# <ul>
|
118
|
-
# <li>Jackson 5
|
119
|
-
# <ul>
|
120
|
-
# <li>Michael</li>
|
121
|
-
# <li>Tito</li>
|
122
|
-
# <li>Jackie</li>
|
123
|
-
# <li>Marlon</li>
|
124
|
-
# <li>Jermaine</li>
|
125
|
-
# </ul>
|
126
|
-
# </li>
|
127
|
-
# <li>TMNT
|
128
|
-
# <ul>
|
129
|
-
# <li>Leonardo</li>
|
130
|
-
# <li>Michelangelo</li>
|
131
|
-
# <li>Donatello</li>
|
132
|
-
# <li>Raphael</li>
|
133
|
-
# </ul>
|
134
|
-
# </li>
|
135
|
-
# </ul>
|
136
|
-
#
|
137
|
-
# <p>Definition lists can be used with HTML syntax. Definition terms are bold and italic.</p>
|
138
|
-
#
|
139
|
-
# <dl>
|
140
|
-
# <dt>Name</dt>
|
141
|
-
# <dd>Godzilla</dd>
|
142
|
-
# <dt>Born</dt>
|
143
|
-
# <dd>1952</dd>
|
144
|
-
# <dt>Birthplace</dt>
|
145
|
-
# <dd>Japan</dd>
|
146
|
-
# <dt>Color</dt>
|
147
|
-
# <dd>Green</dd>
|
148
|
-
# </dl>
|
149
|
-
#
|
150
|
-
# <hr />
|
151
|
-
#
|
152
|
-
# <p>Tables should have bold headings and alternating shaded rows.</p>
|
153
|
-
#
|
154
|
-
# <table>
|
155
|
-
# <thead>
|
156
|
-
# <tr>
|
157
|
-
# <th>Artist</th>
|
158
|
-
# <th>Album</th>
|
159
|
-
# <th>Year</th>
|
160
|
-
# </tr>
|
161
|
-
# </thead>
|
162
|
-
# <tbody>
|
163
|
-
# <tr>
|
164
|
-
# <td>David Bowie</td>
|
165
|
-
# <td>Scary Monsters</td>
|
166
|
-
# <td>1980</td>
|
167
|
-
# </tr>
|
168
|
-
# <tr>
|
169
|
-
# <td>Prince</td>
|
170
|
-
# <td>Purple Rain</td>
|
171
|
-
# <td>1982</td>
|
172
|
-
# </tr>
|
173
|
-
# <tr>
|
174
|
-
# <td>Beastie Boys</td>
|
175
|
-
# <td>License to Ill</td>
|
176
|
-
# <td>1986</td>
|
177
|
-
# </tr>
|
178
|
-
# <tr>
|
179
|
-
# <td>Janet Jackson</td>
|
180
|
-
# <td>Rhythm Nation 1814</td>
|
181
|
-
# <td>1989</td>
|
182
|
-
# </tr>
|
183
|
-
# </tbody>
|
184
|
-
# </table>
|
185
|
-
#
|
186
|
-
# <p>If a table is too wide, it should condense down and/or scroll horizontally.</p>
|
187
|
-
#
|
188
|
-
# <table>
|
189
|
-
# <thead>
|
190
|
-
# <tr>
|
191
|
-
# <th>Artist</th>
|
192
|
-
# <th>Album</th>
|
193
|
-
# <th>Year</th>
|
194
|
-
# <th>Label</th>
|
195
|
-
# <th>Songs</th>
|
196
|
-
# </tr>
|
197
|
-
# </thead>
|
198
|
-
# <tbody>
|
199
|
-
# <tr>
|
200
|
-
# <td>David Bowie</td>
|
201
|
-
# <td>Scary Monsters</td>
|
202
|
-
# <td>1980</td>
|
203
|
-
# <td>RCA Records</td>
|
204
|
-
# <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>
|
205
|
-
# </tr>
|
206
|
-
# <tr>
|
207
|
-
# <td>Prince</td>
|
208
|
-
# <td>Purple Rain</td>
|
209
|
-
# <td>1982</td>
|
210
|
-
# <td>Warner Brothers Records</td>
|
211
|
-
# <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>
|
212
|
-
# </tr>
|
213
|
-
# <tr>
|
214
|
-
# <td>Beastie Boys</td>
|
215
|
-
# <td>License to Ill</td>
|
216
|
-
# <td>1986</td>
|
217
|
-
# <td>Def Jam</td>
|
218
|
-
# <td>Rhymin & 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>
|
219
|
-
# </tr>
|
220
|
-
# <tr>
|
221
|
-
# <td>Janet Jackson</td>
|
222
|
-
# <td>Rhythm Nation 1814</td>
|
223
|
-
# <td>1989</td>
|
224
|
-
# <td>A&M</td>
|
225
|
-
# <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>
|
226
|
-
# </tr>
|
227
|
-
# </tbody>
|
228
|
-
# </table>
|
229
|
-
#
|
230
|
-
# <hr />
|
231
|
-
#
|
232
|
-
# <p>Code snippets like <code>var foo = "bar";</code> can be shown inline.</p>
|
233
|
-
#
|
234
|
-
# <p>Also, <code>this should vertically align</code> <s><code>with this</code></s> <s>and this</s>.</p>
|
235
|
-
#
|
236
|
-
# <p>Code can also be shown in a block element.</p>
|
237
|
-
#
|
238
|
-
# <pre><code>var foo = "bar";</code></pre>
|
239
|
-
#
|
240
|
-
# <p>Code can also use syntax highlighting.</p>
|
241
|
-
#
|
242
|
-
# <pre><code>var foo = "bar";</code></pre>
|
243
|
-
#
|
244
|
-
# <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>
|
245
|
-
#
|
246
|
-
# <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>
|
247
|
-
#
|
248
|
-
# <p>Inline code inside table cells should still be distinguishable.</p>
|
249
|
-
#
|
250
|
-
# <table>
|
251
|
-
# <thead>
|
252
|
-
# <tr>
|
253
|
-
# <th>Language</th>
|
254
|
-
# <th>Code</th>
|
255
|
-
# </tr>
|
256
|
-
# </thead>
|
257
|
-
# <tbody>
|
258
|
-
# <tr>
|
259
|
-
# <td>JavasScript</td>
|
260
|
-
# <td><code>var foo = "bar";</code></td>
|
261
|
-
# </tr>
|
262
|
-
# <tr>
|
263
|
-
# <td>Ruby</td>
|
264
|
-
# <td><code>foo = "bar"</code></td>
|
265
|
-
# </tr>
|
266
|
-
# </tbody>
|
267
|
-
# </table>
|
268
|
-
#
|
269
|
-
# <pre><code>This is the final element on the page and there should be no margin below this.</code></pre>
|
270
|
-
# <% end %>
|
271
|
-
#
|
272
|
-
# @param tag [Symbol] <%= one_of(Primer::Markdown::TAG_OPTIONS) %>
|
273
|
-
# @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
|
274
|
-
def initialize(tag: DEFAULT_TAG, **system_arguments)
|
275
|
-
@system_arguments = system_arguments
|
276
|
-
@system_arguments[:tag] = fetch_or_fallback(TAG_OPTIONS, tag, DEFAULT_TAG)
|
277
|
-
|
278
|
-
@system_arguments[:classes] = class_names(
|
279
|
-
"markdown-body",
|
280
|
-
system_arguments[:classes]
|
281
|
-
)
|
282
|
-
end
|
283
|
-
|
284
|
-
def call
|
285
|
-
render(Primer::BaseComponent.new(**@system_arguments)) { content }
|
286
|
-
end
|
4
|
+
class Markdown < Primer::Beta::Markdown
|
5
|
+
status :deprecated
|
287
6
|
end
|
288
7
|
end
|
@@ -1,74 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Primer
|
4
|
-
|
5
|
-
|
6
|
-
HEADING_TAG_OPTIONS = [:h1, :h2, :h3, :h4, :h5, :h6].freeze
|
7
|
-
HEADING_TAG_FALLBACK = :h2
|
8
|
-
|
9
|
-
# Optional menu heading
|
10
|
-
#
|
11
|
-
# @param tag [Symbol] <%= one_of(Primer::MenuComponent::HEADING_TAG_OPTIONS) %>
|
12
|
-
# @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
|
13
|
-
renders_one :heading, lambda { |tag:, **system_arguments|
|
14
|
-
system_arguments[:tag] = fetch_or_fallback(HEADING_TAG_OPTIONS, tag, HEADING_TAG_FALLBACK)
|
15
|
-
system_arguments[:classes] = class_names(
|
16
|
-
"menu-heading",
|
17
|
-
system_arguments[:classes]
|
18
|
-
)
|
19
|
-
|
20
|
-
Primer::BaseComponent.new(**system_arguments)
|
21
|
-
}
|
22
|
-
|
23
|
-
# Required list of navigational links
|
24
|
-
#
|
25
|
-
# @param href [String] URL to be used for the Link
|
26
|
-
# @param selected [Boolean] Whether the item is the current selection
|
27
|
-
# @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
|
28
|
-
renders_many :items, lambda { |href:, selected: false, **system_arguments|
|
29
|
-
deny_tag_argument(**system_arguments)
|
30
|
-
system_arguments[:tag] = :a
|
31
|
-
system_arguments[:href] = href
|
32
|
-
system_arguments[:"aria-current"] = :page if selected
|
33
|
-
system_arguments[:classes] = class_names(
|
34
|
-
"menu-item",
|
35
|
-
system_arguments[:classes]
|
36
|
-
)
|
37
|
-
|
38
|
-
Primer::BaseComponent.new(**system_arguments)
|
39
|
-
}
|
40
|
-
|
41
|
-
# @example Default
|
42
|
-
# <%= render(Primer::MenuComponent.new) do |c| %>
|
43
|
-
# <% c.with_heading(tag: :h2) do %>
|
44
|
-
# Heading
|
45
|
-
# <% end %>
|
46
|
-
# <% c.with_item(selected: true, href: "#url") do %>
|
47
|
-
# Item 1
|
48
|
-
# <% end %>
|
49
|
-
# <% c.with_item(href: "#url") do %>
|
50
|
-
# <%= render(Primer::OcticonComponent.new("check")) %>
|
51
|
-
# With Icon
|
52
|
-
# <% end %>
|
53
|
-
# <% c.with_item(href: "#url") do %>
|
54
|
-
# <%= render(Primer::OcticonComponent.new("check")) %>
|
55
|
-
# With Icon and Counter
|
56
|
-
# <%= render(Primer::Beta::Counter.new(count: 25)) %>
|
57
|
-
# <% end %>
|
58
|
-
# <% end %>
|
59
|
-
#
|
60
|
-
# @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
|
61
|
-
def initialize(**system_arguments)
|
62
|
-
@system_arguments = deny_tag_argument(**system_arguments)
|
63
|
-
@system_arguments[:tag] = :nav
|
64
|
-
@system_arguments[:classes] = class_names(
|
65
|
-
"menu",
|
66
|
-
@system_arguments[:classes]
|
67
|
-
)
|
68
|
-
end
|
69
|
-
|
70
|
-
def render?
|
71
|
-
items.any?
|
72
|
-
end
|
4
|
+
class MenuComponent < Primer::Alpha::Menu
|
5
|
+
status :deprecated
|
73
6
|
end
|
74
7
|
end
|
@@ -41,13 +41,13 @@ module Primer
|
|
41
41
|
|
42
42
|
# Icon to be rendered in the Tab left.
|
43
43
|
#
|
44
|
-
# @param kwargs [Hash] The same arguments as <%= link_to_component(Primer::
|
44
|
+
# @param kwargs [Hash] The same arguments as <%= link_to_component(Primer::Beta::Octicon) %>.
|
45
45
|
renders_one :icon, lambda { |icon = nil, **system_arguments|
|
46
46
|
system_arguments[:classes] = class_names(
|
47
47
|
@icon_classes,
|
48
48
|
system_arguments[:classes]
|
49
49
|
)
|
50
|
-
Primer::
|
50
|
+
Primer::Beta::Octicon.new(icon, **system_arguments)
|
51
51
|
}
|
52
52
|
|
53
53
|
# The Tab's text.
|
@@ -1,86 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require "octicons"
|
4
|
-
|
5
3
|
module Primer
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
status :beta
|
10
|
-
|
11
|
-
SIZE_XSMALL = :xsmall
|
12
|
-
SIZE_DEFAULT = :small
|
13
|
-
SIZE_MEDIUM = :medium
|
14
|
-
|
15
|
-
SIZE_MAPPINGS = {
|
16
|
-
SIZE_XSMALL => 12,
|
17
|
-
SIZE_DEFAULT => 16,
|
18
|
-
SIZE_MEDIUM => 24
|
19
|
-
}.freeze
|
20
|
-
SIZE_OPTIONS = SIZE_MAPPINGS.keys
|
21
|
-
|
22
|
-
# @example Default
|
23
|
-
# <%= render(Primer::OcticonComponent.new(:check)) %>
|
24
|
-
# <%= render(Primer::OcticonComponent.new(icon: :check)) %>
|
25
|
-
#
|
26
|
-
# @example Medium
|
27
|
-
# <%= render(Primer::OcticonComponent.new(:people, size: :medium)) %>
|
28
|
-
#
|
29
|
-
# @example Helper
|
30
|
-
# <%= primer_octicon(:check) %>
|
31
|
-
#
|
32
|
-
# @param icon_name [Symbol, String] Name of <%= link_to_octicons %> to use.
|
33
|
-
# @param icon [Symbol, String] Name of <%= link_to_octicons %> to use.
|
34
|
-
# @param size [Symbol] <%= one_of(Primer::OcticonComponent::SIZE_MAPPINGS, sort: false) %>
|
35
|
-
# @param use_symbol [Boolean] EXPERIMENTAL (May change or be removed) - Set to true when using with <%= link_to_component(Primer::OcticonSymbolsComponent) %>.
|
36
|
-
# @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
|
37
|
-
def initialize(icon_name = nil, icon: nil, size: SIZE_DEFAULT, use_symbol: false, **system_arguments)
|
38
|
-
icon_key = icon_name || icon
|
39
|
-
|
40
|
-
# Don't allow sizes under 16px
|
41
|
-
if system_arguments[:height].present? && system_arguments[:height].to_i < 16 || system_arguments[:width].present? && system_arguments[:width].to_i < 16
|
42
|
-
system_arguments.delete(:height)
|
43
|
-
system_arguments.delete(:width)
|
44
|
-
end
|
45
|
-
|
46
|
-
cache_key = Primer::Octicon::Cache.get_key(
|
47
|
-
symbol: icon_key,
|
48
|
-
size: size,
|
49
|
-
height: system_arguments[:height],
|
50
|
-
width: system_arguments[:width]
|
51
|
-
)
|
52
|
-
|
53
|
-
@system_arguments = system_arguments
|
54
|
-
@system_arguments[:tag] = :svg
|
55
|
-
@system_arguments[:aria] ||= {}
|
56
|
-
@use_symbol = use_symbol
|
57
|
-
|
58
|
-
if @system_arguments[:aria][:label] || @system_arguments[:"aria-label"]
|
59
|
-
@system_arguments[:role] = "img"
|
60
|
-
else
|
61
|
-
@system_arguments[:aria][:hidden] = true
|
62
|
-
end
|
63
|
-
|
64
|
-
if (cache_icon = Primer::Octicon::Cache.read(cache_key))
|
65
|
-
@icon = cache_icon
|
66
|
-
else
|
67
|
-
# Filter out classify options to prevent them from becoming invalid html attributes.
|
68
|
-
# Note height and width are both classify options and valid html attributes.
|
69
|
-
octicon_options = {
|
70
|
-
height: @system_arguments[:height] || SIZE_MAPPINGS[fetch_or_fallback(SIZE_OPTIONS, size, SIZE_DEFAULT)],
|
71
|
-
width: @system_arguments[:width]
|
72
|
-
}
|
73
|
-
octicon_options.compact!
|
74
|
-
|
75
|
-
@icon = Octicons::Octicon.new(icon_key, octicon_options)
|
76
|
-
Primer::Octicon::Cache.set(cache_key, @icon)
|
77
|
-
end
|
78
|
-
|
79
|
-
@system_arguments[:classes] = class_names(
|
80
|
-
@icon.options[:class],
|
81
|
-
@system_arguments[:classes]
|
82
|
-
)
|
83
|
-
@system_arguments.merge!(@icon.options.except(:class, :'aria-hidden'))
|
84
|
-
end
|
4
|
+
class OcticonComponent < Primer::Beta::Octicon
|
5
|
+
warn_on_deprecated_slot_setter
|
6
|
+
status :deprecated
|
85
7
|
end
|
86
8
|
end
|
@@ -1,57 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require "octicons"
|
4
|
-
|
5
3
|
module Primer
|
6
|
-
|
7
|
-
|
8
|
-
# @example Symbol dictionary
|
9
|
-
# <%= render(Primer::OcticonComponent.new(icon: :check, use_symbol: true, color: :success)) %>
|
10
|
-
# <%= render(Primer::OcticonComponent.new(icon: :check, use_symbol: true, color: :danger)) %>
|
11
|
-
# <%= render(Primer::OcticonComponent.new(icon: :check, use_symbol: true, size: :medium)) %>
|
12
|
-
# <%= render(Primer::OcticonSymbolsComponent.new(icons: [{ symbol: :check }, { symbol: :check, size: :medium }])) %>
|
13
|
-
#
|
14
|
-
# @param icons [Array<Hash>] List of icons to render, in the format { symbol: :icon_name, size: :small }
|
15
|
-
def initialize(icons: [])
|
16
|
-
@icons = {}
|
17
|
-
icons.each do |icon|
|
18
|
-
symbol = icon[:symbol]
|
19
|
-
size = Primer::OcticonComponent::SIZE_MAPPINGS[
|
20
|
-
fetch_or_fallback(Primer::OcticonComponent::SIZE_OPTIONS, icon[:size] || Primer::OcticonComponent::SIZE_DEFAULT, Primer::OcticonComponent::SIZE_DEFAULT)
|
21
|
-
]
|
22
|
-
|
23
|
-
cache_key = Primer::Octicon::Cache.get_key(symbol: symbol, size: size)
|
24
|
-
|
25
|
-
if (cache_icon = Primer::Octicon::Cache.read(cache_key))
|
26
|
-
icon_instance = cache_icon
|
27
|
-
else
|
28
|
-
icon_instance = Octicons::Octicon.new(symbol, height: size)
|
29
|
-
|
30
|
-
Primer::Octicon::Cache.set(cache_key, icon_instance)
|
31
|
-
end
|
32
|
-
|
33
|
-
# Don't put the same icon twice
|
34
|
-
@icons[[symbol, icon_instance.height]] = icon_instance if @icons[[symbol, icon_instance.height]].nil?
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
def render?
|
39
|
-
@icons.any?
|
40
|
-
end
|
41
|
-
|
42
|
-
def symbol_tags
|
43
|
-
safe_join(
|
44
|
-
@icons.values.map do |icon|
|
45
|
-
content_tag(
|
46
|
-
:symbol,
|
47
|
-
icon.path.html_safe, # rubocop:disable Rails/OutputSafety
|
48
|
-
id: "octicon_#{icon.symbol}_#{icon.height}",
|
49
|
-
viewBox: icon.options[:viewBox],
|
50
|
-
width: icon.width,
|
51
|
-
height: icon.height
|
52
|
-
)
|
53
|
-
end
|
54
|
-
)
|
55
|
-
end
|
4
|
+
class OcticonSymbolsComponent < Primer::Alpha::OcticonSymbols
|
5
|
+
status :deprecated
|
56
6
|
end
|
57
7
|
end
|
@@ -6,12 +6,14 @@
|
|
6
6
|
@import "./alpha/banner.pcss";
|
7
7
|
@import "./alpha/dialog.pcss";
|
8
8
|
@import "./alpha/dropdown.pcss";
|
9
|
+
@import "./alpha/layout.pcss";
|
9
10
|
@import "./alpha/tab_nav.pcss";
|
10
11
|
@import "./alpha/text_field.pcss";
|
11
12
|
@import "./alpha/button_marketing.pcss";
|
12
13
|
@import "./alpha/toggle_switch.pcss";
|
13
14
|
@import "./alpha/underline_nav.pcss";
|
14
15
|
@import "./alpha/segmented_control.pcss";
|
16
|
+
@import "./alpha/menu.pcss";
|
15
17
|
|
16
18
|
/* beta */
|
17
19
|
@import "./beta/avatar.pcss";
|
@@ -20,7 +22,6 @@
|
|
20
22
|
@import "./beta/blankslate.pcss";
|
21
23
|
@import "./beta/breadcrumbs.pcss";
|
22
24
|
@import "./beta/button.pcss";
|
23
|
-
@import "./beta/button_group.pcss";
|
24
25
|
@import "./beta/counter.pcss";
|
25
26
|
@import "./beta/flash.pcss";
|
26
27
|
@import "./beta/label.pcss";
|
@@ -30,8 +31,6 @@
|
|
30
31
|
@import "./beta/truncate.pcss";
|
31
32
|
|
32
33
|
/* to be renamed */
|
33
|
-
@import "./button_component.pcss";
|
34
|
-
@import "./menu_component.pcss";
|
35
34
|
@import "./state_component.pcss";
|
36
35
|
@import "./subhead_component.pcss";
|
37
36
|
@import "./timeline_item_component.pcss";
|
@@ -1,43 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Primer
|
4
|
-
|
5
|
-
|
6
|
-
status :beta
|
7
|
-
|
8
|
-
DEFAULT_SIZE = :medium
|
9
|
-
SIZE_MAPPINGS = {
|
10
|
-
:small => 16,
|
11
|
-
DEFAULT_SIZE => 32,
|
12
|
-
:large => 64
|
13
|
-
}.freeze
|
14
|
-
SIZE_OPTIONS = SIZE_MAPPINGS.keys
|
15
|
-
# Setting `box-sizing: content-box` allows consumers to add padding
|
16
|
-
# to the spinner without shrinking the icon
|
17
|
-
DEFAULT_STYLE = "box-sizing: content-box; color: var(--color-icon-primary);"
|
18
|
-
|
19
|
-
#
|
20
|
-
# @example Default
|
21
|
-
# <%= render(Primer::SpinnerComponent.new) %>
|
22
|
-
#
|
23
|
-
# @example Small
|
24
|
-
# <%= render(Primer::SpinnerComponent.new(size: :small)) %>
|
25
|
-
#
|
26
|
-
# @example Large
|
27
|
-
# <%= render(Primer::SpinnerComponent.new(size: :large)) %>
|
28
|
-
#
|
29
|
-
# @param size [Symbol] <%= one_of(Primer::SpinnerComponent::SIZE_MAPPINGS) %>
|
30
|
-
# @param style [String] Custom element styles.
|
31
|
-
# @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
|
32
|
-
def initialize(size: DEFAULT_SIZE, style: DEFAULT_STYLE, **system_arguments)
|
33
|
-
@system_arguments = deny_tag_argument(**system_arguments)
|
34
|
-
@system_arguments[:tag] = :svg
|
35
|
-
@system_arguments[:style] ||= style
|
36
|
-
@system_arguments[:animation] = :rotate
|
37
|
-
@system_arguments[:width] = SIZE_MAPPINGS[fetch_or_fallback(SIZE_OPTIONS, size, DEFAULT_SIZE)]
|
38
|
-
@system_arguments[:height] = SIZE_MAPPINGS[fetch_or_fallback(SIZE_OPTIONS, size, DEFAULT_SIZE)]
|
39
|
-
@system_arguments[:viewBox] = "0 0 16 16"
|
40
|
-
@system_arguments[:fill] = :none
|
41
|
-
end
|
4
|
+
class SpinnerComponent < Primer::Beta::Spinner
|
5
|
+
status :deprecated
|
42
6
|
end
|
43
7
|
end
|
@@ -11,6 +11,8 @@ module Primer
|
|
11
11
|
# The `:heading` slot defaults to rendering a `<div>`. Update the tag to a heading element with the appropriate level to improve page navigation for assistive technologies.
|
12
12
|
# <%= link_to_heading_practices %>
|
13
13
|
class SubheadComponent < Primer::Component
|
14
|
+
warn_on_deprecated_slot_setter
|
15
|
+
|
14
16
|
status :beta
|
15
17
|
|
16
18
|
DEFAULT_HEADING_TAG = :div
|
@@ -3,7 +3,8 @@
|
|
3
3
|
module Primer
|
4
4
|
# Use `TimeAgo` to display a time relative to how long ago it was. This component requires JavaScript.
|
5
5
|
class TimeAgoComponent < Primer::Component
|
6
|
-
|
6
|
+
warn_on_deprecated_slot_setter
|
7
|
+
status :deprecated
|
7
8
|
|
8
9
|
# @example Default
|
9
10
|
# <%= render(Primer::TimeAgoComponent.new(time: Time.at(628232400))) %>
|