|
29 | 29 | }
|
30 | 30 | }
|
31 | 31 |
|
32 |
| -// Select drop downs |
33 |
| -select { |
34 |
| - // doiuse-disable |
35 |
| - appearance: none; |
36 |
| - background-image: url('../../svg/select.svg'); |
37 |
| - background-position: right var(--gap-select-icon) center; |
38 |
| - background-repeat: no-repeat; |
39 |
| - background-size: 11px auto; |
40 |
| - border-color: var(--color-border-forms); |
41 |
| - border-radius: var(--border-radius-select); |
42 |
| - border-style: solid; |
43 |
| - border-width: var(--border-width-input-field); |
44 |
| - color: var(--color-form-text); |
45 |
| - font-size: var(--font-size-input-fields); |
46 |
| - line-height: var(--form-line-height); |
47 |
| - max-width: 100%; |
48 |
| - min-width: 0; |
49 |
| - padding-bottom: var(--form-padding-vertical); |
50 |
| - padding-left: var(--form-padding-horizontal); |
51 |
| - padding-right: var(--form-padding-horizontal); |
52 |
| - padding-top: var(--form-padding-vertical); |
53 |
| - text-indent: 1px; |
54 |
| - transition: none; |
55 |
| - width: 100%; |
56 |
| -} |
57 |
| - |
58 | 32 | // Labels
|
59 | 33 | legend,
|
60 | 34 | label {
|
@@ -109,108 +83,98 @@ input[type="search"] {
|
109 | 83 | }
|
110 | 84 | }
|
111 | 85 |
|
112 |
| -// Radio buttons and checkboxes |
113 |
| -input[type="radio"], |
114 |
| -input[type="checkbox"] { |
| 86 | +// Select drop downs |
| 87 | +select { |
| 88 | + // doiuse-disable |
| 89 | + appearance: none; |
| 90 | + background-image: url('data:image/svg+xml, %3Csvg width="12" height="9" viewBox="0 0 12 9" fill="none" xmlns="http://www.w3.org/2000/svg"%3E%3Cpath d="M2.049 1.552L6.22 6.268a.188.188 0 00.28 0l4.173-4.716" stroke="%23212121" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/%3E%3Cdefs%3E%3Cpath fill="none" transform="translate(.861 .45)" d="M0 0h10.544v7.95H0z"/%3E%3C/defs%3E%3C/svg%3E%0A'); |
| 91 | + background-position: right var(--gap-select-icon) center; |
| 92 | + background-repeat: no-repeat; |
| 93 | + background-size: 11px auto; |
| 94 | + border-color: var(--color-border-forms); |
| 95 | + border-radius: var(--border-radius-select); |
| 96 | + border-style: solid; |
| 97 | + border-width: var(--border-width-input-field); |
| 98 | + color: var(--color-form-text); |
115 | 99 | font-size: var(--font-size-input-fields);
|
116 |
| - height: var(--size-radio-button); |
117 |
| - margin: 0; |
118 |
| - margin-top: calc((1em * var(--line-height-checkbox) - var(--size-radio-button)) / 2); |
119 |
| - opacity: 0; |
120 |
| - padding: 0; |
121 |
| - pointer-events: none; |
122 |
| - // Hide native buttons |
123 |
| - position: absolute; |
124 |
| - width: var(--size-radio-button); |
125 |
| -} |
126 |
| - |
127 |
| -// Labels for radio buttons and checkboxes |
128 |
| -input[type="radio"] + label, |
129 |
| -input[type="checkbox"] + label { |
130 |
| - align-items: flex-start; |
131 |
| - cursor: pointer; |
132 |
| - display: inline-flex; |
133 |
| - line-height: var(--line-height-checkbox); |
| 100 | + line-height: var(--form-line-height); |
| 101 | + max-width: 100%; |
| 102 | + min-width: 0; |
| 103 | + padding-bottom: var(--form-padding-vertical); |
| 104 | + padding-left: var(--form-padding-horizontal); |
| 105 | + padding-right: var(--form-padding-horizontal); |
| 106 | + padding-top: var(--form-padding-vertical); |
| 107 | + text-indent: 1px; |
| 108 | + transition: none; |
| 109 | + width: 100%; |
134 | 110 | }
|
135 | 111 |
|
136 |
| -// Custom buttons - basic style |
137 |
| -input[type="radio"] + label::before, |
138 |
| -input[type="checkbox"] + label::before { |
139 |
| - align-self: center; |
140 |
| - background-color: var(--color-white); |
141 |
| - background-position: center; |
142 |
| - background-repeat: no-repeat; |
143 |
| - border-color: var(--color-checkbox); |
144 |
| - border-style: solid; |
145 |
| - border-width: var(--border-width-checkbox); |
146 |
| - content: ''; |
147 |
| - display: inline-flex; |
148 |
| - flex-shrink: 0; |
149 |
| - height: var(--size-radio-button); |
150 |
| - margin-right: var(--gap-checkbox); |
151 |
| - position: relative; |
152 |
| - top: calc(var(--border-width-checkbox) / 2); |
153 |
| - transition: transform .2s, border .2s; |
154 |
| - width: var(--size-radio-button); |
| 112 | +// Checkboxes & radio buttons |
| 113 | +// Learn about this technique: |
| 114 | +// @link https://moderncss.dev/pure-css-custom-checkbox-style/ |
| 115 | +input[type="radio"], |
| 116 | +input[type="checkbox"] { |
| 117 | + appearance: none; |
| 118 | + background-color: var(--color-background-input-field); |
| 119 | + border: 1px solid var(--color-border-forms); |
| 120 | + color: currentColor; |
| 121 | + display: grid; |
| 122 | + // stylelint-disable-next-line property-disallowed-list |
| 123 | + font: inherit; |
| 124 | + height: var(--size-checkbox); |
| 125 | + margin: 0; |
| 126 | + place-content: center; |
| 127 | + width: var(--size-checkbox); |
155 | 128 | }
|
156 | 129 |
|
157 |
| -// Radio only style |
158 |
| -input[type="radio"] + label::before { |
| 130 | +// Round style radio buttons |
| 131 | +input[type="radio"]::before, |
| 132 | +input[type="radio"] { |
159 | 133 | border-radius: 50%;
|
160 | 134 | }
|
161 | 135 |
|
162 |
| -// Checkbox only style |
163 |
| -input[type="checkbox"] + label::before { |
| 136 | +// Square style checkboxes |
| 137 | +input[type="checkbox"]::before, |
| 138 | +input[type="checkbox"] { |
164 | 139 | border-radius: var(--border-radius-checkbox);
|
165 | 140 | }
|
166 | 141 |
|
167 |
| -// Radio button and checkbox checked states |
168 |
| -input[type="radio"]:checked + label::before, |
169 |
| -input[type="checkbox"]:checked + label::before { |
170 |
| - background-color: var(--color-checkbox); |
171 |
| - border-color: var(--color-checkbox); |
172 |
| - box-shadow: none; |
173 |
| - transition: transform .2s; |
174 |
| -} |
175 |
| - |
176 |
| -// Radio button and checkbox active states |
177 |
| -input[type="radio"]:active + label::before, |
178 |
| -input[type="checkbox"]:active + label::before { |
| 142 | +input[type="radio"]::before, |
| 143 | +input[type="checkbox"]::before { |
| 144 | + background-color: var(--color-checkbox-checked); |
| 145 | + // Change checkbox color by changing 7effe1 to something else below |
| 146 | + background-image: url('data:image/svg+xml, %3Csvg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" heighg="16"%3E%3Cg class="nc-icon-wrapper" stroke-width="3" fill="%237effe1" stroke="%237effe1"%3E%3Cpolyline fill="none" stroke="%237effe1" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" points="1, 9 5, 13 15, 3" data-cap="butt"%3E%3C/polyline%3E%3C/g%3E%3C/svg%3E%0A'); |
| 147 | + background-position: center; |
| 148 | + background-size: var(--size-checkbox-marker) var(--size-checkbox-marker); |
| 149 | + border: 1px solid var(--color-checkbox-checked); |
| 150 | + content: ''; |
| 151 | + height: var(--size-checkbox); |
| 152 | + opacity: 0; |
179 | 153 | transform: scale(.8);
|
180 | 154 | transition: transform .2s;
|
| 155 | + width: var(--size-checkbox); |
181 | 156 | }
|
182 | 157 |
|
183 |
| -// Radio button icon |
184 |
| -input[type="radio"]:checked + label::before { |
185 |
| - background-image: url("data:image/svg+xml;charset=utf8, %3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cg class='nc-icon-wrapper' fill='%23ffffff'%3E%3Ccircle cx='8' cy='8' r='8' fill='%23ffffff'%3E%3C/circle%3E%3C/g%3E%3C/svg%3E"); |
186 |
| - background-size: var(--size-radio-button-marker); |
187 |
| -} |
188 |
| - |
189 |
| -// Checkbox button icon |
190 |
| -input[type="checkbox"]:checked + label::before { |
191 |
| - background-image: url("data:image/svg+xml, %3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpolyline points='1 6.5 4 9.5 11 2.5' fill='none' stroke='%23FFFFFF' stroke-linecap='round' stroke-linejoin='round' stroke-width='2'/%3E%3C/svg%3E"); |
192 |
| - background-size: var(--size-checkbox-marker); |
| 158 | +input[type="radio"]:checked::before, |
| 159 | +input[type="checkbox"]:checked::before { |
| 160 | + opacity: 1; |
| 161 | + transform: scale(1); |
193 | 162 | }
|
194 | 163 |
|
195 |
| -// Radio button and checkbox focus states |
196 |
| -input[type="radio"]:focus + label::before, |
197 |
| -input[type="checkbox"]:focus + label::before, |
198 |
| -input[type="radio"]:checked:active + label::before, |
199 |
| -input[type="checkbox"]:checked:active + label::before { |
200 |
| - border-color: var(--color-checkbox); |
201 |
| - box-shadow: var(--color-checkbox-outline); |
| 164 | +input[type="radio"]:checked, |
| 165 | +input[type="checkbox"]:checked { |
| 166 | + // Hide element visually on click so it creates a bouncy animation illusion |
| 167 | + background-color: transparent; |
| 168 | + border-color: transparent; |
202 | 169 | }
|
203 | 170 |
|
204 |
| -// Radio button and checkbox checked + active states |
205 |
| -input[type="radio"]:checked:active + label::before, |
206 |
| -input[type="checkbox"]:checked:active + label::before { |
207 |
| - transform: none; |
208 |
| - transition: none; |
209 |
| -} |
210 |
| - |
211 |
| -// Radio button and checkbox hovers |
212 |
| -// stylelint-disable-next-line selector-max-pseudo-class |
213 |
| -input[type="radio"]:not(:checked):not(:focus) + label:hover::before, |
214 |
| -input[type="checkbox"]:not(:checked):not(:focus) + label:hover::before { |
215 |
| - border-color: var(--color-checkbox-border-hover); |
| 171 | +input[type="radio"]:hover, |
| 172 | +input[type="radio"] + label:hover, |
| 173 | +input[type="radio"]:focus, |
| 174 | +input[type="radio"] + label:focus, |
| 175 | +input[type="checkbox"]:hover, |
| 176 | +input[type="checkbox"] + label:hover, |
| 177 | +input[type="checkbox"]:focus, |
| 178 | +input[type="checkbox"] + label:focus { |
| 179 | + cursor: pointer; |
216 | 180 | }
|
0 commit comments