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,40 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Primer
4
+ module Beta
5
+ # @label AutoCompleteItem
6
+ class AutoCompleteItemPreview < ViewComponent::Preview
7
+ # @label Default
8
+ # @param selected toggle
9
+ # @param disabled toggle
10
+ # @param value text
11
+ def default(value: "", selected: false, disabled: false)
12
+ render_with_template(
13
+ locals: {
14
+ selected: selected,
15
+ disabled: disabled,
16
+ value: value
17
+ }
18
+ )
19
+ end
20
+
21
+ # @label WithDescription
22
+ # @param description_variant select [block, inline]
23
+ # @param selected toggle
24
+ # @param disabled toggle
25
+ # @param value text
26
+ def with_description(description_variant: "block", value: "", selected: false, disabled: false)
27
+ description_variant = description_variant.to_sym
28
+
29
+ render_with_template(
30
+ locals: {
31
+ description_variant: description_variant,
32
+ selected: selected,
33
+ disabled: disabled,
34
+ value: value
35
+ }
36
+ )
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,20 @@
1
+ <div class="d-flex flex-items-start flex-column flex-sm-row flex-sm-items-end" style="gap: .5rem">
2
+ <%= render(
3
+ Primer::Beta::AutoComplete.new(
4
+ label_text: label_text,
5
+ input_id: input_id,
6
+ list_id: list_id,
7
+ src: "/auto_complete",
8
+ show_clear_button: show_clear_button,
9
+ visually_hide_label: visually_hide_label,
10
+ placeholder: placeholder,
11
+ size: size,
12
+ full_width: full_width,
13
+ disabled: disabled,
14
+ invalid: invalid,
15
+ input_name: input_name
16
+ )) do |c| %>
17
+ <% c.leading_visual_icon(icon: :search) %>
18
+ <% end %>
19
+ <%= render(Primer::ButtonComponent.new(scheme: :primary)) { "Submit" } %>
20
+ </div>
@@ -0,0 +1,245 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Primer
4
+ module Beta
5
+ # @label AutoComplete
6
+ class AutoCompletePreview < ViewComponent::Preview
7
+ # @label Default
8
+ # @param label_text text
9
+ # @param show_clear_button toggle
10
+ # @param visually_hide_label toggle
11
+ # @param placeholder text
12
+ # @param size select [small, medium, large]
13
+ # @param full_width toggle
14
+ # @param disabled toggle
15
+ # @param invalid toggle
16
+ # @param input_id text
17
+ # @param list_id text
18
+ # @param input_name text
19
+ # @param inset toggle
20
+ # @param monospace toggle
21
+ def default(label_text: "Select a fruit", show_clear_button: false, visually_hide_label: false, placeholder: "Placeholder text", size: :medium, full_width: false, disabled: false, invalid: false, input_id: "input-id", list_id: "list-id", input_name: "input-id", inset: false, monospace: false)
22
+ render(Primer::Beta::AutoComplete.new(label_text: label_text, input_id: input_id, list_id: list_id, src: "/auto_complete", show_clear_button: show_clear_button, visually_hide_label: visually_hide_label, placeholder: placeholder, size: size, full_width: full_width, disabled: disabled, invalid: invalid, input_name: input_name, inset: inset, monospace: monospace)) do |c|
23
+ c.leading_visual_icon(icon: :search)
24
+ end
25
+ end
26
+
27
+ # @label With submit button
28
+ # @param label_text text
29
+ # @param show_clear_button toggle
30
+ # @param visually_hide_label toggle
31
+ # @param placeholder text
32
+ # @param size select [small, medium, large]
33
+ # @param full_width toggle
34
+ # @param disabled toggle
35
+ # @param invalid toggle
36
+ # @param input_id text
37
+ # @param list_id text
38
+ # @param input_name text
39
+ def with_submit_button(label_text: "Select a fruit", show_clear_button: false, visually_hide_label: false, placeholder: "Placeholder text", size: :medium, full_width: true, disabled: false, invalid: false, input_id: "input-id", list_id: "list-id", input_name: "input-id")
40
+ render_with_template(locals: {
41
+ label_text: label_text,
42
+ show_clear_button: show_clear_button,
43
+ visually_hide_label: visually_hide_label,
44
+ placeholder: placeholder,
45
+ size: size,
46
+ full_width: full_width,
47
+ disabled: disabled,
48
+ invalid: invalid,
49
+ input_id: input_id,
50
+ list_id: list_id,
51
+ input_name: input_name
52
+ })
53
+ end
54
+
55
+ # @label Leading visual
56
+ # @param label_text text
57
+ # @param show_clear_button toggle
58
+ # @param visually_hide_label toggle
59
+ # @param placeholder text
60
+ # @param size select [small, medium, large]
61
+ # @param full_width toggle
62
+ # @param disabled toggle
63
+ # @param invalid toggle
64
+ # @param input_id text
65
+ # @param list_id text
66
+ # @param input_name text
67
+ def leading_visual(label_text: "Select a fruit", show_clear_button: false, visually_hide_label: false, placeholder: "Placeholder text", size: :medium, full_width: false, disabled: false, invalid: false, input_id: "input-id", list_id: "list-id", input_name: "input-id")
68
+ render(Primer::Beta::AutoComplete.new(label_text: label_text, input_id: input_id, list_id: list_id, src: "/auto_complete", show_clear_button: show_clear_button, visually_hide_label: visually_hide_label, placeholder: placeholder, size: size, full_width: full_width, disabled: disabled, invalid: invalid, input_name: input_name)) do |c|
69
+ c.leading_visual_icon(icon: :search)
70
+ end
71
+ end
72
+
73
+ # @label Trailing action
74
+ # @param label_text text
75
+ # @param show_clear_button toggle
76
+ # @param visually_hide_label toggle
77
+ # @param placeholder text
78
+ # @param size select [small, medium, large]
79
+ # @param full_width toggle
80
+ # @param disabled toggle
81
+ # @param invalid toggle
82
+ # @param input_id text
83
+ # @param list_id text
84
+ # @param input_name text
85
+ def trailing_action(label_text: "Select a fruit", show_clear_button: true, visually_hide_label: false, placeholder: "Placeholder text", size: :medium, full_width: false, disabled: false, invalid: false, input_id: "input-id", list_id: "list-id", input_name: "input-id")
86
+ render(Primer::Beta::AutoComplete.new(label_text: label_text, input_id: input_id, list_id: list_id, src: "/auto_complete", show_clear_button: show_clear_button, visually_hide_label: visually_hide_label, placeholder: placeholder, size: size, full_width: full_width, disabled: disabled, invalid: invalid, input_name: input_name))
87
+ end
88
+
89
+ # @label Full width
90
+ # @param label_text text
91
+ # @param show_clear_button toggle
92
+ # @param visually_hide_label toggle
93
+ # @param placeholder text
94
+ # @param size select [small, medium, large]
95
+ # @param full_width toggle
96
+ # @param disabled toggle
97
+ # @param invalid toggle
98
+ # @param input_id text
99
+ # @param list_id text
100
+ # @param input_name text
101
+ def full_width(label_text: "Select a fruit", show_clear_button: false, visually_hide_label: false, placeholder: "Placeholder text", size: :medium, full_width: true, disabled: false, invalid: false, input_id: "input-id", list_id: "list-id", input_name: "input-id")
102
+ render(Primer::Beta::AutoComplete.new(label_text: label_text, input_id: input_id, list_id: list_id, src: "/auto_complete", show_clear_button: show_clear_button, visually_hide_label: visually_hide_label, placeholder: placeholder, size: size, full_width: full_width, disabled: disabled, invalid: invalid, input_name: input_name)) do |c|
103
+ c.leading_visual_icon(icon: :search)
104
+ end
105
+ end
106
+
107
+ # @label Visually hide label
108
+ # @param label_text text
109
+ # @param show_clear_button toggle
110
+ # @param visually_hide_label toggle
111
+ # @param placeholder text
112
+ # @param size select [small, medium, large]
113
+ # @param full_width toggle
114
+ # @param disabled toggle
115
+ # @param invalid toggle
116
+ # @param input_id text
117
+ # @param list_id text
118
+ # @param input_name text
119
+ def visually_hide_label(label_text: "Select a fruit", show_clear_button: false, visually_hide_label: true, placeholder: "Placeholder text", size: :medium, full_width: false, disabled: false, invalid: false, input_id: "input-id", list_id: "list-id", input_name: "input-id")
120
+ render(Primer::Beta::AutoComplete.new(label_text: label_text, input_id: input_id, list_id: list_id, src: "/auto_complete", show_clear_button: show_clear_button, visually_hide_label: visually_hide_label, placeholder: placeholder, size: size, full_width: full_width, disabled: disabled, invalid: invalid, input_name: input_name)) do |c|
121
+ c.leading_visual_icon(icon: :search)
122
+ end
123
+ end
124
+
125
+ # @!group Sizes
126
+
127
+ # @param label_text text
128
+ # @param show_clear_button toggle
129
+ # @param visually_hide_label toggle
130
+ # @param placeholder text
131
+ # @param size select [small, medium, large]
132
+ # @param full_width toggle
133
+ # @param disabled toggle
134
+ # @param invalid toggle
135
+ # @param input_id text
136
+ # @param list_id text
137
+ # @param input_name text
138
+ def small(label_text: "Select a fruit", show_clear_button: false, visually_hide_label: false, placeholder: "Placeholder text", size: :small, full_width: false, disabled: false, invalid: false, input_id: "input-id-1", list_id: "list-id-1", input_name: "input-id-1")
139
+ render(Primer::Beta::AutoComplete.new(label_text: label_text, input_id: input_id, list_id: list_id, src: "/auto_complete", show_clear_button: show_clear_button, visually_hide_label: visually_hide_label, placeholder: placeholder, size: size, full_width: full_width, disabled: disabled, invalid: invalid, input_name: input_name)) do |c|
140
+ c.leading_visual_icon(icon: :search)
141
+ end
142
+ end
143
+
144
+ # @param label_text text
145
+ # @param show_clear_button toggle
146
+ # @param visually_hide_label toggle
147
+ # @param placeholder text
148
+ # @param size select [small, medium, large]
149
+ # @param full_width toggle
150
+ # @param disabled toggle
151
+ # @param invalid toggle
152
+ # @param input_id text
153
+ # @param list_id text
154
+ # @param input_name text
155
+ def medium(label_text: "Select a fruit", show_clear_button: false, visually_hide_label: false, placeholder: "Placeholder text", size: :medium, full_width: false, disabled: false, invalid: false, input_id: "input-id-2", list_id: "list-id-2", input_name: "input-id-2")
156
+ render(Primer::Beta::AutoComplete.new(label_text: label_text, input_id: input_id, list_id: list_id, src: "/auto_complete", show_clear_button: show_clear_button, visually_hide_label: visually_hide_label, placeholder: placeholder, size: size, full_width: full_width, disabled: disabled, invalid: invalid, input_name: input_name)) do |c|
157
+ c.leading_visual_icon(icon: :search)
158
+ end
159
+ end
160
+
161
+ # @param label_text text
162
+ # @param show_clear_button toggle
163
+ # @param visually_hide_label toggle
164
+ # @param placeholder text
165
+ # @param size select [small, medium, large]
166
+ # @param full_width toggle
167
+ # @param disabled toggle
168
+ # @param invalid toggle
169
+ # @param input_id text
170
+ # @param list_id text
171
+ # @param input_name text
172
+ def large(label_text: "Select a fruit", show_clear_button: false, visually_hide_label: false, placeholder: "Placeholder text", size: :large, full_width: false, disabled: false, invalid: false, input_id: "input-id-3", list_id: "list-id-3", input_name: "input-id-3")
173
+ render(Primer::Beta::AutoComplete.new(label_text: label_text, input_id: input_id, list_id: list_id, src: "/auto_complete", show_clear_button: show_clear_button, visually_hide_label: visually_hide_label, placeholder: placeholder, size: size, full_width: full_width, disabled: disabled, invalid: invalid, input_name: input_name)) do |c|
174
+ c.leading_visual_icon(icon: :search)
175
+ end
176
+ end
177
+
178
+ # @!endgroup
179
+
180
+ # @label Leading visual in results
181
+ # @param label_text text
182
+ # @param show_clear_button toggle
183
+ # @param visually_hide_label toggle
184
+ # @param placeholder text
185
+ # @param size select [small, medium, large]
186
+ # @param full_width toggle
187
+ # @param disabled toggle
188
+ # @param invalid toggle
189
+ # @param input_id text
190
+ # @param list_id text
191
+ # @param input_name text
192
+ def leading_visual_in_results(label_text: "Select a fruit", show_clear_button: false, visually_hide_label: false, placeholder: "Placeholder text", size: :medium, full_width: false, disabled: false, invalid: false, input_id: "input-id", list_id: "list-id", input_name: "input-id")
193
+ render(Primer::Beta::AutoComplete.new(label_text: label_text, input_id: input_id, list_id: list_id, src: "/auto_complete?visual=leading", show_clear_button: show_clear_button, visually_hide_label: visually_hide_label, placeholder: placeholder, size: size, full_width: full_width, disabled: disabled, invalid: invalid, input_name: input_name))
194
+ end
195
+
196
+ # @label Trailing visual in results
197
+ # @param label_text text
198
+ # @param show_clear_button toggle
199
+ # @param visually_hide_label toggle
200
+ # @param placeholder text
201
+ # @param size select [small, medium, large]
202
+ # @param full_width toggle
203
+ # @param disabled toggle
204
+ # @param invalid toggle
205
+ # @param input_id text
206
+ # @param list_id text
207
+ # @param input_name text
208
+ def trailing_visual_in_results(label_text: "Select a fruit", show_clear_button: false, visually_hide_label: false, placeholder: "Placeholder text", size: :medium, full_width: false, disabled: false, invalid: false, input_id: "input-id", list_id: "list-id", input_name: "input-id")
209
+ render(Primer::Beta::AutoComplete.new(label_text: label_text, input_id: input_id, list_id: list_id, src: "/auto_complete?visual=trailing", show_clear_button: show_clear_button, visually_hide_label: visually_hide_label, placeholder: placeholder, size: size, full_width: full_width, disabled: disabled, invalid: invalid, input_name: input_name))
210
+ end
211
+
212
+ # @hidden
213
+ def with_non_visible_label
214
+ render(Primer::Beta::AutoComplete.new(label_text: "Select a fruit", input_id: "input-id", list_id: "test-id", src: "/auto_complete", visually_hide_label: true))
215
+ end
216
+
217
+ # @hidden
218
+ def with_icon
219
+ render(Primer::Beta::AutoComplete.new(label_text: "Select a fruit", input_id: "input-id", list_id: "test-id", src: "/auto_complete")) do |c|
220
+ c.leading_visual_icon(icon: :search)
221
+ end
222
+ end
223
+
224
+ # @hidden
225
+ def show_clear_button
226
+ render(Primer::Beta::AutoComplete.new(label_text: "Select a fruit", input_id: "input-id", list_id: "test-id", src: "/auto_complete", show_clear_button: true))
227
+ end
228
+
229
+ # @hidden
230
+ def size_small
231
+ render(Primer::Beta::AutoComplete.new(label_text: "Select a fruit", input_id: "input-id", list_id: "test-id", src: "/auto_complete", show_clear_button: false, size: :small))
232
+ end
233
+
234
+ # @hidden
235
+ def monospace
236
+ render(Primer::Beta::AutoComplete.new(label_text: "Select a fruit", input_id: "input-id", list_id: "test-id", src: "/auto_complete", show_clear_button: false, monospace: true))
237
+ end
238
+
239
+ # @hidden
240
+ def inset
241
+ render(Primer::Beta::AutoComplete.new(label_text: "Select a fruit", input_id: "input-id", list_id: "test-id", src: "/auto_complete", show_clear_button: false, inset: true))
242
+ end
243
+ end
244
+ end
245
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Primer
4
+ module Beta
5
+ # @label Avatar
6
+ class AvatarPreview < ViewComponent::Preview
7
+ # @label Default options
8
+ #
9
+ # @param size [Integer] select [16, 20, 24, 32, 40, 48, 80]
10
+ # @param shape [Symbol] select [circle, square]
11
+ # @param href [String] text
12
+ def default(size: 24, shape: :circle, href: nil)
13
+ render(Primer::Beta::Avatar.new(src: Primer::ExampleImage::BASE64_SRC, alt: "@kittenuser", size: size, shape: shape, href: href))
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,44 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Primer
4
+ module Beta
5
+ # @label AvatarStack
6
+ class AvatarStackPreview < ViewComponent::Preview
7
+ # @label Default options
8
+ #
9
+ # @param number_of_avatars [Integer] number
10
+ # @param tag select [["div", div], ["span", span]]
11
+ # @param align select [["Left", left], ["Right", right]]
12
+ # @param tooltipped toggle
13
+ # @param tooltip_label text
14
+ def default(number_of_avatars: 1, tag: :div, align: :left, tooltipped: false, tooltip_label: "This is a tooltip!")
15
+ render(Primer::Beta::AvatarStack.new(tag: tag, align: align, tooltipped: tooltipped, body_arguments: { label: tooltip_label })) do |c|
16
+ Array.new(number_of_avatars || 1) do
17
+ c.avatar(src: Primer::ExampleImage::BASE64_SRC, alt: "@kittenuser")
18
+ end
19
+ end
20
+ end
21
+
22
+ # @!group More Examples
23
+
24
+ # @label Align right
25
+ def align_right
26
+ render(Primer::Beta::AvatarStack.new(align: :right)) do |c|
27
+ c.avatar(src: Primer::ExampleImage::BASE64_SRC, alt: "@kittenuser")
28
+ c.avatar(src: Primer::ExampleImage::BASE64_SRC, alt: "@kittenuser")
29
+ c.avatar(src: Primer::ExampleImage::BASE64_SRC, alt: "@kittenuser")
30
+ end
31
+ end
32
+
33
+ # @label With tooltip
34
+ def with_tooltip
35
+ render(Primer::Beta::AvatarStack.new(tooltipped: true, body_arguments: { label: "This is a tooltip!" })) do |c|
36
+ c.avatar(src: Primer::ExampleImage::BASE64_SRC, alt: "@kittenuser")
37
+ c.avatar(src: Primer::ExampleImage::BASE64_SRC, alt: "@kittenuser")
38
+ c.avatar(src: Primer::ExampleImage::BASE64_SRC, alt: "@kittenuser")
39
+ end
40
+ end
41
+ # @!endgroup
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Primer
4
+ module Beta
5
+ # @label BaseButton
6
+ class BaseButtonPreview < ViewComponent::Preview
7
+ # @label Default options
8
+ #
9
+ # @param type [Symbol] select [button, submit]
10
+ # @param tag [Symbol] select [button, a, summary]
11
+ # @param block [Boolean] toggle
12
+ def default(tag: :button, block: false, type: :button)
13
+ render(Primer::Beta::BaseButton.new(tag: tag, block: block, type: type)) { "Button" }
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,94 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Primer
4
+ module Beta
5
+ # @label Blankslate
6
+ class BlankslatePreview < ViewComponent::Preview
7
+ # @label Default options
8
+ #
9
+ # @param narrow [Boolean] toggle
10
+ # @param spacious [Boolean] toggle
11
+ # @param border [Boolean] toggle
12
+ def default(narrow: false, spacious: false, border: false)
13
+ render Primer::Beta::Blankslate.new(narrow: narrow, spacious: spacious, border: border) do |c|
14
+ c.heading(tag: :h2).with_content("Title")
15
+ c.description { "Description" }
16
+ end
17
+ end
18
+
19
+ # @param narrow [Boolean] toggle
20
+ # @param spacious [Boolean] toggle
21
+ # @param border [Boolean] toggle
22
+ def with_icon(narrow: false, spacious: false, border: false)
23
+ render Primer::Beta::Blankslate.new(narrow: narrow, spacious: spacious, border: border) do |c|
24
+ c.visual_icon(icon: :shield)
25
+ c.heading(tag: :h2).with_content("It looks like we have discovered a vulnerability")
26
+ end
27
+ end
28
+
29
+ # @param narrow [Boolean] toggle
30
+ # @param spacious [Boolean] toggle
31
+ # @param border [Boolean] toggle
32
+ def with_image(narrow: false, spacious: false, border: false)
33
+ render Primer::Beta::Blankslate.new(narrow: narrow, spacious: spacious, border: border) do |c|
34
+ c.heading(tag: :h2).with_content("Millions of teams trust GitHub to keep their work safe")
35
+ c.visual_image(src: Primer::ExampleImage::BASE64_SRC, alt: "Security - secure vault")
36
+ end
37
+ end
38
+
39
+ # @param narrow [Boolean] toggle
40
+ # @param spacious [Boolean] toggle
41
+ # @param border [Boolean] toggle
42
+ def loading(narrow: false, spacious: false, border: false)
43
+ render Primer::Beta::Blankslate.new(narrow: narrow, spacious: spacious, border: border) do |c|
44
+ c.heading(tag: :h2).with_content("Mirroring your repository")
45
+ c.description { "We’re currently mirroring this repository. It should take anywhere from a few minutes to a couple of hours depending on the size of the repository." }
46
+ c.visual_spinner(size: :large)
47
+ end
48
+ end
49
+
50
+ # @param narrow [Boolean] toggle
51
+ # @param spacious [Boolean] toggle
52
+ # @param border [Boolean] toggle
53
+ def description(narrow: false, spacious: false, border: false)
54
+ render Primer::Beta::Blankslate.new(narrow: narrow, spacious: spacious, border: border) do |c|
55
+ c.heading(tag: :h2).with_content("It looks like we have discovered a vulnerability")
56
+ c.description { "Millions of teams trust GitHub to keep their work safe" }
57
+ end
58
+ end
59
+
60
+ # @param narrow [Boolean] toggle
61
+ # @param spacious [Boolean] toggle
62
+ # @param border [Boolean] toggle
63
+ def primary_action(narrow: false, spacious: false, border: false)
64
+ render Primer::Beta::Blankslate.new(narrow: narrow, spacious: spacious, border: border) do |c|
65
+ c.heading(tag: :h2).with_content("It looks like we have discovered a vulnerability")
66
+ c.primary_action(href: "#").with_content("Fix issue")
67
+ end
68
+ end
69
+
70
+ # @param narrow [Boolean] toggle
71
+ # @param spacious [Boolean] toggle
72
+ # @param border [Boolean] toggle
73
+ def secondary_action(narrow: false, spacious: false, border: false)
74
+ render Primer::Beta::Blankslate.new(narrow: narrow, spacious: spacious, border: border) do |c|
75
+ c.heading(tag: :h2).with_content("It looks like we have discovered a vulnerability")
76
+ c.secondary_action(href: "#").with_content("Fix issue")
77
+ end
78
+ end
79
+
80
+ # @param narrow [Boolean] toggle
81
+ # @param spacious [Boolean] toggle
82
+ # @param border [Boolean] toggle
83
+ def full(narrow: false, spacious: false, border: false)
84
+ render Primer::Beta::Blankslate.new(narrow: narrow, spacious: spacious, border: border) do |c|
85
+ c.visual_icon(icon: :shield)
86
+ c.heading(tag: :h2).with_content("It looks like we have discovered a vulnerability")
87
+ c.description { "Millions of teams trust GitHub to keep their work safe" }
88
+ c.primary_action(href: "#").with_content("Fix issue")
89
+ c.secondary_action(href: "#").with_content("Learn more about vulnerabilities")
90
+ end
91
+ end
92
+ end
93
+ end
94
+ end
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Primer
4
+ module Beta
5
+ # @label BorderBox
6
+ class BorderBoxPreview < ViewComponent::Preview
7
+ # @label Default options
8
+ #
9
+ # @param padding [Symbol] select [default, condensed]
10
+ def default(padding: :default)
11
+ render(Primer::Beta::BorderBox.new(padding: padding)) do |component|
12
+ component.header { "Header" }
13
+ component.body { "Body" }
14
+ component.row { "Row one" }
15
+ component.row { "Row two" }
16
+ component.row { "Row three" }
17
+ component.footer { "Footer" }
18
+ end
19
+ end
20
+
21
+ # @label Row schemes
22
+ #
23
+ # @param padding [Symbol] select [default, condensed]
24
+ # @param scheme [Symbol] select [default, neutral, info, warning]
25
+ def row_schemes(padding: :default, scheme: :default)
26
+ render(Primer::Beta::BorderBox.new(padding: padding)) do |component|
27
+ component.row(scheme: scheme) { "#{scheme.to_s.capitalize} scheme" }
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Primer
4
+ module Beta
5
+ # @label Breadcrumbs
6
+ class BreadcrumbsPreview < ViewComponent::Preview
7
+ # @label Default options
8
+ #
9
+ # @param number_of_links [Integer] number
10
+ def default(number_of_links: 2)
11
+ render(Primer::Beta::Breadcrumbs.new) do |component|
12
+ Array.new(number_of_links || 3) do |i|
13
+ component.item(href: "##{i}") { "Breadcrumb Item #{i + 1}" }
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Primer
4
+ module Beta
5
+ # @label ButtonGroup
6
+ class ButtonGroupPreview < ViewComponent::Preview
7
+ # @label Default options
8
+ #
9
+ # @param size [Symbol] select [medium, small]
10
+ def default(size: :medium)
11
+ render(Primer::Beta::ButtonGroup.new(size: size)) do |c|
12
+ c.button { "Button" }
13
+ c.button(scheme: :primary) { "Primary" }
14
+ c.button(scheme: :danger) { "Danger" }
15
+ c.button(scheme: :outline) { "Outline" }
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,26 @@
1
+ <div style="display: flex; gap: 1rem;">
2
+ <%= render(Primer::Beta::Button.new(
3
+ scheme: :secondary,
4
+ size: :medium,
5
+ )) do |c| %>
6
+ Button
7
+ <% end %>
8
+ <%= render(Primer::Beta::Button.new(
9
+ scheme: :primary,
10
+ size: :medium,
11
+ )) do |c| %>
12
+ Button
13
+ <% end %>
14
+ <%= render(Primer::Beta::Button.new(
15
+ scheme: :invisible,
16
+ size: :medium,
17
+ )) do |c| %>
18
+ Button
19
+ <% end %>
20
+ <%= render(Primer::Beta::Button.new(
21
+ scheme: :danger,
22
+ size: :medium,
23
+ )) do |c| %>
24
+ Button
25
+ <% end %>
26
+ </div>
@@ -0,0 +1,10 @@
1
+ <%= render(Primer::Beta::Button.new(
2
+ scheme: scheme,
3
+ size: size,
4
+ block: block,
5
+ id: id,
6
+ align_content: align_content
7
+ )) do |c| %>
8
+ <% c.leading_visual_icon(icon: :search) %>
9
+ Button
10
+ <% end %>
@@ -0,0 +1,10 @@
1
+ <%= render(Primer::Beta::Button.new(
2
+ scheme: :default,
3
+ size: :medium,
4
+ block: block,
5
+ id: id,
6
+ align_content: align_content
7
+ )) do |c| %>
8
+ <% c.trailing_action_icon(icon: "triangle-down") %>
9
+ Button
10
+ <% end %>
@@ -0,0 +1,11 @@
1
+ <%= render(Primer::Beta::Button.new(
2
+ scheme: scheme,
3
+ size: size,
4
+ block: block,
5
+ id: id,
6
+ align_content: align_content,
7
+ tag: tag
8
+ )) do |c| %>
9
+ <% c.trailing_visual_counter(count: "15") %>
10
+ Button
11
+ <% end %>
@@ -0,0 +1,10 @@
1
+ <%= render(Primer::Beta::Button.new(
2
+ scheme: scheme,
3
+ size: size,
4
+ block: block,
5
+ id: id,
6
+ align_content: align_content
7
+ )) do |c| %>
8
+ <% c.with_tooltip(text: "Tooltip text") %>
9
+ Button
10
+ <% end %>