|
1 | | -/* Checkbox Component - Based on Figma Design System */ |
2 | | -/* BEM Methodology: .checkbox (block), .checkbox__input (element), .checkbox--modifier (modifiers) */ |
3 | | - |
4 | | -/* ========================================================================== |
5 | | - Base Styles |
6 | | - ========================================================================== */ |
7 | | - |
8 | | -.checkbox__input { |
9 | | - @apply size-4 mx-3 cursor-pointer rounded-sm border-1 border-tertiary bg-primary; |
10 | | - box-shadow: var(--box-shadow); |
11 | | -} |
12 | | - |
13 | | -/* ========================================================================== |
14 | | - State: Checked & Indeterminate |
15 | | - ========================================================================== */ |
16 | | - |
17 | | -.checkbox__input:checked, |
18 | | -.checkbox__input:indeterminate { |
19 | | - @apply bg-accent-content border-accent-content; |
20 | | -} |
21 | | - |
22 | | -/* ========================================================================== |
23 | | - State: Focus & Hover |
24 | | - ========================================================================== */ |
25 | | - |
26 | | -.checkbox__input:focus-visible, |
27 | | -.checkbox__input:hover:not(:disabled) { |
28 | | - @apply ring-2 ring-offset-2 ring-accent-content outline-none; |
29 | | -} |
30 | | - |
31 | | -/* Maintain checked/indeterminate appearance on focus/hover */ |
32 | | -.checkbox__input:checked:focus-visible, |
33 | | -.checkbox__input:checked:hover:not(:disabled), |
34 | | -.checkbox__input:indeterminate:focus-visible, |
35 | | -.checkbox__input:indeterminate:hover:not(:disabled) { |
36 | | - @apply bg-accent-content border-accent-content; |
37 | | -} |
38 | | - |
39 | | -/* ========================================================================== |
40 | | - State: Disabled |
41 | | - ========================================================================== */ |
42 | | - |
43 | | -.checkbox__input:disabled { |
44 | | - @apply cursor-not-allowed opacity-60; |
45 | | -} |
46 | | - |
47 | | -/* ========================================================================== |
48 | | - Modifier: Floating (row selector behavior) |
49 | | - ========================================================================== */ |
50 | | - |
51 | | -.checkbox__input--floating { |
52 | | - @apply absolute start-0 top-0 mt-3 z-10 hidden; |
53 | | -} |
54 | | - |
55 | | -.checkbox__input--floating:checked, |
56 | | -.group:hover .checkbox__input--floating { |
57 | | - @apply block; |
| 1 | +@layer base { |
| 2 | + input[type=checkbox] { |
| 3 | + @apply size-4 cursor-pointer rounded-sm border-1 border-tertiary bg-primary; |
| 4 | + box-shadow: var(--box-shadow); |
| 5 | + } |
| 6 | + |
| 7 | + input[type=checkbox]:checked { |
| 8 | + background-image: url(data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2212%22%20height%3D%228%22%20viewBox%3D%220%200%2012%208%22%20fill%3D%22white%22%3E%3Cpath%20d%3D%22M10.1953%200.195262C10.4556%20-0.0650874%2010.8776%20-0.0650874%2011.138%200.195262C11.3983%200.455612%2011.3983%200.877621%2011.138%201.13797L4.4713%207.80464C4.21095%208.06499%203.78895%208.06499%203.5286%207.80464L0.195262%204.4713C-0.0650874%204.21095%20-0.0650874%203.78894%200.195262%203.5286C0.455612%203.26825%200.877621%203.26825%201.13797%203.5286L3.99995%206.39057L10.1953%200.195262Z%22%20fill%3D%22white%22%2F%3E%3C%2Fsvg%3E); |
| 9 | + background-size: 70%; |
| 10 | + } |
| 11 | + |
| 12 | + input[type=checkbox]:indeterminate { |
| 13 | + background-image: url(data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2211%22%20height%3D%222%22%20viewBox%3D%220%200%2011%202%22%20fill%3D%22white%22%3E%3Cpath%20d%3D%22M10%200C10.3682%200%2010.6667%200.298477%2010.6667%200.666667C10.6667%201.03486%2010.3682%201.33333%2010%201.33333H0.666667C0.298477%201.33333%200%201.03486%200%200.666667C0%200.298477%200.298477%200%200.666667%200H10Z%22%20fill%3D%22white%22%2F%3E%3C%2Fsvg%3E); |
| 14 | + background-size: 70%; |
| 15 | + } |
| 16 | + |
| 17 | + input[type=checkbox]:checked, |
| 18 | + input[type=checkbox]:indeterminate { |
| 19 | + @apply bg-accent-content border-accent-content; |
| 20 | + } |
| 21 | + |
| 22 | + input[type=checkbox]:focus-visible, |
| 23 | + input[type=checkbox]:hover:not(:disabled) { |
| 24 | + @apply ring-2 ring-offset-2 ring-accent-content outline-none; |
| 25 | + } |
| 26 | + |
| 27 | + input[type=checkbox]:checked:focus-visible, |
| 28 | + input[type=checkbox]:checked:hover:not(:disabled), |
| 29 | + input[type=checkbox]:indeterminate:focus-visible, |
| 30 | + input[type=checkbox]:indeterminate:hover:not(:disabled) { |
| 31 | + @apply bg-accent-content border-accent-content; |
| 32 | + } |
| 33 | + |
| 34 | + input[type=checkbox]:disabled { |
| 35 | + @apply cursor-not-allowed opacity-60; |
| 36 | + } |
58 | 37 | } |
0 commit comments