coveragebook_components 0.19.12 → 0.19.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (133) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/build/coco/coco.js +2 -2
  3. data/lib/coco.rb +1 -1
  4. data/lookbook/app/helpers/application_helper.rb +28 -0
  5. data/lookbook/app/previews/buttons/button_group_preview.rb +148 -0
  6. data/lookbook/app/previews/buttons/button_preview.rb +729 -0
  7. data/lookbook/app/previews/buttons/button_to_preview.rb +18 -0
  8. data/lookbook/app/previews/buttons/color_picker_button_preview.rb +42 -0
  9. data/lookbook/app/previews/buttons/image_picker_button_preview.rb +46 -0
  10. data/lookbook/app/previews/buttons/layout_picker_button_preview/default.html.erb +12 -0
  11. data/lookbook/app/previews/buttons/layout_picker_button_preview.rb +6 -0
  12. data/lookbook/app/previews/buttons/option_bar_preview.rb +29 -0
  13. data/lookbook/app/previews/buttons/toolbar_preview.rb +115 -0
  14. data/lookbook/app/previews/embeds/youtube_embed_preview.rb +7 -0
  15. data/lookbook/app/previews/forms/fields_preview/button.html.erb +3 -0
  16. data/lookbook/app/previews/forms/fields_preview/check_box.html.erb +3 -0
  17. data/lookbook/app/previews/forms/fields_preview/color_field.html.erb +3 -0
  18. data/lookbook/app/previews/forms/fields_preview/date_field.html.erb +3 -0
  19. data/lookbook/app/previews/forms/fields_preview/date_select.html.erb +3 -0
  20. data/lookbook/app/previews/forms/fields_preview/datetime_local_field.html.erb +3 -0
  21. data/lookbook/app/previews/forms/fields_preview/datetime_select.html.erb +3 -0
  22. data/lookbook/app/previews/forms/fields_preview/email_field.html.erb +3 -0
  23. data/lookbook/app/previews/forms/fields_preview/error_message.html.erb +3 -0
  24. data/lookbook/app/previews/forms/fields_preview/file_field.html.erb +3 -0
  25. data/lookbook/app/previews/forms/fields_preview/hint.html.erb +3 -0
  26. data/lookbook/app/previews/forms/fields_preview/label.html.erb +3 -0
  27. data/lookbook/app/previews/forms/fields_preview/month_field.html.erb +3 -0
  28. data/lookbook/app/previews/forms/fields_preview/number_field.html.erb +3 -0
  29. data/lookbook/app/previews/forms/fields_preview/password_field.html.erb +3 -0
  30. data/lookbook/app/previews/forms/fields_preview/radio_button.html.erb +3 -0
  31. data/lookbook/app/previews/forms/fields_preview/range_field.html.erb +3 -0
  32. data/lookbook/app/previews/forms/fields_preview/search_field.html.erb +3 -0
  33. data/lookbook/app/previews/forms/fields_preview/select.html.erb +3 -0
  34. data/lookbook/app/previews/forms/fields_preview/submit.html.erb +3 -0
  35. data/lookbook/app/previews/forms/fields_preview/telephone_field.html.erb +3 -0
  36. data/lookbook/app/previews/forms/fields_preview/text_area.html.erb +3 -0
  37. data/lookbook/app/previews/forms/fields_preview/text_field.html.erb +3 -0
  38. data/lookbook/app/previews/forms/fields_preview/time_field.html.erb +3 -0
  39. data/lookbook/app/previews/forms/fields_preview/time_select.html.erb +3 -0
  40. data/lookbook/app/previews/forms/fields_preview/time_zone_select.html.erb +3 -0
  41. data/lookbook/app/previews/forms/fields_preview/url_field.html.erb +3 -0
  42. data/lookbook/app/previews/forms/fields_preview/week_field.html.erb +3 -0
  43. data/lookbook/app/previews/forms/fields_preview/weekday_select.html.erb +3 -0
  44. data/lookbook/app/previews/forms/fields_preview.rb +111 -0
  45. data/lookbook/app/previews/images/avatar_preview.rb +24 -0
  46. data/lookbook/app/previews/images/icon_preview.rb +141 -0
  47. data/lookbook/app/previews/images/image_preview.rb +15 -0
  48. data/lookbook/app/previews/images/svg_preview.rb +8 -0
  49. data/lookbook/app/previews/indicators/badge_preview.rb +68 -0
  50. data/lookbook/app/previews/indicators/stamp_preview.rb +108 -0
  51. data/lookbook/app/previews/layout/page_layout_preview/block_content.html.erb +13 -0
  52. data/lookbook/app/previews/layout/page_layout_preview/default.html.erb +19 -0
  53. data/lookbook/app/previews/layout/page_layout_preview/full_width.html.erb +12 -0
  54. data/lookbook/app/previews/layout/page_layout_preview/hidden_content.html.erb +18 -0
  55. data/lookbook/app/previews/layout/page_layout_preview/mixed.html.erb +15 -0
  56. data/lookbook/app/previews/layout/page_layout_preview/pagination.html.erb +12 -0
  57. data/lookbook/app/previews/layout/page_layout_preview/polling.html.erb +12 -0
  58. data/lookbook/app/previews/layout/page_layout_preview/sections.html.erb +13 -0
  59. data/lookbook/app/previews/layout/page_layout_preview/spacing.html.erb +33 -0
  60. data/lookbook/app/previews/layout/page_layout_preview.rb +38 -0
  61. data/lookbook/app/previews/layout/panel_preview/basic.html.erb +5 -0
  62. data/lookbook/app/previews/layout/panel_preview.rb +6 -0
  63. data/lookbook/app/previews/layout/spacer_preview/default.html.erb +5 -0
  64. data/lookbook/app/previews/layout/spacer_preview/responsive.html.erb +12 -0
  65. data/lookbook/app/previews/layout/spacer_preview/sizes.html.erb +7 -0
  66. data/lookbook/app/previews/layout/spacer_preview.rb +19 -0
  67. data/lookbook/app/previews/layout/stack_preview/default.html.erb +13 -0
  68. data/lookbook/app/previews/layout/stack_preview/item_properties.html.erb +13 -0
  69. data/lookbook/app/previews/layout/stack_preview/item_spacing.html.erb +23 -0
  70. data/lookbook/app/previews/layout/stack_preview/nested.html.erb +19 -0
  71. data/lookbook/app/previews/layout/stack_preview/stack_spacing.html.erb +13 -0
  72. data/lookbook/app/previews/layout/stack_preview.rb +21 -0
  73. data/lookbook/app/previews/messaging/notice_preview.rb +196 -0
  74. data/lookbook/app/previews/messaging/popover_preview/placement.html.erb +7 -0
  75. data/lookbook/app/previews/messaging/popover_preview/targets.html.erb +17 -0
  76. data/lookbook/app/previews/messaging/popover_preview/themes.html.erb +19 -0
  77. data/lookbook/app/previews/messaging/popover_preview/triggers.html.erb +19 -0
  78. data/lookbook/app/previews/messaging/popover_preview.rb +15 -0
  79. data/lookbook/app/previews/messaging/snackbar_preview/manual_show.html.erb +5 -0
  80. data/lookbook/app/previews/messaging/snackbar_preview/queue.html.erb +20 -0
  81. data/lookbook/app/previews/messaging/snackbar_preview/system_test_manual_show.html.erb +5 -0
  82. data/lookbook/app/previews/messaging/snackbar_preview.rb +128 -0
  83. data/lookbook/app/previews/messaging/system_banner_preview.rb +85 -0
  84. data/lookbook/app/previews/messaging/toast_preview.rb +132 -0
  85. data/lookbook/app/previews/messaging/tooltip_preview.rb +11 -0
  86. data/lookbook/app/previews/modals/modal_canvas_preview/basic.html.erb +6 -0
  87. data/lookbook/app/previews/modals/modal_canvas_preview.rb +7 -0
  88. data/lookbook/app/previews/modals/modal_dialog_preview/basic.html.erb +4 -0
  89. data/lookbook/app/previews/modals/modal_dialog_preview/in_page.html.erb +3 -0
  90. data/lookbook/app/previews/modals/modal_dialog_preview/large.html.erb +4 -0
  91. data/lookbook/app/previews/modals/modal_dialog_preview/medium.html.erb +4 -0
  92. data/lookbook/app/previews/modals/modal_dialog_preview/named.html.erb +5 -0
  93. data/lookbook/app/previews/modals/modal_dialog_preview/navigate.html.erb +3 -0
  94. data/lookbook/app/previews/modals/modal_dialog_preview/not_dismissable.html.erb +3 -0
  95. data/lookbook/app/previews/modals/modal_dialog_preview/not_shown.html.erb +5 -0
  96. data/lookbook/app/previews/modals/modal_dialog_preview/notice.html.erb +8 -0
  97. data/lookbook/app/previews/modals/modal_dialog_preview/small.html.erb +4 -0
  98. data/lookbook/app/previews/modals/modal_dialog_preview/triggers.html.erb +9 -0
  99. data/lookbook/app/previews/modals/modal_dialog_preview.rb +45 -0
  100. data/lookbook/app/previews/modals/modal_lightbox_preview/basic.html.erb +5 -0
  101. data/lookbook/app/previews/modals/modal_lightbox_preview/named.html.erb +6 -0
  102. data/lookbook/app/previews/modals/modal_lightbox_preview/scroll.html.erb +6 -0
  103. data/lookbook/app/previews/modals/modal_lightbox_preview/triggers.html.erb +8 -0
  104. data/lookbook/app/previews/modals/modal_lightbox_preview.rb +20 -0
  105. data/lookbook/app/previews/modals/modal_preview/basic.html.erb +6 -0
  106. data/lookbook/app/previews/modals/modal_preview.rb +8 -0
  107. data/lookbook/app/previews/navigation/link_preview.rb +74 -0
  108. data/lookbook/app/previews/navigation/link_to_preview.rb +88 -0
  109. data/lookbook/app/previews/navigation/pager_button_preview.rb +12 -0
  110. data/lookbook/app/previews/navigation/tabs_preview/basic.html.erb +5 -0
  111. data/lookbook/app/previews/navigation/tabs_preview/full.html.erb +5 -0
  112. data/lookbook/app/previews/navigation/tabs_preview/icons.html.erb +5 -0
  113. data/lookbook/app/previews/navigation/tabs_preview.rb +15 -0
  114. data/lookbook/app/previews/pickers/color_picker_preview.rb +27 -0
  115. data/lookbook/app/previews/pickers/image_picker_preview.rb +24 -0
  116. data/lookbook/app/previews/typography/utils_preview/branded_headings.html.erb +24 -0
  117. data/lookbook/app/previews/typography/utils_preview/fixed_size_headings.html.erb +7 -0
  118. data/lookbook/app/previews/typography/utils_preview/headings.html.erb +35 -0
  119. data/lookbook/app/previews/typography/utils_preview.rb +16 -0
  120. data/lookbook/app/previews/utilities/dropdown_preview.rb +19 -0
  121. data/lookbook/app/previews/utilities/seamless_textarea_preview/focus.html.erb +9 -0
  122. data/lookbook/app/previews/utilities/seamless_textarea_preview/multi_line.html.erb +9 -0
  123. data/lookbook/app/previews/utilities/seamless_textarea_preview/single_line.html.erb +8 -0
  124. data/lookbook/app/previews/utilities/seamless_textarea_preview.rb +29 -0
  125. data/lookbook/app/views/layouts/application.html.erb +24 -0
  126. data/lookbook/app/views/layouts/blank.html.erb +12 -0
  127. data/lookbook/app/views/lookbook/previews/group.html.erb +37 -0
  128. data/lookbook/app/views/pages/plans.html.erb +21 -0
  129. data/lookbook/app/views/panels/_design.html.erb +85 -0
  130. data/lookbook/app/views/request/success.html.erb +1 -0
  131. data/lookbook/app/views/turbo_request/done.html.erb +3 -0
  132. data/lookbook/app/views/turbo_request/success.html.erb +1 -0
  133. metadata +130 -1
@@ -0,0 +1,729 @@
1
+ module Buttons
2
+ # @figma https://www.figma.com/embed?embed_host=share&url=https%3A%2F%2Fwww.figma.com%2Ffile%2FxjMavn8xyhnqVvqNJB4hBk%2FCoco-(Design-System)%3Ftype%3Ddesign%26node-id%3D231%253A25388%26t%3DYyUtDf6PBtxXLRdL-1
3
+ class ButtonPreview < Coco::Preview
4
+ include Rails.application.routes.url_helpers
5
+
6
+ # @!group Types
7
+
8
+ def default
9
+ coco_button(icon: :zap) do
10
+ "A Coco Button"
11
+ end
12
+ end
13
+
14
+ def link
15
+ coco_button(href: coco_successful_request_path, icon: :volume_x) do
16
+ "this is a link button"
17
+ end
18
+ end
19
+
20
+ def positional_args
21
+ coco_button("another link button", coco_successful_request_path, icon: :link)
22
+ end
23
+
24
+ def positional_href
25
+ coco_button(coco_successful_request_path, icon: :link_2) do
26
+ "and another link button"
27
+ end
28
+ end
29
+
30
+ def submit
31
+ coco_button(type: :submit, icon: :badge_check) do
32
+ "this is a submit button"
33
+ end
34
+ end
35
+
36
+ def disabled
37
+ coco_button(disabled: true, icon: :twitter) do
38
+ "this is a disabled button"
39
+ end
40
+ end
41
+
42
+ def button_to
43
+ coco_button(action: coco_successful_request_path, method: :post) do
44
+ "this is a form button"
45
+ end
46
+ end
47
+
48
+ def loading
49
+ coco_button(icon: :star, click: "loading = !loading") do |button|
50
+ button.with_state(:loading, text: "Yay it's loading!")
51
+
52
+ "Click to start loading"
53
+ end
54
+ end
55
+
56
+ def active
57
+ coco_button(icon: :mouse_pointer_click, active: true) do |button|
58
+ # button.with_state(:active, text: "Yay it's active!")
59
+
60
+ "this is an active button"
61
+ end
62
+ end
63
+
64
+ def text_slot
65
+ coco_button(icon: :skull) do |button|
66
+ button.with_text { "this is a button" }
67
+ end
68
+ end
69
+
70
+ def with_dropdown
71
+ coco_button do |button|
72
+ button.with_dropdown do
73
+ button.tag.div(style: "padding: 12px;") do
74
+ "Dropdown contents"
75
+ end
76
+ end
77
+
78
+ "button with dropdown"
79
+ end
80
+ end
81
+
82
+ # @!group Form buttons
83
+
84
+ def with_action
85
+ coco_button(action: coco_successful_request_path) do
86
+ "Form button with action"
87
+ end
88
+ end
89
+
90
+ def with_method
91
+ coco_button(action: coco_successful_request_path, method: :get) do
92
+ "Form button with `put` method"
93
+ end
94
+ end
95
+
96
+ def with_params
97
+ coco_button(action: coco_successful_request_path, params: {id: 42}) do
98
+ "Form button with params"
99
+ end
100
+ end
101
+
102
+ def with_confirmation
103
+ coco_button(action: coco_successful_request_path) do |button|
104
+ button.with_confirmation do |confirm|
105
+ confirm.with_text { "Destroy the planet? Really?" }
106
+ confirm.with_button { "Fuck yeah" }
107
+ end
108
+
109
+ "Form button with confirmation"
110
+ end
111
+ end
112
+
113
+ # @!group Turbo
114
+
115
+ def link_turbo_enabled
116
+ coco_button(href: coco_successful_request_path, turbo: true) do
117
+ "Turbo form button"
118
+ end
119
+ end
120
+
121
+ def link_turbo_disabled
122
+ coco_button(href: coco_successful_request_path, turbo: false) do
123
+ "Form button turbo disabled"
124
+ end
125
+ end
126
+
127
+ def form_button_turbo_enabled
128
+ coco_button(action: coco_successful_request_path, turbo: true) do
129
+ "Turbo form button"
130
+ end
131
+ end
132
+
133
+ def form_button_turbo_disabled
134
+ coco_button(action: coco_successful_request_path, turbo: false) do
135
+ "Form button turbo disabled"
136
+ end
137
+ end
138
+
139
+ # @!group Sizes
140
+
141
+ def extra_small
142
+ coco_button(size: :xs, icon: :book_open) do
143
+ "extra small button"
144
+ end
145
+ end
146
+
147
+ def small
148
+ coco_button(size: :sm, icon: :book_open) do
149
+ "small button"
150
+ end
151
+ end
152
+
153
+ # @label Medium (default)
154
+ def medium
155
+ coco_button(size: :md, icon: :book_open) do
156
+ "medium button"
157
+ end
158
+ end
159
+
160
+ def large
161
+ coco_button(size: :lg, icon: :book_open) do
162
+ "large button"
163
+ end
164
+ end
165
+
166
+ def extra_small_icon
167
+ coco_button(size: :xs, icon: :heart)
168
+ end
169
+
170
+ def small_icon
171
+ coco_button(size: :sm, icon: :heart)
172
+ end
173
+
174
+ def medium_icon
175
+ coco_button(size: :md, icon: :heart)
176
+ end
177
+
178
+ def large_icon
179
+ coco_button(size: :lg, icon: :heart)
180
+ end
181
+
182
+ def extra_small_text_icon
183
+ coco_button(size: :xs, icon: :heart, theme: :text_primary)
184
+ end
185
+
186
+ def small_text_icon
187
+ coco_button(size: :sm, icon: :heart, theme: :text_primary)
188
+ end
189
+
190
+ def medium_text_icon
191
+ coco_button(size: :md, icon: :heart, theme: :text_primary)
192
+ end
193
+
194
+ def large_text_icon
195
+ coco_button(size: :lg, icon: :heart, theme: :text_primary)
196
+ end
197
+
198
+ # @!group Fit
199
+
200
+ # @label Auto (default)
201
+ def auto
202
+ coco_button(fit: :auto) do
203
+ "this is a regular button"
204
+ end
205
+ end
206
+
207
+ def full
208
+ coco_button(fit: :full) do
209
+ "this is a full width button"
210
+ end
211
+ end
212
+
213
+ # @!group Themes
214
+
215
+ def primary
216
+ coco_button(theme: :primary) do
217
+ "Primary"
218
+ end
219
+ end
220
+
221
+ def text_primary
222
+ coco_button(theme: :text_primary) do
223
+ "Text Primary"
224
+ end
225
+ end
226
+
227
+ def secondary
228
+ coco_button(theme: :secondary) do
229
+ "Secondary"
230
+ end
231
+ end
232
+
233
+ def text_secondary
234
+ coco_button(theme: :text_secondary) do
235
+ "Text Secondary"
236
+ end
237
+ end
238
+
239
+ def positive
240
+ coco_button(theme: :positive) do
241
+ "Positive"
242
+ end
243
+ end
244
+
245
+ def text_positive
246
+ coco_button(theme: :text_positive) do
247
+ "Text Positive"
248
+ end
249
+ end
250
+
251
+ def negative
252
+ coco_button(theme: :negative) do
253
+ "Negative"
254
+ end
255
+ end
256
+
257
+ def text_negative
258
+ coco_button(theme: :text_negative) do
259
+ "Text Negative"
260
+ end
261
+ end
262
+
263
+ def warning
264
+ coco_button(theme: :warning) do
265
+ "Warning"
266
+ end
267
+ end
268
+
269
+ def text_warning
270
+ coco_button(theme: :text_warning) do
271
+ "Text Warning"
272
+ end
273
+ end
274
+
275
+ def info
276
+ coco_button(theme: :info) do
277
+ "Info"
278
+ end
279
+ end
280
+
281
+ def text_info
282
+ coco_button(theme: :text_info) do
283
+ "Text Info"
284
+ end
285
+ end
286
+
287
+ def toolbar
288
+ coco_button(theme: :toolbar) do
289
+ "Toolbar"
290
+ end
291
+ end
292
+
293
+ def text_toolbar
294
+ coco_button(theme: :text_toolbar) do
295
+ "Text Toolbar"
296
+ end
297
+ end
298
+
299
+ def neutral_dark
300
+ coco_button(theme: :neutral_dark) do
301
+ "Neutral dark"
302
+ end
303
+ end
304
+
305
+ def neutral_light
306
+ coco_button(theme: :neutral_light) do
307
+ "Neutral light"
308
+ end
309
+ end
310
+
311
+ def text_neutral_dark
312
+ coco_button(theme: :text_neutral_dark) do
313
+ "Text neutral dark"
314
+ end
315
+ end
316
+
317
+ def text_neutral_light
318
+ coco_button(theme: :text_neutral_light) do
319
+ "Text neutral light"
320
+ end
321
+ end
322
+
323
+ def blank
324
+ coco_button(theme: :blank) do
325
+ "Blank - no theme but sizing and spacing applied"
326
+ end
327
+ end
328
+
329
+ # @label None
330
+ def none
331
+ coco_button(theme: nil) do
332
+ "Unstyled button"
333
+ end
334
+ end
335
+
336
+ # @hidden
337
+ def toolbar_floating
338
+ coco_button(theme: :toolbar_floating) do
339
+ "Toolbar floating"
340
+ end
341
+ end
342
+
343
+ # @!group Responsive
344
+
345
+ def responsive_default
346
+ coco_button do
347
+ "Small button, medium at xl (default)"
348
+ end
349
+ end
350
+
351
+ def responsive_sm_md
352
+ coco_button(size: :sm, resize: {md: :md}) do
353
+ "Small button, medium at md"
354
+ end
355
+ end
356
+
357
+ def responsive_sm_md_xl
358
+ coco_button(size: :sm, resize: {md: :md, xl: :lg}) do
359
+ "Small button, medium at md, large at xl"
360
+ end
361
+ end
362
+
363
+ def responsive_sm_lg
364
+ coco_button(size: :sm, resize: {lg: :md}) do
365
+ "Small button, medium at lg"
366
+ end
367
+ end
368
+
369
+ def responsive_sm_xl
370
+ coco_button(size: :sm, resize: {xl: :md}) do
371
+ "Small button, medium at xl"
372
+ end
373
+ end
374
+
375
+ def responsive_sm_xxl
376
+ coco_button(size: :sm, resize: {xxl: :md}) do
377
+ "Small button, large at xxl"
378
+ end
379
+ end
380
+
381
+ def responsive_md_lg
382
+ coco_button(size: :md, resize: {lg: :lg}) do
383
+ "Medium button, large at lg"
384
+ end
385
+ end
386
+
387
+ def responsive_md_xl
388
+ coco_button(size: :md, resize: {xl: :lg}) do
389
+ "Medium button, large at xl"
390
+ end
391
+ end
392
+
393
+ def responsive_md_xxl
394
+ coco_button(size: :md, resize: {xxl: :lg}) do
395
+ "Medium button, large at xxl"
396
+ end
397
+ end
398
+
399
+ # @!group Icons
400
+
401
+ # @label Icon before text
402
+ def icon_start
403
+ coco_button do |b|
404
+ b.with_icon :arrow_right_circle
405
+ "icon button"
406
+ end
407
+ end
408
+
409
+ # @label Icon after text
410
+ def icon_end
411
+ coco_button do |b|
412
+ b.with_icon :arrow_right_circle, position: :end
413
+ "icon button"
414
+ end
415
+ end
416
+
417
+ def icon_shorthand
418
+ coco_button(icon: :star) do
419
+ "icon button"
420
+ end
421
+ end
422
+
423
+ # @label Unstyled with icon
424
+ def icon_unstyled
425
+ coco_button(icon: :star, theme: nil) do
426
+ "icon button"
427
+ end
428
+ end
429
+
430
+ def icon_only
431
+ coco_button(icon: :trash)
432
+ end
433
+
434
+ def icon_only_unstyled
435
+ coco_button(icon: :trash, theme: nil)
436
+ end
437
+
438
+ def custom_icon
439
+ coco_button do |button|
440
+ button.with_icon do
441
+ '<svg role="img" fill="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
442
+ <title>Basecamp</title>
443
+ <path d="M12.6516 22.453c-4.0328 0-7.575-1.5542-10.244-4.4946a1.11 1.11 0 0 1-.219-1.1338c.7008-1.8884 2.5935-6.2808 5.0205-6.2948h.0125c1.219 0 2.1312.9655 2.8648 1.7412.2192.2324.555.5875.7818.7611.5656-.5587 1.6775-2.4158 2.5422-4.2779.259-.5567.9203-.7985 1.4765-.5402.557.2584.7988.919.5404 1.4762-2.6217 5.6503-4.019 5.6503-4.478 5.6503-1.022 0-1.7628-.7843-2.4791-1.5422-.3208-.339-.9878-1.045-1.2482-1.045h-.0004c-.5665.095-1.8085 2.0531-2.6966 4.2034 2.1925 2.1722 4.9232 3.2726 8.1266 3.2726 4.3955 0 7.683-1.1964 9.0996-3.2953-.4888-5.585-3.5642-13.1634-9.0996-13.1634-4.6855 0-8.2152 3.264-10.4915 9.7007-.205.579-.8416.8828-1.4187.6776-.5789-.2047-.882-.8398-.6776-1.4185 2.624-7.421 6.859-11.1833 12.5878-11.1833 7.4826 0 10.9304 9.5613 11.3458 15.588a1.1154 1.1154 0 0 1-.1456.6314c-1.7407 3.0221-5.7182 4.6864-11.2002 4.6864Z"/>
444
+ </svg>'.html_safe
445
+ end
446
+ end
447
+ end
448
+
449
+ # @!group Tooltips
450
+
451
+ def basic_tooltip
452
+ coco_button(tooltip: "this is a tooltip", id: "basic-tooltip-button") do
453
+ "button with tooltip"
454
+ end
455
+ end
456
+
457
+ def tooltip_with_placement
458
+ coco_button(id: "placed-tooltip-button") do |button|
459
+ button.with_tooltip "this is a tooltip", placement: "right"
460
+
461
+ "button with tooltip on the right"
462
+ end
463
+ end
464
+
465
+ def state_specific_tooltip
466
+ coco_button(tooltip: "The initial tooltip content", click: "toggleState('active')", id: "state-specific-tooltip-button") do |button|
467
+ button.with_state(:active, tooltip: "Button is active", text: "Active!")
468
+
469
+ "click to change tooltip text"
470
+ end
471
+ end
472
+
473
+ # @!group Confirmation
474
+
475
+ # @label Default
476
+ def confirm_default
477
+ coco_button(href: "http://example.com", theme: :secondary, confirm: true) do
478
+ "Feed the trolls"
479
+ end
480
+ end
481
+
482
+ # @label Basic
483
+ def confirm_basic
484
+ coco_button(href: "http://example.com", theme: :secondary) do |button|
485
+ button.with_confirmation do |confirm|
486
+ confirm.with_text { "Destroy the planet? Really?" }
487
+ confirm.with_button { "Fuck yeah" }
488
+ end
489
+
490
+ "Nuke from orbit"
491
+ end
492
+ end
493
+
494
+ # @label Custom dropdown placement
495
+ def confirm_placement
496
+ coco_button(href: "http://example.com", theme: :secondary, dropdown: {placement: "right"}) do |button|
497
+ button.with_confirmation do |confirm|
498
+ confirm.with_text { "Are you sure you want to do that?" }
499
+ confirm.with_button { "Yes, continue" }
500
+ end
501
+
502
+ "Release the hounds"
503
+ end
504
+ end
505
+
506
+ # @label Confirm with cancel
507
+ def confirm_full
508
+ coco_button(href: "http://example.com", theme: :secondary) do |button|
509
+ button.with_confirmation do |confirm|
510
+ confirm.with_text { "Not a good idea." }
511
+ confirm.with_button { "Do it anyway" }
512
+ confirm.with_cancel { "Abort" }
513
+ end
514
+
515
+ "Feed the trolls"
516
+ end
517
+ end
518
+
519
+ # @!group Menus
520
+
521
+ def with_menu
522
+ coco_menu_button do |button|
523
+ button.with_menu do |menu|
524
+ menu.with_button(icon: :globe) { "Menu item one and this one has a long title" }
525
+ menu.with_button(icon: :carrot) { "Menu item 2" }
526
+ menu.with_button(icon: :bell) { "A third menu item" }
527
+ menu.with_divider
528
+ menu.with_html do
529
+ tag.div("Just content, not a button",
530
+ style: "padding: 0.5rem 0.75rem; font-style: italic; font-size: 0.8rem; opacity: 0.6; text-align: center;")
531
+ end
532
+ end
533
+
534
+ "Click for options"
535
+ end
536
+ end
537
+
538
+ def icon_button_menu
539
+ coco_menu_button(icon: :cog) do |button|
540
+ button.with_menu do |menu|
541
+ menu.with_button(icon: :globe) { "Menu item one" }
542
+ menu.with_button(icon: :carrot) { "Menu item 2" }
543
+ end
544
+ end
545
+ end
546
+
547
+ def with_nested_menu
548
+ coco_menu_button do |button|
549
+ button.with_menu do |menu|
550
+ menu.with_button(icon: :globe) { "Menu item one" }
551
+ menu.with_menu_button(icon: :bell) do |subbutton|
552
+ subbutton.with_menu do |submenu|
553
+ submenu.with_button(icon: :smile) { "Sub menu item one" }
554
+ submenu.with_button(icon: :frown) { "Sub menu item two" }
555
+ end
556
+
557
+ "Nested menu"
558
+ end
559
+ end
560
+
561
+ "Menu"
562
+ end
563
+ end
564
+
565
+ # @!group States
566
+
567
+ def loading_state
568
+ coco_button(icon: :play, click: "toggleState('loading')") do |button|
569
+ button.with_state(:loading)
570
+
571
+ "Click to toggle the default loading state"
572
+ end
573
+ end
574
+
575
+ def custom_loading_state
576
+ coco_button(icon: :undo, click: "toggleState('loading')") do |button|
577
+ button.with_state(:loading, text: "Here we go!", icon: :clock)
578
+
579
+ "Click to toggle a custom loading state"
580
+ end
581
+ end
582
+
583
+ def active_state
584
+ coco_button(icon: :mouse_pointer_2, click: "toggleState('active')") do |button|
585
+ button.with_state(:active, text: "Button is active", icon: :check)
586
+
587
+ "Click to toggle the active state"
588
+ end
589
+ end
590
+
591
+ def state_tooltips
592
+ coco_button(icon: :bell, click: "toggleState('active')", tooltip: "default state") do |button|
593
+ button.with_state(:active, text: "Button is active", icon: :check, tooltip: "active state")
594
+
595
+ "Click to toggle the active state"
596
+ end
597
+ end
598
+
599
+ # @!endgroup
600
+
601
+ # Button playground
602
+ # ---------------
603
+ #
604
+ # Use the param controls to experiment with the available options.
605
+ #
606
+ # @display centered true
607
+ #
608
+ # @param text
609
+ # @param size [Symbol] select [[responsive, default], sm, md, lg]
610
+ # @param theme [Symbol] select {{ Coco::Button::THEMES }}
611
+ # @param disabled
612
+ # @param loading
613
+ # @param loading_text text
614
+ # @param icon [Symbol] select :icon_names
615
+ # @param icon_position [Symbol] select [start, end]
616
+ def playground(text: "You can play with me!", size: :md, theme: :primary, disabled: false, loading: false, loading_text: "It's loading!", icon: "", icon_position: :start)
617
+ coco_button(
618
+ size: size.to_sym,
619
+ theme: theme.to_sym,
620
+ disabled: disabled,
621
+ loading: loading
622
+ ) do |button|
623
+ button.icon(icon.to_sym, position: icon_position) if icon.present?
624
+
625
+ button.with_state(:loading, text: loading_text)
626
+
627
+ text
628
+ end
629
+ end
630
+
631
+ # system test previews
632
+
633
+ # @hidden
634
+ def system_test_link
635
+ coco_button(href: coco_successful_request_path, icon: :volume_x) do
636
+ "this is a link button"
637
+ end
638
+ end
639
+
640
+ # @hidden
641
+ def system_test_form_button_with_action
642
+ coco_button(action: coco_successful_request_path) do
643
+ "Form button with action"
644
+ end
645
+ end
646
+
647
+ # @hidden
648
+ def system_test_form_button_with_method
649
+ coco_button(action: coco_successful_request_path, method: :get) do
650
+ "Form button with `put` method"
651
+ end
652
+ end
653
+
654
+ # @hidden
655
+ def system_test_form_button_with_params
656
+ coco_button(action: coco_successful_request_path, params: {id: 42}) do
657
+ "Form button with params"
658
+ end
659
+ end
660
+
661
+ # @hidden
662
+ def system_test_form_button_with_confirmation
663
+ coco_button(action: coco_successful_request_path) do |button|
664
+ button.with_confirmation do |confirm|
665
+ confirm.with_text { "Destroy the planet? Really?" }
666
+ confirm.with_button { "Fuck yeah" }
667
+ end
668
+
669
+ "Form button with confirmation"
670
+ end
671
+ end
672
+
673
+ # @hidden
674
+ def disabled_link
675
+ coco_button(href: "https://example.com", disabled: true, icon: :twitter) do
676
+ "this is a disabled link button"
677
+ end
678
+ end
679
+
680
+ # @hidden
681
+ def button_attributes
682
+ coco_button(type: "test_type", value: "test_value", name: "test_name", target: "test_target") do
683
+ "button with button attributes set"
684
+ end
685
+ end
686
+
687
+ # @hidden
688
+ def data_attributes
689
+ coco_button(data: {attr_1: "one", attr_2: "two"}) do
690
+ "button with data attributes set"
691
+ end
692
+ end
693
+
694
+ # @hidden
695
+ def modal_trigger
696
+ coco_button(modal: true) do
697
+ "modal trigger button"
698
+ end
699
+ end
700
+
701
+ # @hidden
702
+ def loading_state_system_test
703
+ coco_button(icon: :play, click: "toggleState('loading')") do |button|
704
+ button.with_state(:loading)
705
+
706
+ "Not loading"
707
+ end
708
+ end
709
+
710
+ # @hidden
711
+ def active_state_system_test
712
+ coco_button(icon: :mouse_pointer_2, click: "toggleState('active')") do |button|
713
+ button.with_state(:active, text: "Active!", icon: :check)
714
+
715
+ "Not active"
716
+ end
717
+ end
718
+
719
+ private
720
+
721
+ def icon_names
722
+ [["No icon", ""], *super]
723
+ end
724
+
725
+ def coco_successful_request_path
726
+ defined?(successful_request_path) ? successful_request_path : "#"
727
+ end
728
+ end
729
+ end