coveragebook_components 0.10.1.beta.2 → 0.11.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (40) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/build/coco/app.css +3968 -3053
  3. data/app/assets/build/coco/app.js +5 -4
  4. data/app/assets/build/coco/book.css +1609 -627
  5. data/app/assets/build/coco/book.js +2 -2
  6. data/app/assets/css/app/tippy.css +1 -1
  7. data/app/assets/css/base.css +0 -4
  8. data/app/assets/css/shared/tippy.css +2 -2
  9. data/app/assets/css/shared/utils/text.css +323 -66
  10. data/app/components/coco/app/blocks/sidebar_nav/item/item.css +3 -3
  11. data/app/components/coco/app/blocks/sidebar_nav/menu/menu.css +3 -3
  12. data/app/components/coco/app/elements/alert/alert.css +7 -7
  13. data/app/components/coco/app/elements/color_picker/color_picker.css +2 -2
  14. data/app/components/coco/app/elements/confirm_panel/confirm_panel.css +1 -1
  15. data/app/components/coco/app/elements/image_picker/image_picker.css +4 -4
  16. data/app/components/coco/app/elements/menu/menu.css +2 -2
  17. data/app/components/coco/app/elements/menu_items/user_profile/user_profile.css +1 -1
  18. data/app/components/coco/app/elements/snackbar/snackbar.css +1 -1
  19. data/app/components/coco/app/layouts/page/page.css +1 -5
  20. data/app/components/coco/app/layouts/page/page.html.erb +3 -9
  21. data/app/components/coco/app/layouts/page/page.rb +18 -3
  22. data/app/components/coco/shared/button/button.css +31 -31
  23. data/app/components/coco/shared/button/button.rb +2 -2
  24. data/app/components/coco/shared/link/link.css +67 -0
  25. data/app/components/coco/shared/link/link.rb +20 -1
  26. data/app/components/coco/shared/prose/prose.css +28 -0
  27. data/app/components/coco/shared/prose/prose.rb +14 -0
  28. data/app/components/coco/shared/spacer/spacer.css +201 -0
  29. data/app/components/coco/shared/spacer/spacer.rb +23 -0
  30. data/app/components/coco/shared/stack/stack.css +4 -0
  31. data/app/components/coco/shared/stack/stack.html.erb +4 -0
  32. data/app/components/coco/shared/stack/stack.rb +47 -0
  33. data/app/helpers/coco/app_helper.rb +1 -1
  34. data/app/helpers/coco/shared_helper.rb +13 -0
  35. data/config/tailwind.base.config.cjs +3 -1
  36. data/config/tokens.cjs +1 -0
  37. data/lib/coco.rb +1 -1
  38. metadata +12 -7
  39. data/app/components/coco/app/elements/link/link.css +0 -70
  40. data/app/components/coco/app/elements/link/link.rb +0 -33
@@ -16,7 +16,7 @@
16
16
  }
17
17
 
18
18
  .user-profile-email {
19
- @apply text-gray-500 coco-label-sm italic truncate;
19
+ @apply text-gray-500 label-sm italic truncate;
20
20
  }
21
21
  }
22
22
  }
@@ -22,7 +22,7 @@
22
22
  }
23
23
 
24
24
  .snackbar-content {
25
- @apply coco-label-md text-content-light-1 font-semibold flex-grow mr-2 my-2;
25
+ @apply label-md text-content-light-1 font-semibold flex-grow mr-2 my-2;
26
26
  }
27
27
 
28
28
  .coco-button {
@@ -1,11 +1,7 @@
1
1
  @layer components {
2
2
  [data-coco][data-component="page-layout"] {
3
3
  .page-body {
4
- @apply pt-12 pb-12 px-app w-full;
5
- }
6
-
7
- .page-sections {
8
- @apply space-y-12;
4
+ @apply px-app w-full;
9
5
  }
10
6
 
11
7
  .page-controls {
@@ -4,17 +4,11 @@
4
4
  <%= header %>
5
5
  </header>
6
6
  <% end %>
7
+
7
8
  <div class="page-body" data-role="page-body">
8
- <div class="page-body-content">
9
- <% if sections? %>
10
- <div class="page-sections">
11
- <%= safe_join(sections) %>
12
- </div>
13
- <% end %>
14
- <%= content %>
15
- </div>
9
+ <%= render stack %>
16
10
  </div>
17
-
11
+
18
12
  <% if previous_link? || next_link? %>
19
13
  <div class="page-controls">
20
14
  <%= previous_link %>
@@ -11,8 +11,9 @@ module Coco
11
11
  renders_one :header
12
12
  renders_many :hidden_sections
13
13
 
14
- renders_many :sections, ->(**kwargs, &block) do
15
- coco_tag(:section, **kwargs, &block)
14
+ renders_many :sections, ->(tag_name = :section, **kwargs, &block) do
15
+ stack.with_space(@spacing) unless stack.starts_with_spacer?
16
+ stack.with_item(tag_name, **kwargs) { block&.call }
16
17
  end
17
18
 
18
19
  renders_one :previous_link, ->(**kwargs) do
@@ -31,12 +32,26 @@ module Coco
31
32
  with_poll_controller(@poll) unless poll_controller? || @poll.nil?
32
33
  with_next_link(href: @next_page) if @next_page
33
34
  with_previous_link(href: @previous_page) if @previous_page
35
+
36
+ with_section(class: "contents") { content } if content.present?
37
+ stack.with_space(@spacing) unless stack.ends_with_spacer?
34
38
  end
35
39
 
36
- def initialize(poll: nil, **kwargs)
40
+ delegate :with_space, to: :stack
41
+
42
+ def initialize(spacing: 4, poll: nil, **kwargs)
37
43
  @poll = poll
38
44
  @previous_page = kwargs[:previous]
39
45
  @next_page = kwargs[:next]
46
+ @spacing = spacing
47
+ end
48
+
49
+ def stack
50
+ @stack ||= Coco::Stack.new(
51
+ spacing: @spacing,
52
+ direction: :vertical,
53
+ class: "page-body-content"
54
+ )
40
55
  end
41
56
  end
42
57
  end
@@ -359,119 +359,119 @@
359
359
  /* Responsive resizing */
360
360
 
361
361
  &[data-size="xs"] {
362
- @apply coco-button-xs;
362
+ @apply button-xs;
363
363
  }
364
364
 
365
365
  &[data-size="sm"] {
366
- @apply coco-button-sm;
366
+ @apply button-sm;
367
367
  }
368
368
 
369
369
  &[data-size="md"] {
370
- @apply coco-button-md;
370
+ @apply button-md;
371
371
  }
372
372
 
373
373
  &[data-size="lg"] {
374
- @apply coco-button-lg;
374
+ @apply button-lg;
375
375
  }
376
376
 
377
377
  @media screen(md) {
378
378
  &[data-size-md="xs"] {
379
- @apply coco-button-xs;
379
+ @apply button-xs;
380
380
  }
381
381
 
382
382
  &[data-size-md="sm"] {
383
- @apply coco-button-sm;
383
+ @apply button-sm;
384
384
  }
385
385
 
386
386
  &[data-size-md="md"] {
387
- @apply coco-button-md;
387
+ @apply button-md;
388
388
  }
389
389
 
390
390
  &[data-size-md="lg"] {
391
- @apply coco-button-lg;
391
+ @apply button-lg;
392
392
  }
393
393
  }
394
394
 
395
395
  @media screen(lg) {
396
396
  &[data-size-lg="xs"] {
397
- @apply coco-button-xs;
397
+ @apply button-xs;
398
398
  }
399
399
 
400
400
  &[data-size-lg="sm"] {
401
- @apply coco-button-sm;
401
+ @apply button-sm;
402
402
  }
403
403
 
404
404
  &[data-size-lg="md"] {
405
- @apply coco-button-md;
405
+ @apply button-md;
406
406
  }
407
407
 
408
408
  &[data-size-lg="lg"] {
409
- @apply coco-button-lg;
409
+ @apply button-lg;
410
410
  }
411
411
  }
412
412
 
413
413
  @media screen(xl) {
414
414
  &[data-size-xl="xs"] {
415
- @apply coco-button-xs;
415
+ @apply button-xs;
416
416
  }
417
417
 
418
418
  &[data-size-xl="sm"] {
419
- @apply coco-button-sm;
419
+ @apply button-sm;
420
420
  }
421
421
 
422
422
  &[data-size-xl="md"] {
423
- @apply coco-button-md;
423
+ @apply button-md;
424
424
  }
425
425
 
426
426
  &[data-size-xl="lg"] {
427
- @apply coco-button-lg;
427
+ @apply button-lg;
428
428
  }
429
429
  }
430
430
 
431
431
  @media screen(2xl) {
432
432
  &[data-size-xxl="xs"],
433
433
  &[data-size-2xl="xs"] {
434
- @apply coco-button-xs;
434
+ @apply button-xs;
435
435
  }
436
436
 
437
437
  &[data-size-xxl="sm"],
438
438
  &[data-size-2xl="sm"] {
439
- @apply coco-button-sm;
439
+ @apply button-sm;
440
440
  }
441
441
 
442
442
  &[data-size-xxl="md"],
443
443
  &[data-size-2xl="md"] {
444
- @apply coco-button-md;
444
+ @apply button-md;
445
445
  }
446
446
 
447
447
  &[data-size-xxl="lg"],
448
448
  &[data-size-2xl="lg"] {
449
- @apply coco-button-lg;
449
+ @apply button-lg;
450
450
  }
451
451
  }
452
452
 
453
453
  @media screen(max) {
454
454
  &[data-size-max="xs"] {
455
- @apply coco-button-xs;
455
+ @apply button-xs;
456
456
  }
457
457
 
458
458
  &[data-size-max="sm"] {
459
- @apply coco-button-sm;
459
+ @apply button-sm;
460
460
  }
461
461
 
462
462
  &[data-size-max="md"] {
463
- @apply coco-button-md;
463
+ @apply button-md;
464
464
  }
465
465
 
466
466
  &[data-size-max="lg"] {
467
- @apply coco-button-lg;
467
+ @apply button-lg;
468
468
  }
469
469
  }
470
470
  }
471
471
  }
472
472
 
473
473
  @layer utilities {
474
- .coco-button-xs {
474
+ .button-xs {
475
475
  .button-content {
476
476
  font-size: 14px;
477
477
  line-height: 14px;
@@ -501,9 +501,9 @@
501
501
  }
502
502
  }
503
503
 
504
- .coco-button-sm {
504
+ .button-sm {
505
505
  .button-content {
506
- @apply coco-label-sm;
506
+ @apply label-sm;
507
507
  }
508
508
 
509
509
  .button-icon [data-component="icon"],
@@ -530,9 +530,9 @@
530
530
  }
531
531
  }
532
532
 
533
- .coco-button-md {
533
+ .button-md {
534
534
  .button-content {
535
- @apply coco-label-md;
535
+ @apply label-md;
536
536
  }
537
537
 
538
538
  .button-icon [data-component="icon"],
@@ -559,9 +559,9 @@
559
559
  }
560
560
  }
561
561
 
562
- .coco-button-lg {
562
+ .button-lg {
563
563
  .button-content {
564
- @apply coco-label-lg;
564
+ @apply label-lg;
565
565
  }
566
566
 
567
567
  .button-icon [data-component="icon"],
@@ -107,8 +107,8 @@ module Coco
107
107
  end
108
108
 
109
109
  def static?
110
- if @static.nil?
111
- !(confirm? || dropdown? || tooltip? || @states.any? || on_click.present? || get_option_value(:collapsible))
110
+ @_static ||= if @static.nil?
111
+ !(confirm? || dropdown? || tooltip? || @states.any? || on_click.present? || get_option_value(:collapsible) || tag_attrs.key?(:x))
112
112
  else
113
113
  @static
114
114
  end
@@ -21,5 +21,72 @@
21
21
  }
22
22
  }
23
23
  }
24
+
25
+ &[data-theme] {
26
+ @apply no-underline hover:underline;
27
+ }
28
+
29
+ &[data-underline="true"] {
30
+ @apply underline;
31
+ }
32
+
33
+ &[data-underline="false"] {
34
+ @apply no-underline;
35
+ }
36
+
37
+ &[data-theme="primary"] {
38
+ @apply link-primary;
39
+ }
40
+
41
+ &[data-theme="positive"] {
42
+ @apply link-positive;
43
+ }
44
+
45
+ &[data-theme="negative"] {
46
+ @apply link-negative;
47
+ }
48
+
49
+ &[data-theme="warning"] {
50
+ @apply link-warning;
51
+ }
52
+
53
+ &[data-theme="info"] {
54
+ @apply link-info;
55
+ }
56
+
57
+ &[data-theme="neutral-dark"] {
58
+ @apply link-neutral-dark;
59
+ }
60
+
61
+ &[data-theme="neutral-light"] {
62
+ @apply link-neutral-light;
63
+ }
64
+ }
65
+ }
66
+
67
+ @layer utilities {
68
+ .link-primary,
69
+ .link-positive {
70
+ @apply text-content-primary active:text-green-700;
71
+ }
72
+
73
+ .link-negative {
74
+ @apply text-content-negative active:text-red-800;
75
+ }
76
+
77
+ .link-warning {
78
+ @apply text-content-warning active:text-amber-800;
79
+ }
80
+
81
+ .link-info {
82
+ @apply text-content-info active:text-info-800;
83
+ }
84
+
85
+ .link-neutral-dark {
86
+ @apply text-content-dark-1;
87
+ }
88
+
89
+ .link-neutral-light {
90
+ @apply text-content-light-1;
24
91
  }
25
92
  }
@@ -1,8 +1,23 @@
1
1
  module Coco
2
2
  class Link < Coco::Component
3
- include Concerns::Extendable
4
3
  include Concerns::ActsAsLink
5
4
  include Concerns::WithIcon
5
+ include Concerns::AcceptsOptions
6
+ include Concerns::AcceptsTheme
7
+
8
+ THEMES = %W[positive primary warning negative info neutral-dark neutral-light] << nil
9
+
10
+ accepts_option :theme, from: THEMES
11
+ accepts_option :underline, from: [true, false]
12
+
13
+ before_initialize do |kwargs|
14
+ if kwargs.key?(:modal)
15
+ modal_name = (kwargs[:modal] == true) ? "default" : kwargs[:modal]
16
+ kwargs[:data] = kwargs.fetch(:data, {}).merge(coco_modal_data_attributes(modal_name))
17
+ kwargs.delete(:modal)
18
+ end
19
+ kwargs
20
+ end
6
21
 
7
22
  def call
8
23
  render component_tag(class: ["coco-link", ("with-icon" if icon?)]) do
@@ -12,5 +27,9 @@ module Coco
12
27
  ])
13
28
  end
14
29
  end
30
+
31
+ class << self
32
+ include Coco::SharedHelper
33
+ end
15
34
  end
16
35
  end
@@ -0,0 +1,28 @@
1
+ @layer components {
2
+ [data-coco].coco-prose {
3
+ @apply para-md;
4
+
5
+ :last-child {
6
+ @apply !mb-0;
7
+ }
8
+
9
+ a[href]:not([data-theme]) {
10
+ @apply text-content-primary;
11
+ }
12
+
13
+ &[data-centered="true"] {
14
+ @apply text-center;
15
+ }
16
+
17
+ &[data-style="display"] > {
18
+ h1,
19
+ h2,
20
+ h3,
21
+ h4,
22
+ h5,
23
+ h6 {
24
+ margin-bottom: 0.34em;
25
+ }
26
+ }
27
+ }
28
+ }
@@ -0,0 +1,14 @@
1
+ module Coco
2
+ class Prose < Coco::Component
3
+ include Concerns::AcceptsOptions
4
+
5
+ accepts_option :centered, from: [true, false]
6
+ accepts_option :style, from: [:display, :content]
7
+
8
+ def call
9
+ render component_tag(class: "coco-prose") do
10
+ content
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,201 @@
1
+ @layer components {
2
+ [data-coco][data-component="spacer"] {
3
+ @apply pointer-events-none select-none invisible !p-0 !m-0 !border-none !flex-none;
4
+
5
+ &[data-size="0"] {
6
+ @apply hidden;
7
+ }
8
+
9
+ @apply !w-0;
10
+
11
+ &:not([data-scale-from]) {
12
+ @apply spacer-vertical-xs;
13
+ }
14
+
15
+ &[data-scale-from="sm"] {
16
+ @apply spacer-vertical-sm;
17
+ }
18
+
19
+ &[data-scale-from="md"] {
20
+ @apply spacer-vertical-md;
21
+ }
22
+
23
+ &[data-scale-from="lg"] {
24
+ @apply spacer-vertical-lg;
25
+ }
26
+
27
+ @media screen(sm) {
28
+ &:not([data-scale-from]),
29
+ &[data-scale-from="sm"] {
30
+ @apply spacer-vertical-sm;
31
+ }
32
+
33
+ &[data-scale-from="md"] {
34
+ @apply spacer-vertical-md;
35
+ }
36
+
37
+ &[data-scale-from="lg"] {
38
+ @apply spacer-vertical-lg;
39
+ }
40
+ }
41
+
42
+ @media screen(md) {
43
+ &:not([data-scale-from]),
44
+ &[data-scale-from="sm"],
45
+ &[data-scale-from="md"] {
46
+ @apply spacer-vertical-md;
47
+ }
48
+
49
+ &[data-scale-from="lg"] {
50
+ @apply spacer-vertical-lg;
51
+ }
52
+ }
53
+
54
+ @media screen(lg) {
55
+ &:not([data-scale-from]),
56
+ &[data-scale-from="sm"],
57
+ &[data-scale-from="md"],
58
+ &[data-scale-from="lg"] {
59
+ @apply spacer-vertical-lg;
60
+ }
61
+ }
62
+ }
63
+ }
64
+
65
+ @layer utilities {
66
+ .spacer-vertical-xs {
67
+ &[data-size="1"] {
68
+ @apply h-1.5;
69
+ }
70
+
71
+ &[data-size="2"] {
72
+ @apply h-3;
73
+ }
74
+
75
+ &[data-size="3"] {
76
+ @apply h-5;
77
+ }
78
+
79
+ &[data-size="4"] {
80
+ @apply h-7;
81
+ }
82
+
83
+ &[data-size="5"] {
84
+ @apply h-9;
85
+ }
86
+
87
+ &[data-size="6"] {
88
+ @apply h-11;
89
+ }
90
+
91
+ &[data-size="7"] {
92
+ @apply h-13;
93
+ }
94
+
95
+ &[data-size="8"] {
96
+ @apply h-15;
97
+ }
98
+ }
99
+
100
+ .spacer-vertical-sm {
101
+ &[data-size="1"] {
102
+ @apply h-2;
103
+ }
104
+
105
+ &[data-size="2"] {
106
+ @apply h-4;
107
+ }
108
+
109
+ &[data-size="3"] {
110
+ @apply h-6;
111
+ }
112
+
113
+ &[data-size="4"] {
114
+ @apply h-8;
115
+ }
116
+
117
+ &[data-size="5"] {
118
+ @apply h-10;
119
+ }
120
+
121
+ &[data-size="6"] {
122
+ @apply h-12;
123
+ }
124
+
125
+ &[data-size="7"] {
126
+ @apply h-14;
127
+ }
128
+
129
+ &[data-size="8"] {
130
+ @apply h-16;
131
+ }
132
+ }
133
+
134
+ .spacer-vertical-md {
135
+ &[data-size="1"] {
136
+ @apply h-4;
137
+ }
138
+
139
+ &[data-size="2"] {
140
+ @apply h-6;
141
+ }
142
+
143
+ &[data-size="3"] {
144
+ @apply h-8;
145
+ }
146
+
147
+ &[data-size="4"] {
148
+ @apply h-10;
149
+ }
150
+
151
+ &[data-size="5"] {
152
+ @apply h-12;
153
+ }
154
+
155
+ &[data-size="6"] {
156
+ @apply h-14;
157
+ }
158
+
159
+ &[data-size="7"] {
160
+ @apply h-16;
161
+ }
162
+
163
+ &[data-size="8"] {
164
+ @apply h-18;
165
+ }
166
+ }
167
+
168
+ .spacer-vertical-lg {
169
+ &[data-size="1"] {
170
+ @apply h-6;
171
+ }
172
+
173
+ &[data-size="2"] {
174
+ @apply h-8;
175
+ }
176
+
177
+ &[data-size="3"] {
178
+ @apply h-10;
179
+ }
180
+
181
+ &[data-size="4"] {
182
+ @apply h-12;
183
+ }
184
+
185
+ &[data-size="5"] {
186
+ @apply h-14;
187
+ }
188
+
189
+ &[data-size="6"] {
190
+ @apply h-16;
191
+ }
192
+
193
+ &[data-size="7"] {
194
+ @apply h-18;
195
+ }
196
+
197
+ &[data-size="8"] {
198
+ @apply h-20;
199
+ }
200
+ }
201
+ }
@@ -0,0 +1,23 @@
1
+ module Coco
2
+ class Spacer < Coco::Component
3
+ include Concerns::AcceptsOptions
4
+
5
+ SIZES = [0, 1, 2, 3, 4, 5, 6, 7, 8]
6
+
7
+ BREAKPOINTS = %i[sm md lg xl]
8
+
9
+ DEFAULT = 4
10
+
11
+ accepts_option :size, from: SIZES, default: DEFAULT
12
+ accepts_option :scale_from, from: BREAKPOINTS, private: true
13
+ accepts_option :responsive, from: [true, false], default: true, private: true
14
+
15
+ def call
16
+ render component_tag(:div, data: {scale_from:})
17
+ end
18
+
19
+ def scale_from
20
+ get_option_value(:responsive) ? get_option_value(:scale_from) : BREAKPOINTS.last
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,4 @@
1
+ @layer components {
2
+ [data-coco][data-component="stack"] {
3
+ }
4
+ }
@@ -0,0 +1,4 @@
1
+ <%= render component_tag do %>
2
+ <%= safe_join(items) %>
3
+ <% end %>
4
+