primer_view_components 0.0.97 → 0.0.98

Sign up to get free protection for your applications and to get access to all the features.
Files changed (99) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +10 -0
  3. data/app/components/primer/beta/avatar.rb +10 -10
  4. data/app/components/primer/beta/avatar_stack.rb +9 -9
  5. data/app/components/primer/beta/blankslate.rb +2 -2
  6. data/app/components/primer/button_component.rb +1 -1
  7. data/app/components/primer/image.rb +4 -4
  8. data/app/components/primer/image_crop.rb +3 -3
  9. data/app/components/primer/timeline_item_component.rb +1 -1
  10. data/lib/primer/deprecations.rb +0 -1
  11. data/lib/primer/example_image.rb +7 -0
  12. data/lib/primer/view_components/version.rb +1 -1
  13. data/lib/tasks/docs.rake +4 -4
  14. data/lib/tasks/test.rake +1 -1
  15. data/previews/primer/alpha/action_list_preview/heading.html.erb +4 -0
  16. data/previews/primer/alpha/action_list_preview.rb +308 -0
  17. data/previews/primer/alpha/auto_complete_preview.rb +42 -0
  18. data/previews/primer/alpha/button_marketing_preview.rb +17 -0
  19. data/previews/primer/alpha/dialog_preview/custom_header.html.erb +7 -0
  20. data/previews/primer/alpha/dialog_preview/test.html.erb +7 -0
  21. data/previews/primer/alpha/dialog_preview/with_footer.html.erb +8 -0
  22. data/previews/primer/alpha/dialog_preview/with_form.html.erb +12 -0
  23. data/previews/primer/alpha/dialog_preview.rb +85 -0
  24. data/previews/primer/alpha/hidden_text_expander_preview.rb +15 -0
  25. data/previews/primer/alpha/layout_preview.rb +23 -0
  26. data/previews/primer/alpha/nav_list_preview.rb +64 -0
  27. data/previews/primer/alpha/tab_panels_preview.rb +23 -0
  28. data/previews/primer/alpha/text_field_preview.rb +66 -0
  29. data/previews/primer/alpha/toggle_switch_preview.rb +50 -0
  30. data/previews/primer/alpha/tooltip_preview/with_multiple_on_a_page.html.erb +14 -0
  31. data/previews/primer/alpha/tooltip_preview/with_right_most_position.html.erb +7 -0
  32. data/previews/primer/alpha/tooltip_preview.rb +83 -0
  33. data/previews/primer/alpha/underline_nav_preview/default.html.erb +8 -0
  34. data/previews/primer/alpha/underline_nav_preview.rb +41 -0
  35. data/previews/primer/alpha/underline_panels_preview.rb +23 -0
  36. data/previews/primer/beta/auto_complete_item_preview/default.html.erb +9 -0
  37. data/previews/primer/beta/auto_complete_item_preview/with_description.html.erb +11 -0
  38. data/previews/primer/beta/auto_complete_item_preview.rb +40 -0
  39. data/previews/primer/beta/auto_complete_preview/with_submit_button.html.erb +20 -0
  40. data/previews/primer/beta/auto_complete_preview.rb +245 -0
  41. data/previews/primer/beta/avatar_preview.rb +17 -0
  42. data/previews/primer/beta/avatar_stack_preview.rb +44 -0
  43. data/previews/primer/beta/base_button_preview.rb +17 -0
  44. data/previews/primer/beta/blankslate_preview.rb +94 -0
  45. data/previews/primer/beta/border_box_preview.rb +32 -0
  46. data/previews/primer/beta/breadcrumbs_preview.rb +19 -0
  47. data/previews/primer/beta/button_group_preview.rb +20 -0
  48. data/previews/primer/beta/button_preview/all_schemes.html.erb +26 -0
  49. data/previews/primer/beta/button_preview/leading_visual.html.erb +10 -0
  50. data/previews/primer/beta/button_preview/trailing_action.html.erb +10 -0
  51. data/previews/primer/beta/button_preview/trailing_visual.html.erb +11 -0
  52. data/previews/primer/beta/button_preview/with_tooltip.html.erb +10 -0
  53. data/previews/primer/beta/button_preview.rb +256 -0
  54. data/previews/primer/beta/close_button_preview.rb +15 -0
  55. data/previews/primer/beta/counter_preview.rb +24 -0
  56. data/previews/primer/beta/details_preview.rb +45 -0
  57. data/previews/primer/beta/flash_preview.rb +20 -0
  58. data/previews/primer/beta/heading_preview.rb +16 -0
  59. data/previews/primer/beta/icon_button_preview.rb +107 -0
  60. data/previews/primer/beta/text_preview.rb +16 -0
  61. data/previews/primer/beta/truncate_preview.rb +47 -0
  62. data/previews/primer/clipboard_copy_preview/element.html.erb +2 -0
  63. data/previews/primer/clipboard_copy_preview.rb +29 -0
  64. data/previews/primer/dropdown_preview.rb +39 -0
  65. data/previews/primer/forms/forms_preview/after_content_form.html.erb +3 -0
  66. data/previews/primer/forms/forms_preview/array_check_box_group_form.html.erb +3 -0
  67. data/previews/primer/forms/forms_preview/caption_template_form.html.erb +3 -0
  68. data/previews/primer/forms/forms_preview/check_box_group_form.html.erb +3 -0
  69. data/previews/primer/forms/forms_preview/composed_form.html.erb +4 -0
  70. data/previews/primer/forms/forms_preview/horizontal_form.html.erb +3 -0
  71. data/previews/primer/forms/forms_preview/invalid_form.html.erb +3 -0
  72. data/previews/primer/forms/forms_preview/multi_input_form.html.erb +3 -0
  73. data/previews/primer/forms/forms_preview/multi_text_field_form.html.erb +3 -0
  74. data/previews/primer/forms/forms_preview/radio_button_group_form.html.erb +3 -0
  75. data/previews/primer/forms/forms_preview/radio_button_with_nested_form.html.erb +3 -0
  76. data/previews/primer/forms/forms_preview/select_list_form.html.erb +3 -0
  77. data/previews/primer/forms/forms_preview/single_text_field_form.html.erb +3 -0
  78. data/previews/primer/forms/forms_preview/submit_button_form.html.erb +3 -0
  79. data/previews/primer/forms/forms_preview/text_field_and_checkbox_form.html.erb +3 -0
  80. data/previews/primer/forms/forms_preview.rb +37 -0
  81. data/previews/primer/hellip_button_preview.rb +14 -0
  82. data/previews/primer/image_crop_preview.rb +22 -0
  83. data/previews/primer/label_component_preview.rb +15 -0
  84. data/previews/primer/layout_component_preview.rb +18 -0
  85. data/previews/primer/link_component_preview.rb +29 -0
  86. data/previews/primer/local_time_component_preview.rb +41 -0
  87. data/previews/primer/markdown_preview.rb +280 -0
  88. data/previews/primer/menu_component_preview/default.html.erb +17 -0
  89. data/previews/primer/menu_component_preview.rb +9 -0
  90. data/previews/primer/octicon_component_preview.rb +14 -0
  91. data/previews/primer/popover_component_preview.rb +20 -0
  92. data/previews/primer/progress_bar_component_preview.rb +17 -0
  93. data/previews/primer/spinner_component_preview.rb +13 -0
  94. data/previews/primer/state_component_preview.rb +16 -0
  95. data/previews/primer/subhead_component_preview.rb +23 -0
  96. data/previews/primer/time_ago_component_preview.rb +16 -0
  97. data/previews/primer/timeline_item_component_preview.rb +17 -0
  98. data/static/statuses.json +1 -1
  99. metadata +87 -3
@@ -0,0 +1,3 @@
1
+ <%= primer_form_with(url: "/foo") do |f| %>
2
+ <%= render(SingleTextFieldForm.new(f)) %>
3
+ <% end %>
@@ -0,0 +1,3 @@
1
+ <%= primer_form_with(url: "/foo") do |f| %>
2
+ <%= render(SubmitButtonForm.new(f)) %>
3
+ <% end %>
@@ -0,0 +1,3 @@
1
+ <%= primer_form_with(url: "/foo") do |f| %>
2
+ <%= render(TextFieldAndCheckboxForm.new(f)) %>
3
+ <% end %>
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Primer
4
+ module Forms
5
+ class FormsPreview < ViewComponent::Preview
6
+ def single_text_field_form; end
7
+
8
+ def multi_text_field_form; end
9
+
10
+ def text_field_and_checkbox_form; end
11
+
12
+ def horizontal_form; end
13
+
14
+ def composed_form; end
15
+
16
+ def submit_button_form; end
17
+
18
+ def radio_button_group_form; end
19
+
20
+ def check_box_group_form; end
21
+
22
+ def array_check_box_group_form; end
23
+
24
+ def select_list_form; end
25
+
26
+ def radio_button_with_nested_form; end
27
+
28
+ def caption_template_form; end
29
+
30
+ def after_content_form; end
31
+
32
+ def invalid_form; end
33
+
34
+ def multi_input_form; end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Primer
4
+ # @label HellipButton
5
+ class HellipButtonPreview < ViewComponent::Preview
6
+ # @label Default Options
7
+ #
8
+ # @param aria_label [String]
9
+ # @param inline [Boolean]
10
+ def default(inline: false, aria_label: "No effect")
11
+ render(Primer::HellipButton.new(inline: inline, "aria-label": aria_label))
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Primer
4
+ # @label ImageCrop
5
+ class ImageCropPreview < ViewComponent::Preview
6
+ # @label Default Options
7
+ #
8
+ # @param rounded [Boolean]
9
+ def default(rounded: false)
10
+ render(Primer::ImageCrop.new(src: Primer::ExampleImage::BASE64_SRC, rounded: rounded))
11
+ end
12
+
13
+ # @label Custom loading slot
14
+ #
15
+ # @param rounded [Boolean]
16
+ def loading(rounded: false)
17
+ render(Primer::ImageCrop.new(src: Primer::ExampleImage::BASE64_SRC, rounded: rounded)) do |c|
18
+ c.with_loading { "Loading..." }
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Primer
4
+ # @label LabelComponent
5
+ class LabelComponentPreview < ViewComponent::Preview
6
+ # @label Default Options
7
+ #
8
+ # @param size [Symbol] select [medium, large]
9
+ # @param tag [Symbol] select [span, summary, a, div]
10
+ # @param inline [Boolean] toggle
11
+ def default(size: :medium, tag: :span, inline: false)
12
+ render(Primer::LabelComponent.new(tag: tag, size: size, inline: inline)) { "Label" }
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Primer
4
+ # @label LayoutComponent
5
+ class LayoutComponentPreview < ViewComponent::Preview
6
+ # @label Default Options
7
+ #
8
+ # @param responsive [Boolean]
9
+ # @param side [Symbol] select [left, right]
10
+ # @param sidebar_col [Integer] select [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
11
+ def default(responsive: false, side: :right, sidebar_col: 3)
12
+ render(Primer::LayoutComponent.new(responsive: responsive, side: side, sidebar_col: sidebar_col)) do |component|
13
+ component.with_main { "Main" }
14
+ component.with_sidebar { "Sidebar" }
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Primer
4
+ # @label LinkComponent
5
+ class LinkComponentPreview < ViewComponent::Preview
6
+ # @label Default Options
7
+ #
8
+ # @param underline [Boolean]
9
+ # @param muted [Boolean]
10
+ # @param tag [Symbol] select [a, span]
11
+ # @param scheme [Symbol] select [default, primary, secondary]
12
+ def default(tag: :a, scheme: :default, muted: false, underline: true)
13
+ render(Primer::LinkComponent.new(href: "#", tag: tag, scheme: scheme, muted: muted, underline: underline)) { "This is a link!" }
14
+ end
15
+
16
+ # @label with Tooltip
17
+ #
18
+ # @param underline [Boolean]
19
+ # @param muted [Boolean]
20
+ # @param tag [Symbol] select [a, span]
21
+ # @param scheme [Symbol] select [default, primary, secondary]
22
+ def tooltip(tag: :a, scheme: :default, muted: false, underline: true)
23
+ render(Primer::LinkComponent.new(href: "#", id: "tooltip-link", tag: tag, scheme: scheme, muted: muted, underline: underline)) do |component|
24
+ component.with_tooltip(text: "Tooltip text")
25
+ "Link with tooltip"
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,41 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Primer
4
+ # @label LocalTime
5
+ class LocalTimeComponentPreview < ViewComponent::Preview
6
+ # @param datetime datetime-local
7
+ # @param weekday [Symbol] select [long, short]
8
+ # @param month [Symbol] select [long, short]
9
+ # @param year [Symbol] select [numeric, "2-digit"]
10
+ # @param day [Symbol] select [numeric, "2-digit"]
11
+ # @param hour [Symbol] select [numeric, "2-digit"]
12
+ # @param minute [Symbol] select [numeric, "2-digit"]
13
+ # @param second [Symbol] select [numeric, "2-digit"]
14
+ # @param time_zone_name [Symbol] select [long, short]
15
+ def default(datetime: "2014-04-01T16:30:00-08:00", weekday: :short, month: :short, year: :numeric, day: :numeric, hour: :numeric, minute: :numeric, second: :numeric, time_zone_name: :short)
16
+ render(Primer::LocalTime.new(datetime: DateTime.parse(datetime), weekday: weekday, month: month, year: year, day: day, hour: hour, minute: minute, second: second, time_zone_name: time_zone_name))
17
+ end
18
+
19
+ # @hidden
20
+ def with_all_the_options
21
+ render(Primer::LocalTime.new(
22
+ datetime: DateTime.parse("2016-06-01T13:05:07Z"),
23
+ weekday: :long,
24
+ year: :"2-digit",
25
+ month: :long,
26
+ day: :"2-digit",
27
+ hour: :"2-digit",
28
+ minute: :"2-digit",
29
+ second: :"2-digit",
30
+ time_zone_name: :long
31
+ ))
32
+ end
33
+
34
+ # @label With replaceable content
35
+ #
36
+ # @param initial_text [String] textarea
37
+ def with_contents(initial_text: "This will be replaced")
38
+ render Primer::LocalTime.new(datetime: DateTime.parse("2014-04-01T16:30:00-08:00"), initial_text: initial_text)
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,280 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Primer
4
+ # @label Markdown
5
+ class MarkdownPreview < ViewComponent::Preview
6
+ # @label Default Options
7
+ def default
8
+ render(Primer::Markdown.new) do
9
+ "<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>
10
+
11
+ <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>
12
+
13
+ <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>
14
+
15
+ <blockquote>
16
+ <p>There should be no margin above this first sentence.</p>
17
+ <p>Blockquotes should be a lighter gray with a gray border along the left side.</p>
18
+ <p>There should be no margin below this final sentence.</p>
19
+ </blockquote>
20
+
21
+ <h1>Header 1</h1>
22
+
23
+ <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>
24
+
25
+ <h2>Header 2</h2>
26
+
27
+ <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>
28
+
29
+ <h3>Header 3</h3>
30
+
31
+ <pre><code>This is a code block following a header.</code></pre>
32
+
33
+ <h4>Header 4</h4>
34
+
35
+ <ul>
36
+ <li>This is an unordered list following a header.</li>
37
+ <li>This is an unordered list following a header.</li>
38
+ <li>This is an unordered list following a header.</li>
39
+ </ul>
40
+
41
+ <h5>Header 5</h5>
42
+
43
+ <ol>
44
+ <li>This is an ordered list following a header.</li>
45
+ <li>This is an ordered list following a header.</li>
46
+ <li>This is an ordered list following a header.</li>
47
+ </ol>
48
+
49
+ <h6>Header 6</h6>
50
+
51
+ <table>
52
+ <thead>
53
+ <tr>
54
+ <th>What</th>
55
+ <th>Follows</th>
56
+ </tr>
57
+ </thead>
58
+ <tbody>
59
+ <tr>
60
+ <td>A table</td>
61
+ <td>A header</td>
62
+ </tr>
63
+ <tr>
64
+ <td>A table</td>
65
+ <td>A header</td>
66
+ </tr>
67
+ <tr>
68
+ <td>A table</td>
69
+ <td>A header</td>
70
+ </tr>
71
+ </tbody>
72
+ </table>
73
+
74
+ <hr />
75
+
76
+ <p>There's a horizontal rule above and below this.</p>
77
+
78
+ <hr />
79
+
80
+ <p>Here is an unordered list:</p>
81
+
82
+ <ul>
83
+ <li>Salt-n-Pepa</li>
84
+ <li>Bel Biv DeVoe</li>
85
+ <li>Kid 'N Play</li>
86
+ </ul>
87
+
88
+ <p>And an ordered list:</p>
89
+
90
+ <ol>
91
+ <li>Michael Jackson</li>
92
+ <li>Michael Bolton</li>
93
+ <li>Michael Bublé</li>
94
+ </ol>
95
+
96
+ <p>And an unordered task list:</p>
97
+
98
+ <ul>
99
+ <li><input type=\"checkbox\" checked> Create a sample markdown document</li>
100
+ <li><input type=\"checkbox\"> Add task lists to it</li>
101
+ <li><input type=\"checkbox\"> Take a vacation</li>
102
+ </ul>
103
+
104
+ <p>And a \"mixed\" task list:</p>
105
+
106
+ <ul>
107
+ <li><input type=\"checkbox\"> Steal underpants</li>
108
+ <li>?</li>
109
+ <li><input type=\"checkbox\"> Profit!</li>
110
+ </ul>
111
+
112
+ And a nested list:
113
+
114
+ <ul>
115
+ <li>Jackson 5
116
+ <ul>
117
+ <li>Michael</li>
118
+ <li>Tito</li>
119
+ <li>Jackie</li>
120
+ <li>Marlon</li>
121
+ <li>Jermaine</li>
122
+ </ul>
123
+ </li>
124
+ <li>TMNT
125
+ <ul>
126
+ <li>Leonardo</li>
127
+ <li>Michelangelo</li>
128
+ <li>Donatello</li>
129
+ <li>Raphael</li>
130
+ </ul>
131
+ </li>
132
+ </ul>
133
+
134
+ <p>Definition lists can be used with HTML syntax. Definition terms are bold and italic.</p>
135
+
136
+ <dl>
137
+ <dt>Name</dt>
138
+ <dd>Godzilla</dd>
139
+ <dt>Born</dt>
140
+ <dd>1952</dd>
141
+ <dt>Birthplace</dt>
142
+ <dd>Japan</dd>
143
+ <dt>Color</dt>
144
+ <dd>Green</dd>
145
+ </dl>
146
+
147
+ <hr />
148
+
149
+ <p>Tables should have bold headings and alternating shaded rows.</p>
150
+
151
+ <table>
152
+ <thead>
153
+ <tr>
154
+ <th>Artist</th>
155
+ <th>Album</th>
156
+ <th>Year</th>
157
+ </tr>
158
+ </thead>
159
+ <tbody>
160
+ <tr>
161
+ <td>David Bowie</td>
162
+ <td>Scary Monsters</td>
163
+ <td>1980</td>
164
+ </tr>
165
+ <tr>
166
+ <td>Prince</td>
167
+ <td>Purple Rain</td>
168
+ <td>1982</td>
169
+ </tr>
170
+ <tr>
171
+ <td>Beastie Boys</td>
172
+ <td>License to Ill</td>
173
+ <td>1986</td>
174
+ </tr>
175
+ <tr>
176
+ <td>Janet Jackson</td>
177
+ <td>Rhythm Nation 1814</td>
178
+ <td>1989</td>
179
+ </tr>
180
+ </tbody>
181
+ </table>
182
+
183
+ <p>If a table is too wide, it should condense down and/or scroll horizontally.</p>
184
+
185
+ <table>
186
+ <thead>
187
+ <tr>
188
+ <th>Artist</th>
189
+ <th>Album</th>
190
+ <th>Year</th>
191
+ <th>Label</th>
192
+ <th>Songs</th>
193
+ </tr>
194
+ </thead>
195
+ <tbody>
196
+ <tr>
197
+ <td>David Bowie</td>
198
+ <td>Scary Monsters</td>
199
+ <td>1980</td>
200
+ <td>RCA Records</td>
201
+ <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>
202
+ </tr>
203
+ <tr>
204
+ <td>Prince</td>
205
+ <td>Purple Rain</td>
206
+ <td>1982</td>
207
+ <td>Warner Brothers Records</td>
208
+ <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>
209
+ </tr>
210
+ <tr>
211
+ <td>Beastie Boys</td>
212
+ <td>License to Ill</td>
213
+ <td>1986</td>
214
+ <td>Def Jam</td>
215
+ <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>
216
+ </tr>
217
+ <tr>
218
+ <td>Janet Jackson</td>
219
+ <td>Rhythm Nation 1814</td>
220
+ <td>1989</td>
221
+ <td>A&amp;M</td>
222
+ <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>
223
+ </tr>
224
+ </tbody>
225
+ </table>
226
+
227
+ <hr />
228
+
229
+ <p>Code snippets like <code>var foo = \"bar\";</code> can be shown inline.</p>
230
+
231
+ <p>Also, <code>this should vertically align</code> <s><code>with this</code></s> <s>and this</s>.</p>
232
+
233
+ <p>Code can also be shown in a block element.</p>
234
+
235
+ <pre><code>var foo = \"bar\";</code></pre>
236
+
237
+ <p>Code can also use syntax highlighting.</p>
238
+
239
+ <pre><code>var foo = \"bar\";</code></pre>
240
+
241
+ <pre><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>
242
+
243
+ <pre><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>
244
+
245
+ <p>Inline code inside table cells should still be distinguishable.</p>
246
+
247
+ <table>
248
+ <thead>
249
+ <tr>
250
+ <th>Language</th>
251
+ <th>Code</th>
252
+ </tr>
253
+ </thead>
254
+ <tbody>
255
+ <tr>
256
+ <td>JavasScript</td>
257
+ <td><code>var foo = \"bar\";</code></td>
258
+ </tr>
259
+ <tr>
260
+ <td>Ruby</td>
261
+ <td><code>foo = \"bar\"</code></td>
262
+ </tr>
263
+ </tbody>
264
+ </table>
265
+
266
+ <hr />
267
+
268
+ <p>Small images should be shown at their actual size.</p>
269
+
270
+ <!-- p><img src=\"http://placekitten.com/g/300/200/\"></!-->
271
+
272
+ <p>Large images should always scale down and fit in the content container.</p>
273
+
274
+ <!-- p><img src=\"http://placekitten.com/g/1200/800/\"></!-->
275
+
276
+ <pre><code>This is the final element on the page and there should be no margin below this.</code></pre>".html_safe # rubocop:disable Rails/OutputSafety
277
+ end
278
+ end
279
+ end
280
+ end
@@ -0,0 +1,17 @@
1
+ <%= render(Primer::MenuComponent.new) do |c| %>
2
+ <% c.with_heading(tag: :h2) do %>
3
+ Heading
4
+ <% end %>
5
+ <% c.with_item(selected: true, href: "#url") do %>
6
+ Item 1
7
+ <% end %>
8
+ <% c.with_item(href: "#url") do %>
9
+ <%= render(Primer::OcticonComponent.new("check")) %>
10
+ With Icon
11
+ <% end %>
12
+ <% c.with_item(href: "#url") do %>
13
+ <%= render(Primer::OcticonComponent.new("check")) %>
14
+ With Icon and Counter
15
+ <%= render(Primer::Beta::Counter.new(count: 25)) %>
16
+ <% end %>
17
+ <% end %>
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Primer
4
+ # @label MenuComponent
5
+ class MenuComponentPreview < ViewComponent::Preview
6
+ # @label Default Options
7
+ def default; end
8
+ end
9
+ end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Primer
4
+ # @label OcticonComponent
5
+ class OcticonComponentPreview < ViewComponent::Preview
6
+ # @label Default Options
7
+ #
8
+ # @param aria_label [String]
9
+ # @param size [Symbol] select [xsmall, small, medium]
10
+ def default(size: :small, aria_label: nil)
11
+ render(Primer::OcticonComponent.new(icon: :people, size: size, "aria-label": aria_label))
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Primer
4
+ # @label PopoverComponent
5
+ class PopoverComponentPreview < ViewComponent::Preview
6
+ # @label Default Options
7
+ #
8
+ # @param caret [Symbol] select [top, right, bottom, left, top_right, top_left, bottom_right, bottom_left, left_bottom, left_top, right_bottom, right_top]
9
+ def default(caret: :top)
10
+ render Primer::PopoverComponent.new do |component|
11
+ component.with_heading do
12
+ "Activity feed"
13
+ end
14
+ component.with_body(caret: caret) do
15
+ "This is the Popover body."
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Primer
4
+ # @label ProgressBarComponent
5
+ class ProgressBarComponentPreview < ViewComponent::Preview
6
+ # @label Default Options
7
+ #
8
+ # @param size [Symbol] select [default, small, large]
9
+ def default(size: :default)
10
+ render(Primer::ProgressBarComponent.new(size: size)) do |component|
11
+ component.with_item(percentage: 10)
12
+ component.with_item(bg: :accent_emphasis, percentage: 20)
13
+ component.with_item(bg: :danger_emphasis, percentage: 30)
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Primer
4
+ # @label SpinnerComponent
5
+ class SpinnerComponentPreview < ViewComponent::Preview
6
+ # @label Default Options
7
+ #
8
+ # @param size [Symbol] select [small, medium, large]
9
+ def default(size: :medium)
10
+ render(Primer::SpinnerComponent.new(size: size))
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Primer
4
+ # @label StateComponent
5
+ class StateComponentPreview < ViewComponent::Preview
6
+ # @label Default Options
7
+ #
8
+ # @param title [String]
9
+ # @param tag [Symbol] select [span, div]
10
+ # @param size [Symbol] select [default, small]
11
+ # @param scheme [Symbol] select [default, open, closed, merged]
12
+ def default(title: "State", scheme: :default, size: :default, tag: :span)
13
+ render(Primer::StateComponent.new(title: title, scheme: scheme, size: size, tag: tag)) { "State" }
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Primer
4
+ # @label SubheadComponent
5
+ class SubheadComponentPreview < ViewComponent::Preview
6
+ # @label Default Options
7
+ #
8
+ # @param spacious [Boolean]
9
+ # @param hide_border [Boolean]
10
+ # @param heading_danger [Boolean]
11
+ # @param heading_tag [Symbol] select [div, h1, h2, h3, h4, h5, h6]
12
+ def default(spacious: false, hide_border: false, heading_tag: :div, heading_danger: false)
13
+ render(Primer::SubheadComponent.new(spacious: spacious, hide_border: hide_border)) do |component|
14
+ component.with_heading(tag: heading_tag, danger: heading_danger) do
15
+ "My Heading"
16
+ end
17
+ component.with_description do
18
+ "My Description"
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Primer
4
+ # @label TimeAgoComponent
5
+ class TimeAgoComponentPreview < ViewComponent::Preview
6
+ # @param time datetime-local
7
+ # @param micro [Boolean] toggle
8
+ def default(time: Time.zone.now.to_s, micro: false)
9
+ render(Primer::TimeAgoComponent.new(time: DateTime.parse(time), micro: micro))
10
+ end
11
+
12
+ def micro
13
+ render(Primer::TimeAgoComponent.new(time: Time.zone.now, micro: true))
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Primer
4
+ # @label TimelineItemComponent
5
+ class TimelineItemComponentPreview < ViewComponent::Preview
6
+ # @label Default Options
7
+ #
8
+ # @param condensed [Boolean]
9
+ def default(condensed: false)
10
+ render(Primer::TimelineItemComponent.new(condensed: condensed)) do |component|
11
+ component.with_avatar(src: Primer::ExampleImage::BASE64_SRC, alt: "octocat")
12
+ component.with_badge(bg: :success_emphasis, color: :on_emphasis, icon: :check)
13
+ component.with_body { "Success!" }
14
+ end
15
+ end
16
+ end
17
+ end
data/static/statuses.json CHANGED
@@ -49,7 +49,7 @@
49
49
  "Primer::BlankslateComponent": "deprecated",
50
50
  "Primer::Box": "stable",
51
51
  "Primer::BoxComponent": "deprecated",
52
- "Primer::ButtonComponent": "deprecated",
52
+ "Primer::ButtonComponent": "beta",
53
53
  "Primer::ClipboardCopy": "beta",
54
54
  "Primer::CloseButton": "deprecated",
55
55
  "Primer::ConditionalWrapper": "alpha",