|
1 | | -@layer components { |
2 | | - .checkbox, |
3 | | - .radio, |
4 | | - .switch { |
5 | | - @apply inline-flex items-center cursor-pointer relative; |
| 1 | +@utility checkbox { |
| 2 | + @apply inline-flex items-center cursor-pointer relative; |
| 3 | + |
| 4 | + & input[type='checkbox'] { |
| 5 | + @apply absolute left-0 opacity-0 -z-1; |
| 6 | + } |
| 7 | + |
| 8 | + & input[type='checkbox'] + .check { |
| 9 | + @apply border-gray-700 border transition-colors duration-200 dark:bg-slate-800; |
| 10 | + } |
| 11 | + |
| 12 | + & input[type='checkbox']:focus + .check { |
| 13 | + @apply ring-3 ring-blue-700; |
| 14 | + } |
| 15 | + |
| 16 | + & input[type='checkbox'] + .check { |
| 17 | + @apply block w-5 h-5; |
| 18 | + } |
| 19 | + |
| 20 | + & input[type='checkbox'] + .check { |
| 21 | + @apply rounded-sm; |
| 22 | + } |
| 23 | + |
| 24 | + & input[type='checkbox']:checked + .check { |
| 25 | + @apply bg-no-repeat bg-center border-4; |
6 | 26 | } |
7 | 27 |
|
8 | | - .checkbox input[type='checkbox'], |
9 | | - .radio input[type='radio'], |
10 | | - .switch input[type='checkbox'] { |
| 28 | + & input[type='checkbox']:checked + .check { |
| 29 | + background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1 1'%3E%3Cpath style='fill:%23fff' d='M 0.04038059,0.6267767 0.14644661,0.52071068 0.42928932,0.80355339 0.3232233,0.90961941 z M 0.21715729,0.80355339 0.85355339,0.16715729 0.95961941,0.2732233 0.3232233,0.90961941 z'%3E%3C/path%3E%3C/svg%3E"); |
| 30 | + } |
| 31 | + |
| 32 | + & input[type='checkbox']:checked + .check { |
| 33 | + @apply bg-blue-600 border-blue-600; |
| 34 | + } |
| 35 | +} |
| 36 | + |
| 37 | +@utility radio { |
| 38 | + @apply inline-flex items-center cursor-pointer relative; |
| 39 | + |
| 40 | + & input[type='radio'] { |
11 | 41 | @apply absolute left-0 opacity-0 -z-1; |
12 | 42 | } |
13 | 43 |
|
14 | | - .checkbox input[type='checkbox'] + .check, |
15 | | - .radio input[type='radio'] + .check, |
16 | | - .switch input[type='checkbox'] + .check { |
| 44 | + & input[type='radio'] + .check { |
| 45 | + @apply border-gray-700 border transition-colors duration-200 dark:bg-slate-800; |
| 46 | + } |
| 47 | + |
| 48 | + & input[type='radio']:focus + .check { |
| 49 | + @apply ring-3 ring-blue-700; |
| 50 | + } |
| 51 | + |
| 52 | + & input[type='radio'] + .check { |
| 53 | + @apply block w-5 h-5; |
| 54 | + } |
| 55 | + |
| 56 | + & input[type='radio'] + .check { |
| 57 | + @apply rounded-full; |
| 58 | + } |
| 59 | + |
| 60 | + & input[type='radio']:checked + .check { |
| 61 | + @apply bg-no-repeat bg-center border-4; |
| 62 | + } |
| 63 | + |
| 64 | + & input[type='radio']:checked + .check { |
| 65 | + background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%23fff' d='M12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12A10,10 0 0,0 12,2Z' /%3E%3C/svg%3E"); |
| 66 | + } |
| 67 | + |
| 68 | + & input[type='radio']:checked + .check { |
| 69 | + @apply bg-blue-600 border-blue-600; |
| 70 | + } |
| 71 | +} |
| 72 | + |
| 73 | +@utility switch { |
| 74 | + @apply inline-flex items-center cursor-pointer relative; |
| 75 | + |
| 76 | + & input[type='checkbox'] { |
| 77 | + @apply absolute left-0 opacity-0 -z-1; |
| 78 | + } |
| 79 | + |
| 80 | + & input[type='checkbox'] + .check { |
| 81 | + @apply border-gray-700 border transition-colors duration-200 dark:bg-slate-800; |
| 82 | + } |
| 83 | + |
| 84 | + & input[type='checkbox']:focus + .check { |
| 85 | + @apply ring-3 ring-blue-700; |
| 86 | + } |
| 87 | + |
| 88 | + & input[type='checkbox'] + .check { |
| 89 | + @apply flex items-center shrink-0 w-12 h-6 p-0.5 bg-gray-200; |
| 90 | + } |
| 91 | + |
| 92 | + & input[type='checkbox'] + .check { |
| 93 | + @apply rounded-full; |
| 94 | + } |
| 95 | + |
| 96 | + & input[type='checkbox'] + .check:before { |
| 97 | + @apply rounded-full; |
| 98 | + } |
| 99 | + |
| 100 | + & input[type='checkbox']:checked + .check { |
| 101 | + @apply bg-blue-600 border-blue-600; |
| 102 | + } |
| 103 | + |
| 104 | + & input[type='checkbox'] + .check:before { |
| 105 | + content: ''; |
| 106 | + @apply block w-5 h-5 bg-white border border-gray-700; |
| 107 | + } |
| 108 | + |
| 109 | + & input[type='checkbox']:checked + .check:before { |
| 110 | + transform: translate3d(110%, 0, 0); |
| 111 | + @apply border-blue-600; |
| 112 | + } |
| 113 | +} |
| 114 | + |
| 115 | +@utility check { |
| 116 | + .checkbox input[type='checkbox'] + & { |
17 | 117 | @apply border-gray-700 border transition-colors duration-200 dark:bg-slate-800; |
18 | 118 | } |
19 | 119 |
|
20 | | - .checkbox input[type='checkbox']:focus + .check, |
21 | | - .radio input[type='radio']:focus + .check, |
22 | | - .switch input[type='checkbox']:focus + .check { |
23 | | - @apply ring ring-blue-700; |
| 120 | + .radio input[type='radio'] + & { |
| 121 | + @apply border-gray-700 border transition-colors duration-200 dark:bg-slate-800; |
24 | 122 | } |
25 | 123 |
|
26 | | - .checkbox input[type='checkbox'] + .check, |
27 | | - .radio input[type='radio'] + .check { |
| 124 | + .switch input[type='checkbox'] + & { |
| 125 | + @apply border-gray-700 border transition-colors duration-200 dark:bg-slate-800; |
| 126 | + } |
| 127 | + |
| 128 | + .checkbox input[type='checkbox']:focus + & { |
| 129 | + @apply ring-3 ring-blue-700; |
| 130 | + } |
| 131 | + |
| 132 | + .radio input[type='radio']:focus + & { |
| 133 | + @apply ring-3 ring-blue-700; |
| 134 | + } |
| 135 | + |
| 136 | + .switch input[type='checkbox']:focus + & { |
| 137 | + @apply ring-3 ring-blue-700; |
| 138 | + } |
| 139 | + |
| 140 | + .checkbox input[type='checkbox'] + & { |
28 | 141 | @apply block w-5 h-5; |
29 | 142 | } |
30 | 143 |
|
31 | | - .checkbox input[type='checkbox'] + .check { |
32 | | - @apply rounded; |
| 144 | + .radio input[type='radio'] + & { |
| 145 | + @apply block w-5 h-5; |
| 146 | + } |
| 147 | + |
| 148 | + .checkbox input[type='checkbox'] + & { |
| 149 | + @apply rounded-sm; |
33 | 150 | } |
34 | 151 |
|
35 | | - .switch input[type='checkbox'] + .check { |
| 152 | + .switch input[type='checkbox'] + & { |
36 | 153 | @apply flex items-center shrink-0 w-12 h-6 p-0.5 bg-gray-200; |
37 | 154 | } |
38 | 155 |
|
39 | | - .radio input[type='radio'] + .check, |
40 | | - .switch input[type='checkbox'] + .check, |
41 | | - .switch input[type='checkbox'] + .check:before { |
| 156 | + .radio input[type='radio'] + & { |
| 157 | + @apply rounded-full; |
| 158 | + } |
| 159 | + |
| 160 | + .switch input[type='checkbox'] + & { |
42 | 161 | @apply rounded-full; |
43 | 162 | } |
44 | 163 |
|
45 | | - .checkbox input[type='checkbox']:checked + .check, |
46 | | - .radio input[type='radio']:checked + .check { |
| 164 | + .switch input[type='checkbox'] + &:before { |
| 165 | + @apply rounded-full; |
| 166 | + } |
| 167 | + |
| 168 | + .checkbox input[type='checkbox']:checked + & { |
| 169 | + @apply bg-no-repeat bg-center border-4; |
| 170 | + } |
| 171 | + |
| 172 | + .radio input[type='radio']:checked + & { |
47 | 173 | @apply bg-no-repeat bg-center border-4; |
48 | 174 | } |
49 | 175 |
|
50 | | - .checkbox input[type='checkbox']:checked + .check { |
| 176 | + .checkbox input[type='checkbox']:checked + & { |
51 | 177 | background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1 1'%3E%3Cpath style='fill:%23fff' d='M 0.04038059,0.6267767 0.14644661,0.52071068 0.42928932,0.80355339 0.3232233,0.90961941 z M 0.21715729,0.80355339 0.85355339,0.16715729 0.95961941,0.2732233 0.3232233,0.90961941 z'%3E%3C/path%3E%3C/svg%3E"); |
52 | 178 | } |
53 | 179 |
|
54 | | - .radio input[type='radio']:checked + .check { |
| 180 | + .radio input[type='radio']:checked + & { |
55 | 181 | background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%23fff' d='M12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12A10,10 0 0,0 12,2Z' /%3E%3C/svg%3E"); |
56 | 182 | } |
57 | 183 |
|
58 | | - .switch input[type='checkbox']:checked + .check, |
59 | | - .checkbox input[type='checkbox']:checked + .check, |
60 | | - .radio input[type='radio']:checked + .check { |
| 184 | + .switch input[type='checkbox']:checked + & { |
| 185 | + @apply bg-blue-600 border-blue-600; |
| 186 | + } |
| 187 | + |
| 188 | + .checkbox input[type='checkbox']:checked + & { |
| 189 | + @apply bg-blue-600 border-blue-600; |
| 190 | + } |
| 191 | + |
| 192 | + .radio input[type='radio']:checked + & { |
61 | 193 | @apply bg-blue-600 border-blue-600; |
62 | 194 | } |
63 | 195 |
|
64 | | - .switch input[type='checkbox'] + .check:before { |
| 196 | + .switch input[type='checkbox'] + &:before { |
65 | 197 | content: ''; |
66 | 198 | @apply block w-5 h-5 bg-white border border-gray-700; |
67 | 199 | } |
68 | 200 |
|
69 | | - .switch input[type='checkbox']:checked + .check:before { |
| 201 | + .switch input[type='checkbox']:checked + &:before { |
70 | 202 | transform: translate3d(110%, 0, 0); |
71 | 203 | @apply border-blue-600; |
72 | 204 | } |
|
0 commit comments