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,256 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Primer
4
+ module Beta
5
+ # @label Button
6
+ class ButtonPreview < ViewComponent::Preview
7
+ # @label Playground
8
+ # @param scheme select [default, primary, danger, invisible, link]
9
+ # @param size select [small, medium, large]
10
+ # @param block toggle
11
+ # @param disabled toggle
12
+ # @param align_content select [center, start]
13
+ # @param tag select [a, summary, button]
14
+ def playground(
15
+ scheme: :default,
16
+ size: :medium,
17
+ block: false,
18
+ id: "button-preview",
19
+ align_content: :center,
20
+ tag: :button,
21
+ disabled: false
22
+ )
23
+ render(Primer::Beta::Button.new(
24
+ scheme: scheme,
25
+ size: size,
26
+ block: block,
27
+ id: id,
28
+ align_content: align_content,
29
+ tag: tag,
30
+ disabled: disabled
31
+ )) do |_c|
32
+ "Button"
33
+ end
34
+ end
35
+
36
+ # @label Default
37
+ # @param block toggle
38
+ # @param disabled toggle
39
+ # @param tag select [a, summary, button]
40
+ def default(
41
+ block: false,
42
+ id: "button-preview",
43
+ tag: :button,
44
+ disabled: false
45
+ )
46
+ render(Primer::Beta::Button.new(
47
+ scheme: :default,
48
+ size: :medium,
49
+ block: block,
50
+ id: id,
51
+ tag: tag,
52
+ disabled: disabled
53
+ )) do |_c|
54
+ "Button"
55
+ end
56
+ end
57
+
58
+ # @label Primary
59
+ # @param block toggle
60
+ # @param disabled toggle
61
+ # @param tag select [a, summary, button]
62
+ def primary(
63
+ id: "button-preview",
64
+ block: false,
65
+ tag: :button,
66
+ disabled: false
67
+ )
68
+ render(Primer::Beta::Button.new(
69
+ scheme: :primary,
70
+ size: :medium,
71
+ block: block,
72
+ id: id,
73
+ tag: tag,
74
+ disabled: disabled
75
+ )) do |_c|
76
+ "Button"
77
+ end
78
+ end
79
+
80
+ # @label Danger
81
+ # @param block toggle
82
+ # @param disabled toggle
83
+ # @param tag select [a, summary, button]
84
+ def danger(
85
+ id: "button-preview",
86
+ block: false,
87
+ tag: :button,
88
+ disabled: false
89
+ )
90
+ render(Primer::Beta::Button.new(
91
+ scheme: :danger,
92
+ size: :medium,
93
+ block: block,
94
+ id: id,
95
+ tag: tag,
96
+ disabled: disabled
97
+ )) do |_c|
98
+ "Button"
99
+ end
100
+ end
101
+
102
+ # @label Invisible
103
+ # @param block toggle
104
+ # @param disabled toggle
105
+ # @param tag select [a, summary, button]
106
+ def invisible(
107
+ id: "button-preview",
108
+ block: false,
109
+ tag: :button,
110
+ disabled: false
111
+ )
112
+ render(Primer::Beta::Button.new(
113
+ scheme: :invisible,
114
+ size: :medium,
115
+ block: block,
116
+ id: id,
117
+ tag: tag,
118
+ disabled: disabled
119
+ )) do |_c|
120
+ "Button"
121
+ end
122
+ end
123
+
124
+ # @label All schemes
125
+ def all_schemes
126
+ render_with_template(locals: {})
127
+ end
128
+
129
+ # @label Full width
130
+ # @param disabled toggle
131
+ # @param tag select [a, summary, button]
132
+ def full_width(
133
+ id: "button-preview",
134
+ tag: :button,
135
+ disabled: false
136
+ )
137
+ render(Primer::Beta::Button.new(
138
+ scheme: :default,
139
+ size: :medium,
140
+ block: true,
141
+ id: id,
142
+ tag: tag,
143
+ disabled: disabled
144
+ )) do |_c|
145
+ "Button"
146
+ end
147
+ end
148
+
149
+ # @label Link as button
150
+ # @param scheme select [default, primary, danger, outline, invisible, link]
151
+ # @param size select [small, medium]
152
+ # @param block toggle
153
+ # @param align_content select [center, start]
154
+ def link_as_button(
155
+ scheme: :default,
156
+ size: :medium,
157
+ block: false,
158
+ id: "button-preview",
159
+ align_content: :center,
160
+ tag: :a
161
+ )
162
+ render(Primer::Beta::Button.new(
163
+ scheme: scheme,
164
+ size: size,
165
+ block: block,
166
+ id: id,
167
+ align_content: align_content,
168
+ tag: tag
169
+ )) do |_c|
170
+ "Button"
171
+ end
172
+ end
173
+
174
+ # @label Trailing visual
175
+ # @param scheme select [default, primary, danger, outline, invisible, link]
176
+ # @param size select [small, medium]
177
+ # @param block toggle
178
+ # @param align_content select [center, start]
179
+ # @param tag select [a, summary, button]
180
+ def trailing_visual(
181
+ scheme: :default,
182
+ size: :medium,
183
+ block: false,
184
+ id: "button-preview",
185
+ align_content: :center,
186
+ tag: :a
187
+ )
188
+ render_with_template(locals: {
189
+ scheme: scheme,
190
+ size: size,
191
+ block: block,
192
+ id: id,
193
+ align_content: align_content,
194
+ tag: tag
195
+ })
196
+ end
197
+
198
+ # @label Leading visual
199
+ # @param scheme select [default, primary, danger, outline, invisible, link]
200
+ # @param size select [small, medium]
201
+ # @param block toggle
202
+ # @param align_content select [center, start]
203
+ def leading_visual(
204
+ scheme: :invisible,
205
+ size: :medium,
206
+ block: false,
207
+ id: "button-preview",
208
+ align_content: :center
209
+ )
210
+ render_with_template(locals: {
211
+ scheme: scheme,
212
+ size: size,
213
+ block: block,
214
+ id: id,
215
+ align_content: align_content
216
+ })
217
+ end
218
+
219
+ # @label Trailing action
220
+ # @param block toggle
221
+ # @param align_content select [center, start]
222
+ def trailing_action(
223
+ block: false,
224
+ id: "button-preview",
225
+ align_content: :center
226
+ )
227
+ render_with_template(locals: {
228
+ block: block,
229
+ id: id,
230
+ align_content: align_content
231
+ })
232
+ end
233
+
234
+ # @label With tooltip
235
+ # @param scheme select [default, primary, danger, outline, invisible, link]
236
+ # @param size select [small, medium]
237
+ # @param block toggle
238
+ # @param align_content select [center, start]
239
+ def with_tooltip(
240
+ scheme: :default,
241
+ size: :medium,
242
+ block: false,
243
+ id: "button-preview",
244
+ align_content: :center
245
+ )
246
+ render_with_template(locals: {
247
+ scheme: scheme,
248
+ size: size,
249
+ block: block,
250
+ id: id,
251
+ align_content: align_content
252
+ })
253
+ end
254
+ end
255
+ end
256
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Primer
4
+ module Beta
5
+ # @label CloseButton
6
+ class CloseButtonPreview < ViewComponent::Preview
7
+ # @label Default options
8
+ #
9
+ # @param type [Symbol] select [button, submit]
10
+ def default(type: :button)
11
+ render(Primer::Beta::CloseButton.new(type: type))
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Primer
4
+ module Beta
5
+ # @label Counter
6
+ class CounterPreview < ViewComponent::Preview
7
+ # @label Default Options
8
+ #
9
+ # @param count number
10
+ # @param limit number
11
+ # @param hide_if_zero toggle
12
+ # @param round toggle
13
+ # @param scheme [Symbol] select [[Default, default], [Primary, primary], [Secondary, secondary]]]
14
+ def default(count: 1_000, limit: nil, round: false, hide_if_zero: false, scheme: :default)
15
+ render(Primer::Beta::Counter.new(count: count, round: round, limit: limit, hide_if_zero: hide_if_zero, scheme: scheme))
16
+ end
17
+
18
+ # @label With Text
19
+ def with_text
20
+ render(Primer::Beta::Counter.new(text: "∞"))
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,45 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Primer
4
+ module Beta
5
+ # @label Details
6
+ class DetailsPreview < ViewComponent::Preview
7
+ # @label Default options
8
+ #
9
+ # @param overlay [Symbol] select [none, default, dark]
10
+ # @param reset [Boolean] toggle
11
+ def default(reset: false, overlay: :default)
12
+ render Primer::Beta::Details.new(reset: reset, overlay: overlay) do |c|
13
+ c.with_summary do
14
+ "Summary"
15
+ end
16
+ c.with_body do
17
+ "Body"
18
+ end
19
+ end
20
+ end
21
+
22
+ # @label Custom button
23
+ #
24
+ # @param overlay [Symbol] select [none, default, dark]
25
+ # @param reset [Boolean] toggle
26
+ def custom_button(reset: false, overlay: :default)
27
+ render Primer::Beta::Details.new(reset: reset, overlay: overlay) do |c|
28
+ c.summary(size: :small, scheme: :primary) { "Click me" }
29
+ c.body { "Body" }
30
+ end
31
+ end
32
+
33
+ # @label Without button
34
+ #
35
+ # @param overlay [Symbol] select [none, default, dark]
36
+ # @param reset [Boolean] toggle
37
+ def without_button(reset: false, overlay: :default)
38
+ render Primer::Beta::Details.new(reset: reset, overlay: overlay) do |c|
39
+ c.summary(button: false) { "Click me" }
40
+ c.body { "Body" }
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Primer
4
+ module Beta
5
+ # @label Flash
6
+ class FlashPreview < ViewComponent::Preview
7
+ # @label Default
8
+ #
9
+ # @param full toggle
10
+ # @param spacious toggle
11
+ # @param dismissible toggle
12
+ # @param icon [Symbol] select [alert, check, info, people]
13
+ # @param scheme [Symbol] select [default, warning, danger, success]
14
+ # @param content text
15
+ def default(full: false, spacious: false, dismissible: false, icon: :people, scheme: Primer::Beta::Flash::DEFAULT_SCHEME, content: "This is a flash message!")
16
+ render(Primer::Beta::Flash.new(full: full, spacious: spacious, dismissible: dismissible, icon: icon, scheme: scheme)) { content }
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Primer
4
+ module Beta
5
+ # @label Heading
6
+ class HeadingPreview < ViewComponent::Preview
7
+ # @label Default options
8
+ #
9
+ # @param tag [Symbol] select [h1, h2, h3, h4, h5, h6]
10
+ # @param content [String] text
11
+ def default(tag: :h2, content: "Heading")
12
+ render(Primer::Beta::Heading.new(tag: tag)) { content }
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,107 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Primer
4
+ module Beta
5
+ # @label IconButton
6
+ class IconButtonPreview < ViewComponent::Preview
7
+ # @label Playground
8
+ # @param scheme select [default, danger, invisible]
9
+ # @param size select [small, medium, large]
10
+ # @param aria_label text
11
+ # @param disabled toggle
12
+ # @param tag select [a, summary, button]
13
+ # @param icon [Symbol] octicon
14
+ def playground(
15
+ scheme: :default,
16
+ size: :medium,
17
+ id: "button-preview",
18
+ tag: :button,
19
+ disabled: false,
20
+ icon: :plus,
21
+ aria_label: "Button"
22
+ )
23
+ render(Primer::Beta::IconButton.new(
24
+ scheme: scheme,
25
+ size: size,
26
+ id: id,
27
+ tag: tag,
28
+ disabled: disabled,
29
+ icon: icon,
30
+ "aria-label": aria_label
31
+ ))
32
+ end
33
+
34
+ # @label Default
35
+ # @param size select [small, medium, large]
36
+ # @param aria_label text
37
+ # @param disabled toggle
38
+ # @param tag select [a, summary, button]
39
+ def default(
40
+ size: :medium,
41
+ id: "button-preview",
42
+ tag: :button,
43
+ disabled: false,
44
+ icon: :star,
45
+ aria_label: "Button"
46
+ )
47
+ render(Primer::Beta::IconButton.new(
48
+ scheme: :default,
49
+ size: size,
50
+ id: id,
51
+ tag: tag,
52
+ disabled: disabled,
53
+ icon: icon,
54
+ "aria-label": aria_label
55
+ ))
56
+ end
57
+
58
+ # @label Invisible
59
+ # @param size select [small, medium, large]
60
+ # @param aria_label text
61
+ # @param disabled toggle
62
+ # @param tag select [a, summary, button]
63
+ def invisible(
64
+ size: :medium,
65
+ id: "button-preview",
66
+ tag: :button,
67
+ disabled: false,
68
+ icon: :x,
69
+ aria_label: "Button"
70
+ )
71
+ render(Primer::Beta::IconButton.new(
72
+ scheme: :invisible,
73
+ size: size,
74
+ id: id,
75
+ tag: tag,
76
+ disabled: disabled,
77
+ icon: icon,
78
+ "aria-label": aria_label
79
+ ))
80
+ end
81
+
82
+ # @label Danger
83
+ # @param size select [small, medium, large]
84
+ # @param aria_label text
85
+ # @param disabled toggle
86
+ # @param tag select [a, summary, button]
87
+ def danger(
88
+ size: :medium,
89
+ id: "button-preview",
90
+ tag: :button,
91
+ disabled: false,
92
+ icon: :trash,
93
+ aria_label: "Button"
94
+ )
95
+ render(Primer::Beta::IconButton.new(
96
+ scheme: :danger,
97
+ size: size,
98
+ id: id,
99
+ tag: tag,
100
+ disabled: disabled,
101
+ icon: icon,
102
+ "aria-label": aria_label
103
+ ))
104
+ end
105
+ end
106
+ end
107
+ end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Primer
4
+ module Beta
5
+ # @label Text
6
+ class TextPreview < ViewComponent::Preview
7
+ # @label Default options
8
+ #
9
+ # @param tag [Symbol] select [div, p, span]
10
+ # @param content [String] text
11
+ def default(tag: :span, content: "Text")
12
+ render(Primer::Beta::Text.new(tag: tag)) { content }
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,47 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Primer
4
+ module Beta
5
+ # @label Truncate
6
+ class TruncatePreview < ViewComponent::Preview
7
+ # @label Default options
8
+ #
9
+ # @param text [String] text
10
+ def default(text: "branch-name-that-is-really-long")
11
+ render(Primer::Beta::Truncate.new) { text }
12
+ end
13
+
14
+ # @label Multiple items
15
+ def multiple_items
16
+ render(Primer::Beta::Truncate.new) do |component|
17
+ component.with_item do
18
+ "really-long-repository-owner-name"
19
+ end
20
+ component.with_item(font_weight: :bold) do
21
+ "really-long-repository-name"
22
+ end
23
+ end
24
+ end
25
+
26
+ # @label Advanced multiple items
27
+ def advanced_multiple_items
28
+ render(Primer::Beta::Truncate.new(tag: :ol)) do |component|
29
+ component.with_item(tag: :li) { "primer" }
30
+ component.with_item(tag: :li, priority: true) { "/ css" }
31
+ component.with_item(tag: :li) { "/ Issues" }
32
+ component.with_item(tag: :li) { "/ #123" }
33
+ component.with_item(tag: :li, priority: true) { "Visual bug on primer.style found in lists" }
34
+ end
35
+ end
36
+
37
+ # @label Max widths
38
+ def max_widths
39
+ render(Primer::Beta::Truncate.new) do |component|
40
+ component.with_item(max_width: 300) { "branch-name-that-is-really-long-branch-name-that-is-really-long-branch-name-that-is-really-long" }
41
+ component.with_item(max_width: 200) { "branch-name-that-is-really-long-branch-name-that-is-really-long-branch-name-that-is-really-long" }
42
+ component.with_item(max_width: 100) { "branch-name-that-is-really-long-branch-name-that-is-really-long-branch-name-that-is-really-long" }
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,2 @@
1
+ <%= render(Primer::ClipboardCopy.new(for: "blob-path", "aria-label": aria_label)) %>
2
+ <div id="blob-path">src/index.js</div>
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Primer
4
+ # @label ClipboardCopy
5
+ class ClipboardCopyPreview < ViewComponent::Preview
6
+ # @label Default Options
7
+ #
8
+ # @param aria_label [String]
9
+ # @param value [String]
10
+ def default(value: "Text to copy", aria_label: "Copy text to the system clipboard")
11
+ render(Primer::ClipboardCopy.new(value: value, "aria-label": aria_label))
12
+ end
13
+
14
+ # @label With text instead of icons
15
+ #
16
+ # @param aria_label [String]
17
+ # @param value [String]
18
+ def text(value: "Text to copy", aria_label: "Copy text to the system clipboard")
19
+ render(Primer::ClipboardCopy.new(value: value, "aria-label": aria_label)) { "Click to copy!" }
20
+ end
21
+
22
+ # @label Copying from an element
23
+ #
24
+ # @param aria_label [String]
25
+ def element(aria_label: "Copy text to the system clipboard")
26
+ render_with_template(locals: { aria_label: aria_label })
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Primer
4
+ # @label Dropdown
5
+ class DropdownPreview < ViewComponent::Preview
6
+ # @label Default Options
7
+ #
8
+ # @param with_caret [Boolean] toggle
9
+ # @param overlay [Symbol] select [none, default, dark]
10
+ def default(overlay: :default, with_caret: false)
11
+ render(Primer::Dropdown.new(overlay: overlay, with_caret: with_caret)) do |c|
12
+ c.with_button { "Dropdown" }
13
+
14
+ c.with_menu(header: "Header") do |m|
15
+ m.with_item { "Item 1" }
16
+ m.with_item { "Item 2" }
17
+ m.with_item(divider: true)
18
+ m.with_item { "Item 3" }
19
+ m.with_item { "Item 4" }
20
+ end
21
+ end
22
+ end
23
+
24
+ # @label Menu Options
25
+ #
26
+ # @param as [Symbol] select [list, default]
27
+ # @param direction [Symbol] select [se, sw, w, e, ne, s]
28
+ # @param scheme [Symbol] select [default, dark]
29
+ def menu(as: :default, direction: :se, scheme: :default)
30
+ render(Primer::Dropdown::Menu.new(as: as, direction: direction, scheme: scheme, header: "Header")) do |m|
31
+ m.with_item { "Item 1" }
32
+ m.with_item { "Item 2" }
33
+ m.with_item(divider: true)
34
+ m.with_item { "Item 3" }
35
+ m.with_item { "Item 4" }
36
+ end
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,3 @@
1
+ <%= primer_form_with(url: "/foo") do |f| %>
2
+ <%= render(AfterContentForm.new(f)) %>
3
+ <% end %>
@@ -0,0 +1,3 @@
1
+ <%= primer_form_with(url: "/foo") do |f| %>
2
+ <%= render(ArrayCheckBoxGroupForm.new(f)) %>
3
+ <% end %>
@@ -0,0 +1,3 @@
1
+ <%= primer_form_with(url: "/foo") do |f| %>
2
+ <%= render(CaptionTemplateForm.new(f)) %>
3
+ <% end %>
@@ -0,0 +1,3 @@
1
+ <%= primer_form_with(url: "/foo") do |f| %>
2
+ <%= render(CheckBoxGroupForm.new(f)) %>
3
+ <% end %>
@@ -0,0 +1,4 @@
1
+ <p>Each of these fields comes from its own form definition.</p>
2
+ <%= primer_form_with(url: "/foo") do |f| %>
3
+ <%= render(ComposedForm.new(f)) %>
4
+ <% end %>
@@ -0,0 +1,3 @@
1
+ <%= primer_form_with(url: "/foo") do |f| %>
2
+ <%= render(HorizontalForm.new(f)) %>
3
+ <% end %>
@@ -0,0 +1,3 @@
1
+ <%= primer_form_with(url: "/foo") do |f| %>
2
+ <%= render(InvalidForm.new(f)) %>
3
+ <% end %>
@@ -0,0 +1,3 @@
1
+ <%= primer_form_with(url: "/foo") do |f| %>
2
+ <%= render(MultiInputForm.new(f)) %>
3
+ <% end %>
@@ -0,0 +1,3 @@
1
+ <%= primer_form_with(url: "/foo") do |f| %>
2
+ <%= render(MultiTextFieldForm.new(f)) %>
3
+ <% end %>
@@ -0,0 +1,3 @@
1
+ <%= primer_form_with(url: "/foo") do |f| %>
2
+ <%= render(RadioButtonGroupForm.new(f)) %>
3
+ <% end %>
@@ -0,0 +1,3 @@
1
+ <%= primer_form_with(url: "/foo") do |f| %>
2
+ <%= render(RadioButtonWithNestedForm.new(f)) %>
3
+ <% end %>
@@ -0,0 +1,3 @@
1
+ <%= primer_form_with(url: "/foo") do |f| %>
2
+ <%= render(SelectListForm.new(f)) %>
3
+ <% end %>