Repository navigation
Expand file tree
/
Copy pathstyle.css
More file actions
982 lines (907 loc) · 33.5 KB
/
Copy pathstyle.css
File metadata and controls
982 lines (907 loc) · 33.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
/*
For optimized output that includes only what your code uses, use the Vite plugin
or Gro generator instead of importing this file directly:
import 'virtual:fuz.css'; // Vite plugin - recommended
import './fuz.css'; // Gro generator
Direct import is for utility-only mode (with theme.css) or non-bundled usage.
See: https://css.fuz.dev/docs/classes
---
Notes:
- acts as a CSS reset and also sets minimal defaults for elements with themable variables
- wraps opinionated selectors in `:where` so they carry zero specificity -
cross-layer overrides (utilities, themes, consumer styles) are already
guaranteed by cascade-layer order, so what `:where` buys now is that
conflicts *within* this stylesheet resolve purely by source order
(the state interplay below depends on that), and that rules consumers
add into the fuz layers override these effortlessly
- `.unstyled` class opts out of opinionated styling (colors, borders, decorative properties)
while keeping normalizations (font inheritance, border-collapse) -
applied to interactive elements (links, buttons, inputs, summary) and decorative containers,
but not structural elements where styling aids usability (tables) or is semantic (small)
- needs more variables
*/
@layer fuz.base, fuz.preferences, fuz.theme, fuz.utilities;
/* OS user-preference mappings live in fuz.preferences, above the fuz.base
defaults (so they beat them regardless of import order, including theme.css
in utility-only mode) and below fuz.theme (so theme overrides beat them). */
@layer fuz.preferences {
@media (prefers-reduced-motion) {
:root {
/* setting to `initial` disables animations but allows for fallbacks (see PendingAnimation);
`!important` because a theme may set durations and must not re-enable motion the
user turned off - in a layer it outranks every `:root` declaration, layered or not,
while an element further down can still set its own duration */
--duration_6: initial !important;
--duration_5: initial !important;
--duration_4: initial !important;
--duration_3: initial !important;
--duration_2: initial !important;
--duration_1: initial !important;
}
}
/* map the OS contrast preference onto the same variables the
'high contrast' modifier sets: the curve knobs, the border and link
roles, and the panel ring */
@media (prefers-contrast: more) {
:root {
--shade_lightness_00: 1;
--text_lightness_curve: 0.8;
--border_color: var(--shade_50);
--link_color: var(--accent_70);
--panel_shadow: 0 0 0 var(--border_width) var(--border_color);
}
:root.dark {
--shade_lightness_00: 0.12;
--text_lightness_curve: 0.6;
}
}
/* the dark mapping again for a root that names no scheme, following the OS
(see `render_color_scheme_rules`) */
@media (prefers-contrast: more) and (prefers-color-scheme: dark) {
:root:not(.light) {
--shade_lightness_00: 0.12;
--text_lightness_curve: 0.6;
}
}
/* forced colors (Windows High Contrast) replace author colors with system
colors, so states painted only by a background or a color mix vanish;
these restate them in system colors. One block per element, so each
ships with its element in bundled output. The composites restate
their own states inside their rulesets, since a rule here loses to
them from fuz.utilities. */
@media (forced-colors: active) {
:where(input[type='radio']:not(.unstyled):checked)::before {
background-color: CanvasText;
}
}
@media (forced-colors: active) {
/* the thumb and track pseudo-elements read this variable */
:where(input[type='range']:not(.unstyled)) {
--thumb_background_color: CanvasText;
}
:where(input[type='range']:not(.unstyled):is(:disabled, [aria-disabled='true'])) {
--thumb_background_color: GrayText;
}
}
@media (forced-colors: active) {
/* gradients are dropped in forced colors, taking the chevron with them,
so the native arrow comes back */
:where(select:not(.unstyled)) {
appearance: auto;
background-image: none;
}
}
@media (forced-colors: active) {
/* Highlight marks selection alone, so a focused link rings in the text
color rather than the browser's forced pick, which can be Highlight */
:where(a:not(.unstyled):focus-visible) {
outline-color: CanvasText;
}
}
@media (forced-colors: active) {
/* Highlight marks selection alone, so the focus ring takes the text color
rather than the browser's forced pick, which can be Highlight too */
:where(:is(button, input, textarea, select):not(.unstyled):focus-visible) {
border-color: CanvasText;
outline-color: CanvasText;
}
/* native `:disabled` is grayed by the browser, `aria-disabled` is not;
after the focus rule, so a focused one keeps its GrayText border */
:where(:is(button, input, textarea, select):not(.unstyled)[aria-disabled='true']) {
color: GrayText;
border-color: GrayText;
}
/* forced colors drop the selected fill, so selection shows as a
Highlight border with an outline drawn just inside it (no layout
shift). Focused, the outline moves out as a double Highlight ring, so
a focused selected button reads apart from both a focused one (a
single CanvasText ring) and a selected one. The colors stay forced
(no `forced-color-adjust: none`), so the label and its text keep the
system's text color (icons too, when drawn in `currentColor`) */
:where(button:not(.unstyled):is(.selected, [aria-pressed='true'])) {
border-color: Highlight;
outline: var(--outline_width_focus) solid Highlight;
outline-offset: calc(-1 * (var(--border_width) + var(--outline_width_focus)));
}
:where(button:not(.unstyled):is(.selected, [aria-pressed='true']):focus-visible) {
outline: calc(2 * var(--outline_width_focus)) double Highlight;
outline-offset: var(--outline_offset);
}
:where(
button:not(.unstyled):is(.selected, [aria-pressed='true']):is(
:disabled,
[aria-disabled='true']
)
) {
border-color: GrayText;
outline-color: GrayText;
}
}
}
/* All other rules live in the fuz.base cascade layer: the preference mappings
beat them from fuz.preferences, theme overrides from fuz.theme, generated
utility classes from fuz.utilities, and consumers' unlayered styles beat
everything. The bundled generators unwrap these blocks and re-layer only
the rules a project uses. */
@layer fuz.base {
*,
::before,
::after,
::backdrop {
box-sizing: border-box;
border: 0 solid;
margin: 0;
padding: 0;
}
:root,
:host {
color-scheme: light dark; /* follows the OS unless the root names a scheme with `.dark` or `.light` */
background-color: var(--shade_00);
background-image: var(--background_image);
color: var(--text_color);
accent-color: var(--accent_50);
scrollbar-color: var(--scrollbar_thumb_color) var(--scrollbar_track_color);
line-height: var(--line_height_md);
font-size: 62.5%; /* see `body.font-size`, using `rem` font size units with a base 16px */
/* stops mobile browsers inflating text on their own (iOS Safari after an
orientation change); `100%` rather than `none`, which can also block the
reader's own text scaling on some mobile browsers - a desktop browser
can't show the difference, so this is untested on a phone
@source https://kilianvalkhof.com/2022/css-html/your-css-reset-needs-text-size-adjust-probably/ */
-moz-text-size-adjust: 100%;
-webkit-text-size-adjust: 100%;
text-size-adjust: 100%;
-webkit-tap-highlight-color: transparent;
}
:root.dark {
color-scheme: dark;
}
:root.light {
color-scheme: light;
}
body {
min-height: 100svh; /* the small viewport, so the floor never scrolls a short page under a mobile toolbar */
font-size: var(--font_size_md, 1.6rem); /* rem against `font-size: 62.5%`; the token follows `--font_size_scale` */
font-family: var(--font_family);
font-weight: var(--font_weight);
tab-size: 2; /* TODO var */
}
::selection {
background-color: var(--selection_color);
}
:where(input, textarea)::placeholder {
opacity: 1;
color: color-mix(in oklab, currentcolor 50%, transparent);
}
:where(input)::file-selector-button {
font: inherit;
cursor: pointer;
}
:where(dialog:not(.unstyled))::backdrop {
/* same default dim as fuz_ui's Dialog, themable through one variable,
then its default `--darken_60` for a variable set without it. Older
browsers don't let ::backdrop inherit custom properties from the
page, so the last fallback is that value as a literal */
background-color: var(--backdrop_color, var(--darken_60, #000000a6));
}
/*
Keep hidden behavior when `display` is set.
The `!important` makes this `hidden` behavior much higher specificity.
Respects `hidden="until-found"` for find-in-page support.
@source https://github.com/jensimmons/cssremedy
*/
[hidden]:where(:not([hidden='until-found'])) {
display: none !important;
}
:where(a:not(.unstyled)) {
cursor: pointer;
/* TODO should the generic be --link_color or --color? */
--text_color: var(--link_color);
color: var(--text_color);
font-weight: 700;
text-decoration: var(--text_decoration);
border-radius: var(--border_radius, var(--border_radius_xs3));
outline: var(--outline_width) var(--outline_style) var(--outline_color);
/* gap between border and ring so the same-color pair reads as two
shapes instead of one thick band */
outline-offset: var(--outline_offset);
}
/* TODO should these be customizable with utility classes? */
:where(a:not(.unstyled):hover) {
text-decoration: var(--text_decoration_hover);
}
/* `:focus-visible`, so a clicked link doesn't hold the ring */
:where(a:not(.unstyled):focus-visible) {
--outline_width: var(--outline_width_focus);
}
:where(a:not(.unstyled):active) {
--outline_width: var(--outline_width_active);
}
:where(a:not(.unstyled):is(.selected, [aria-current]:not([aria-current='false']))) {
--text_color: var(--link_color_selected);
text-decoration: var(--text_decoration_selected);
}
:where(:is(ul, ol, menu):not(.unstyled)) {
padding-left: var(--space_xl4);
}
:where(.unstyled:is(ul, ol, menu)) {
list-style: none;
}
:where(:is(h1, h2, h3, h4, h5, h6, .heading):not(.unstyled)) {
font-family: var(--heading_font_family);
font-size: var(--font_size, inherit);
line-height: var(--line_height_sm);
letter-spacing: var(--heading_letter_spacing);
text-wrap: balance; /* @see https://developer.mozilla.org/en-US/docs/Web/CSS/text-wrap#balance */
/* TODO use this pattern elsewhere? provides API to components like `MdnLogo` */
overflow-wrap: break-word; /* TODO @many is this best? `anywhere` instead? what about adding elsewhere? */
}
/* heading margins use calc multipliers on --flow_margin so they scale proportionally
with .sized_sm while preserving hierarchy. multipliers are derived from the space
scale (sqrt(GR) ≈ 1.272 per step). margin-top is 2 steps above margin-bottom. */
:where(h1:not(.unstyled)) {
--font_size: var(--font_size_xl3);
/* --heading_font_weight is a hook with per-tier fallbacks: setting it
flattens the weight ladder deliberately (display-heavy themes) */
font-weight: var(--heading_font_weight, 300);
margin-bottom: calc(var(--flow_margin, var(--space_lg)) * 3.23);
/* somewhat strange to omit only this one, but generally seems to be the desired behavior */
/* margin-top: calc(var(--flow_margin, var(--space_lg)) * 5.28); */
}
:where(h2:not(.unstyled)) {
--font_size: var(--font_size_xl2);
font-weight: var(--heading_font_weight, 400);
margin-bottom: calc(var(--flow_margin, var(--space_lg)) * 2.54);
margin-top: calc(var(--flow_margin, var(--space_lg)) * 4.15);
}
:where(h3:not(.unstyled)) {
--font_size: var(--font_size_xl);
font-weight: var(--heading_font_weight, 500);
margin-bottom: calc(var(--flow_margin, var(--space_lg)) * 2);
margin-top: calc(var(--flow_margin, var(--space_lg)) * 3.23);
}
:where(h4:not(.unstyled)) {
--font_size: var(--font_size_lg);
font-weight: var(--heading_font_weight, 700);
margin-bottom: calc(var(--flow_margin, var(--space_lg)) * 1.62);
margin-top: calc(var(--flow_margin, var(--space_lg)) * 2.54);
}
:where(h5:not(.unstyled)) {
--font_size: var(--font_size_md);
font-weight: var(--heading_font_weight, 900);
margin-bottom: calc(var(--flow_margin, var(--space_lg)) * 1.23);
margin-top: calc(var(--flow_margin, var(--space_lg)) * 2);
}
:where(h6:not(.unstyled)) {
--font_size: var(--font_size_sm);
font-weight: var(--heading_font_weight, 600);
margin-bottom: var(--flow_margin, var(--space_lg));
margin-top: calc(var(--flow_margin, var(--space_lg)) * 1.62);
text-transform: uppercase;
}
/* a heading opening a padded or bordered box sits on the box's padding -
these boxes don't collapse a child's margin away, so the top margin
would stack on it. Not global: in a page's flow, the first heading of a
nested section keeps its gap from the content before it */
:where(
:is(.panel, .pane, aside, blockquote, fieldset, dialog, li, td, th)
> :is(h2, h3, h4, h5, h6):not(.unstyled):first-child
) {
margin-top: 0;
}
:where(p) {
overflow-wrap: break-word; /* TODO @many is this best? `anywhere` instead? what about adding elsewhere? */
}
/*
TODO remove the :last-child here and elsewhere when margin-trim is fully supported,
currently can break based on DOM structure - https://developer.mozilla.org/en-US/docs/Web/CSS/margin-trim
*/
/* TODO other elements */
/* checkboxes and radios are expected to be nested inside a `label`, thus no bottom margin */
:where(
:is(
p,
ul,
ol,
menu,
form,
fieldset,
table,
details,
textarea,
select,
label,
pre,
blockquote,
aside,
nav,
legend
):not(:last-child):not(.unstyled)
) {
margin-bottom: var(--flow_margin, var(--space_lg));
}
/* sections are the page-level gap: a flow-margin multiple (xl7 over the lg
default), so density composites scale it with the rest of the rhythm */
:where(section:not(:last-child):not(.unstyled)) {
margin-bottom: calc(var(--flow_margin, var(--space_lg)) * 5.31);
}
/* Horizontal flex layout containers reset flow margins on direct children; use `.gap_*`. */
:where(.row > *) {
margin: 0;
}
:where(aside:not(.unstyled)) {
border-left-color: var(--border_color);
border-left-style: var(--border_style);
border-left-width: var(--border_width_3);
border-radius: var(--border_radius, var(--border_radius_xs));
padding: var(--space_md);
color: var(--text_color);
background-color: var(--ink_10);
}
:where(blockquote:not(.unstyled)) {
border-left-color: var(--border_color);
border-left-style: var(--border_style);
border-left-width: var(--border_width_8);
padding: var(--space_md);
color: var(--text_color);
}
:where(code:not(.unstyled)) {
white-space: pre-wrap;
font-family: var(--font_family_mono);
-webkit-hyphens: none;
hyphens: none;
color: var(--text_color);
background-color: var(--ink_05);
padding: 0 var(--space_xs2);
border-radius: var(--border_radius, var(--border_radius_xs));
}
:where(code.inline, p code) {
display: inline-block;
vertical-align: baseline;
}
:where(pre:not(.unstyled)) {
font-family: var(--font_family_mono);
color: var(--text_color);
white-space: pre;
overflow: auto;
max-width: 100%;
}
:where(hr:not(.unstyled)) {
border-top: 1px solid var(--border_color_30);
border-bottom: 2px solid var(--border_color_30);
border-left: none;
border-right: none;
width: 100%;
height: 5px;
margin: var(--space_xl7) 0;
}
:where(fieldset:not(.unstyled)) {
display: flex;
flex-direction: column;
}
:where(fieldset) {
/* TODO consider a global border reset */
border: 0;
}
:where(legend:not(.unstyled)) {
font-size: var(--font_size_lg);
}
/* normalization - keep font inheritance even for unstyled */
:where(button, input, textarea, select) {
font: inherit;
}
:where(:is(input, textarea, select):not(.unstyled)) {
appearance: none;
line-height: normal;
display: block;
color: var(--text_color);
caret-color: var(--caret_color);
background-color: var(--input_fill);
border-color: var(--border_color);
border-style: var(--border_style);
border-width: var(--border_width);
border-radius: var(--border_radius, var(--control_radius));
outline: var(--outline_width) var(--outline_style) var(--outline_color);
outline-offset: var(--outline_offset);
padding: var(--input_padding_y) var(--input_padding_x);
width: 100%;
min-width: var(--input_width_min);
min-height: var(--input_height);
}
:where(textarea:not(.unstyled)) {
--input_padding_y: var(--space_sm);
height: 100px;
resize: vertical;
}
/* `appearance: none` removes the native arrow, so single selects draw a
chevron from two gradients in the text color, following the scheme and
the disabled opacity (forced colors restore the native arrow, in
fuz.preferences); list boxes (`multiple`, a `size` above 1) have none
TODO the arrow stays on the right in RTL - no logical `background-position` yet */
:where(select:not(.unstyled):not([multiple], [size]:not([size='1']))) {
--select_arrow_size: 0.35em;
padding-right: calc(var(--input_padding_x) + 3 * var(--select_arrow_size));
background-image:
linear-gradient(45deg, transparent 50%, currentcolor 50%),
linear-gradient(135deg, currentcolor 50%, transparent 50%);
background-position:
right calc(var(--input_padding_x) + var(--select_arrow_size)) center,
right var(--input_padding_x) center;
background-size: var(--select_arrow_size) var(--select_arrow_size);
background-repeat: no-repeat;
}
:where(:is(select, option, input[type='color']):not(:disabled):not([aria-disabled='true'])) {
cursor: pointer;
}
:where(option:not(.unstyled)) {
color: var(--text_color);
background-color: var(--shade_00);
}
:where(
:is(input, textarea, select):not(.unstyled):hover:not(:disabled):not([aria-disabled='true'])
) {
/* hover previews the focus color - the element color when set (an
outline_* class), else the accent intent; focus then adds the outline
at the same color, escalating visibility (buttons hover through
--button_border_color_hover instead) */
--border_color: var(--outline_color);
}
/* these have no active states because they feel buggy in the browsers,
because the active state only applies when the thumb is clicked directly,
but not for the identical user action of clicking the track,
so for consistent visuals we opt to include no active state */
:where(input[type='checkbox']:not(.unstyled)) {
cursor: pointer;
width: var(--input_height_compact);
height: var(--input_height_compact);
min-width: var(--input_height_compact);
min-height: var(--input_height_compact);
border-radius: var(--border_radius, var(--border_radius_xs));
--input_padding_x: 0;
--checkbox_content: var(--checkbox_content_empty, '');
}
:where(input[type='checkbox']:not(.unstyled):checked) {
--checkbox_content: var(--checkbox_content_checked, '✓'); /* ✔✓ ✗ ✘ */
}
:where(input[type='checkbox']:not(.unstyled))::before {
content: var(--checkbox_content);
width: 100%;
height: 100%;
text-align: center;
line-height: normal;
display: flex;
align-items: center;
justify-content: center;
overflow: var(--overflow, visible);
font-size: var(--font_size, var(--font_size_xl3));
color: var(--text_color);
}
:where(input[type='radio']:not(.unstyled)) {
cursor: pointer;
width: var(--input_height_compact);
height: var(--input_height_compact);
border-radius: 50%;
min-width: var(--input_height_compact);
min-height: var(--input_height_compact);
--input_padding_x: 0;
}
:where(input[type='radio']:not(.unstyled):checked)::before {
content: '';
display: block;
position: relative;
top: 25%;
left: 25%;
width: 50%;
height: 50%;
background-color: var(--text_color);
border-radius: 50%;
}
/* TODO @many figure these variables out so they're easily customized (similar pattern in a lot of places) */
:where(input[type='range']:not(.unstyled)) {
--thumb_size: var(--space_xl);
--thumb_background_color: var(--text_70);
cursor: pointer;
}
:where(input[type='range']:not(.unstyled):hover:not(:disabled):not([aria-disabled='true'])) {
--thumb_background_color: var(--accent_50);
}
:where(input[type='range']:not(.unstyled):disabled:active) {
--thumb_background_color: var(--negative_50);
}
:where(input[type='range']:not(.unstyled))::-webkit-slider-thumb {
appearance: none;
height: var(--thumb_size);
width: var(--thumb_size);
border-radius: 50%;
background-color: var(--thumb_background_color);
border: 0;
/*
this is the only line that differs between the `moz` one
CSS stops parsing if it hits an unknown selector like `::-moz-range-thumb` in Webkit/Blink,
so we need both declarations anyway, and the declarations can't be combined with plain CSS,
one of the few times I've wanted to reach for PostCSS
*/
margin-top: calc(var(--thumb_size) / -2);
}
:where(input[type='range']:not(.unstyled))::-moz-range-thumb {
appearance: none;
height: var(--thumb_size);
width: var(--thumb_size);
border-radius: 50%;
background-color: var(--thumb_background_color);
border: 0;
}
:where(input[type='range']:not(.unstyled))::-webkit-slider-runnable-track {
width: 100%;
height: var(--border_width);
background-color: var(--thumb_background_color);
}
:where(input[type='range']:not(.unstyled))::-moz-range-track {
width: 100%;
height: var(--border_width);
background-color: var(--thumb_background_color);
}
/* TODO :has selector? `button:has(input[type='checkbox']:checked)`
see https://caniuse.com/css-has
*/
:where(input:not(.unstyled):checked:not(:disabled):not([aria-disabled='true'])) {
--text_color: var(--accent_50);
--border_color: var(--accent_50);
}
:where(input[type='radio']:not(.unstyled):checked) {
cursor: default;
}
/* after the checked state, so an invalid checkbox reads invalid; hover and
focus color the border through `--outline_color`, so they stay negative */
:where(:is(input, textarea, select):not(.unstyled)[aria-invalid='true']) {
--border_color: var(--negative_50);
--outline_color: var(--negative_50);
}
:where(
:is(input, textarea, select):not(.unstyled).inline,
p :is(input, textarea, select):not(.unstyled)
) {
display: inline-block;
margin-left: var(--space_lg);
/* TODO ideally `width` here would be set to a minimum and have an API to increase size --
buttons can grow automatically, but how can inputs? only with js?
*/
width: var(--input_width_min);
}
/* `aria-disabled` takes the disabled look but stays focusable, so only
native `:disabled` drops the outline */
:where(:is(input, textarea, select):not(.unstyled):is(:disabled, [aria-disabled='true'])) {
/* TODO ideally these would just set `fill`, but they'd have to go after the button variants, and then duplicate selectors? */
--input_fill: transparent;
--border_style: solid dashed;
cursor: default;
opacity: var(--disabled_opacity);
}
:where(:is(input, textarea, select):not(.unstyled):disabled) {
outline: none;
}
:where([contenteditable]:not(.unstyled):focus-visible) {
--outline_width: var(--outline_width_focus);
outline: var(--outline_width) var(--outline_style) var(--outline_color);
outline-offset: var(--outline_offset);
}
/* split from contenteditable, which no element or class names, so the
bundled output ships these with the elements and that one always */
:where(:is(input, textarea, select):not(.unstyled):active) {
--outline_width: var(--outline_width_active);
}
:where([contenteditable]:not(.unstyled):active) {
--outline_width: var(--outline_width_active);
}
/* TODO could improve this with the coming `:has` selector
for disabled colors without needing a wrapper .disabled class */
:where(label:not(.unstyled)) {
display: block;
color: var(--text_color);
cursor: pointer;
}
:where(:is(label:not(.unstyled) .title)) {
font-weight: 600;
margin-bottom: var(--space_xs2);
}
:where(label.selected:not(.unstyled)) {
cursor: default;
--text_color: var(--accent_60);
}
:where(label.disabled:not(.unstyled)) {
cursor: default;
--text_color: var(--text_disabled);
}
:where(label.row:not(.unstyled)) {
justify-content: flex-start;
}
:where(label.row:not(.unstyled) :is(input[type='checkbox'], input[type='radio']):not(.unstyled)) {
margin-right: var(--space_md);
}
/*
TODO think through these patterns to get somewhere consistent
- declaring variables with variants like `_hover` enables simpler theming, so you don't have to write complex selectors and can just change a variable
- should the variants therefore be changed to style variables or inlined here?
- inlining them here avoids the overhead of variables, but is that optimizable anyway? are there added costs in theory that aren't avoidable?
- but these need to be resolved locally to get overrides, couldn't set `fill` for example - can you use a variable still though, just also locally declare it?
*/
:where(button:not(.unstyled)) {
--text_color: var(--text_70);
--button_text_color: var(--text_color);
--button_fill: color-mix(in oklab, var(--fill, var(--shade_50)) 8%, transparent);
--button_fill_hover: color-mix(in oklab, var(--fill, var(--shade_50)) 16%, transparent);
--button_fill_active: color-mix(in oklab, var(--fill, var(--shade_50)) 24%, transparent);
--button_border_color: var(--border_color);
/* TODO give real values, 90%? */
--button_border_color_hover: color-mix(in oklab, var(--border_color) 90%, var(--shade_max));
--button_border_color_active: color-mix(in oklab, var(--border_color) 80%, var(--shade_max));
color: var(--button_text_color);
background-color: var(--button_fill);
cursor: pointer;
appearance: none;
display: flex;
flex-wrap: wrap;
align-items: center;
justify-content: center;
font-size: var(--font_size, inherit);
font-weight: 700;
line-height: normal;
min-height: var(--button_min_height, var(--input_height));
padding: 0 var(--input_padding_x);
box-shadow: var(--shadow, var(--button_shadow));
border-width: var(--border_width);
border-style: var(--button_border_style);
border-color: var(--button_border_color);
border-radius: var(--border_radius, var(--control_radius));
outline: var(--outline_width) var(--outline_style) var(--outline_color);
outline-offset: var(--outline_offset);
}
/* the ring is the only focus signal, and `:focus-visible` keeps it to
keyboard focus on buttons, checkboxes, and radios - a click into a text
field or select still matches, so those keep it */
:where(:is(button, input, textarea, select):not(.unstyled):focus-visible) {
/* follows the element color when set (an outline_* class; on buttons,
.palette_*), else the accent intent */
--border_color: var(--outline_color);
--outline_width: var(--outline_width_focus);
}
/* TODO maybe gradients? or at least use a text_color */
/* TODO hover variants with brighter borders? maybe use a colorless border for that? */
/* the label is stop 70, a step past the text-safe stop 60 links use, so it
holds AA on every fill its own tint takes - rest, hover, and pressed; the
fill, border, and ring stay at stop 60, which also carries the inverse
text once selected fills the button */
:where(button:not(.unstyled).palette_a) {
--text_color: var(--palette_a_70);
--fill: var(--palette_a_60);
--border_color: var(--palette_a_60);
--outline_color: var(--palette_a_60);
}
:where(button:not(.unstyled).palette_b) {
--text_color: var(--palette_b_70);
--fill: var(--palette_b_60);
--border_color: var(--palette_b_60);
--outline_color: var(--palette_b_60);
}
:where(button:not(.unstyled).palette_c) {
--text_color: var(--palette_c_70);
--fill: var(--palette_c_60);
--border_color: var(--palette_c_60);
--outline_color: var(--palette_c_60);
}
:where(button:not(.unstyled).palette_d) {
--text_color: var(--palette_d_70);
--fill: var(--palette_d_60);
--border_color: var(--palette_d_60);
--outline_color: var(--palette_d_60);
}
:where(button:not(.unstyled).palette_e) {
--text_color: var(--palette_e_70);
--fill: var(--palette_e_60);
--border_color: var(--palette_e_60);
--outline_color: var(--palette_e_60);
}
:where(button:not(.unstyled).palette_f) {
--text_color: var(--palette_f_70);
--fill: var(--palette_f_60);
--border_color: var(--palette_f_60);
--outline_color: var(--palette_f_60);
}
:where(button:not(.unstyled).palette_g) {
--text_color: var(--palette_g_70);
--fill: var(--palette_g_60);
--border_color: var(--palette_g_60);
--outline_color: var(--palette_g_60);
}
:where(button:not(.unstyled).palette_h) {
--text_color: var(--palette_h_70);
--fill: var(--palette_h_60);
--border_color: var(--palette_h_60);
--outline_color: var(--palette_h_60);
}
:where(button:not(.unstyled).palette_i) {
--text_color: var(--palette_i_70);
--fill: var(--palette_i_60);
--border_color: var(--palette_i_60);
--outline_color: var(--palette_i_60);
}
:where(button:not(.unstyled).palette_j) {
--text_color: var(--palette_j_70);
--fill: var(--palette_j_60);
--border_color: var(--palette_j_60);
--outline_color: var(--palette_j_60);
}
/* TODO try to rearrange some of this to go after the colored variants */
/* `aria-disabled` takes the disabled look but stays focusable, so only
native `:disabled` drops the outline - and it keeps pointer events, so
a tooltip or a click handler explaining why still works */
:where(button:not(.unstyled):is(:disabled, [aria-disabled='true'])) {
/* TODO ideally these would just set `fill`, but they'd have to go after the button variants, and then duplicate selectors? */
--button_fill: transparent;
--button_border_style: solid dashed;
cursor: default;
box-shadow: none;
opacity: var(--disabled_opacity);
}
:where(button:not(.unstyled):disabled) {
outline: none;
}
/* `aria-pressed` takes the selected look but not the settled behavior
below, since a pressed toggle can be unpressed, like `.deselectable` */
:where(button:not(.unstyled):is(.selected, [aria-pressed='true'])) {
/* text_00 is the ramp endpoint: contrast themes bending
--text_lightness_curve move the near-background stops toward the fill,
but can never move an endpoint, so inverse text stays readable */
--button_text_color: var(--text_00);
--button_fill: var(--fill, var(--shade_60));
--button_fill_hover: var(--fill, var(--shade_60));
--button_fill_active: var(--fill, var(--shade_60));
}
:where(button:not(.unstyled).selected:not(.deselectable)) {
--button_border_color_hover: var(--border_color);
--button_border_color_active: var(--border_color);
cursor: default;
box-shadow: none;
}
/* hover only - focus shows as the ring alone */
:where(button:not(.unstyled):not(:disabled):not([aria-disabled='true']):hover) {
--button_fill: var(--button_fill_hover);
--button_border_color: var(--button_border_color_hover);
--shadow: var(--button_shadow_hover);
}
:where(
button:not(.unstyled):not(.selected, [aria-pressed='true']):not(:disabled):not(
[aria-disabled='true']
):hover
) {
--button_text_color: color-mix(in oklab, var(--text_color) 90%, var(--shade_max));
}
/* a settled `.selected` (no `.deselectable`) keeps its label on hover,
`aria-pressed` or not */
:where(
button:not(.unstyled):is(.selected.deselectable, [aria-pressed='true']:not(.selected)):not(
:disabled
):not([aria-disabled='true']):hover
) {
--button_text_color: var(--text_min);
}
:where(button:not(.unstyled):not(:disabled):not([aria-disabled='true']):active) {
--button_fill: var(--button_fill_active);
--button_border_color: var(--button_border_color_active);
--outline_width: var(--outline_width_active);
--shadow: var(--button_shadow_active);
/* set on the property, not the variable - a variable pointing back at
`--button_border_style` would be a cycle */
border-style: var(--button_border_style_active);
}
:where(
:is(input, textarea, select, button):not(.unstyled):disabled:active,
label:not(.unstyled).disabled:active
) {
--text_color: var(--negative_50);
--border_color: var(--negative_50);
}
/* TODO is there a cleaner way to override these through vars? */
:where(button:not(.unstyled):is(.selected, [aria-pressed='true']):disabled:active) {
--text_color: var(--text_00);
--fill: var(--negative_50);
}
:where(button:not(.unstyled):not(.selected, [aria-pressed='true']):disabled:active) {
--fill: transparent;
}
:where(button:not(.unstyled).selected:not(.deselectable):active) {
--outline_width: var(--outline_width_focus);
}
:where(button:not(.unstyled).inline, p button:not(.unstyled)) {
display: inline-block;
/* TODO this increases paragraph line spacing */
min-height: var(--button_min_height, var(--input_height_compact));
}
:where(small) {
font-size: var(--font_size_sm);
}
:where(img, picture, canvas, svg, video) {
display: block;
max-width: 100%; /* shrink to fit */
height: auto; /* preserve aspect ratio */
}
:where(audio) {
width: 100%;
}
:where(summary:not(.unstyled)) {
cursor: pointer;
padding: var(--space_md);
border-radius: var(--border_radius, var(--border_radius_xs));
}
:where(summary:hover:not(.unstyled)) {
background-color: var(--ink_10);
}
:where(summary:active:not(.unstyled)) {
background-color: var(--ink_20);
}
:where(details[open] summary:not(.unstyled)) {
margin-bottom: var(--space_sm);
}
:where(table) {
border-collapse: collapse;
}
:where(thead) {
text-align: left;
}
:where(th) {
font-weight: bold;
}
:where(th, td) {
padding: var(--space_xs3) var(--space_sm);
}
:where(tr) {
border-bottom: 1px solid var(--border_color_10);
}
:where(tr:hover) {
background-color: var(--ink_10);
}
:where(abbr[title]) {
text-decoration: underline dotted;
}
:where(b, strong) {
font-weight: bolder;
}
:where(kbd, samp) {
font-family: var(--font_family_mono);
}
:where(sub, sup) {
font-size: 75%;
line-height: 0;
position: relative;
vertical-align: baseline;
}
:where(sub) {
bottom: -0.25em;
}
:where(sup) {
top: -0.5em;
}
:where(progress) {
vertical-align: baseline;
}
} /* @layer fuz.base */