|
1 | 1 | /* radio buttons */ |
2 | 2 |
|
3 | 3 | .radio { |
4 | | - position: relative; |
| 4 | + display: block; |
| 5 | + min-height: 1.5rem; |
| 6 | + padding-inline-start: var(--hiq-radio-label-padding-horizontal); |
| 7 | + margin-bottom: var(--hiq-radio-margin-bottom); |
5 | 8 |
|
6 | 9 | & label { |
7 | | - position: relative; |
8 | | - margin-bottom: var(--hiq-radio-margin-bottom); |
9 | | - padding: 0 var(--hiq-radio-label-padding-horizontal); |
10 | | - font-weight: var(--hiq-radio-label-font-weight) !important; |
11 | | - line-height: 1; |
12 | | - cursor: pointer; |
13 | | - user-select: none; |
| 10 | + display: inline-block; |
| 11 | + margin-bottom: 0; |
| 12 | + font-weight: var(--hiq-radio-label-font-weight); |
| 13 | + } |
14 | 14 |
|
15 | | - /* style `::before` to look like radio button */ |
16 | | - &::before { |
17 | | - display: block; |
18 | | - position: absolute; |
19 | | - top: 0; |
20 | | - left: 0; |
21 | | - width: var(--hiq-radio-width); |
22 | | - height: var(--hiq-radio-height); |
23 | | - border: var(--hiq-radio-border-width) solid var(--hiq-radio-border-color); |
24 | | - border-radius: var(--hiq-radio-border-radius); |
25 | | - background-color: var(--hiq-radio-background-color); |
26 | | - transition: background-color var(--hiq-speed) var(--hiq-easing); |
27 | | - content: ''; |
28 | | - } |
| 15 | + input { |
| 16 | + width: var(--hiq-radio-width); |
| 17 | + height: var(--hiq-radio-height); |
| 18 | + margin-top: .25em; |
| 19 | + margin-inline-start: -1.5em; |
| 20 | + vertical-align: top; |
| 21 | + background-color: var(--hiq-radio-background-color); |
| 22 | + background-repeat: no-repeat; |
| 23 | + background-position: center; |
| 24 | + background-size: contain; |
| 25 | + appearance: none; |
29 | 26 | } |
30 | 27 |
|
31 | | - /* visually hide input */ |
32 | 28 | & input[type='radio'] { |
33 | | - position: absolute; |
34 | | - top: 0; |
35 | | - left: 0; |
36 | | - width: 0; |
37 | | - height: 0; |
38 | | - opacity: 0; |
39 | | - pointer-events: none; |
40 | | - |
41 | | - &:hover + label::before { |
42 | | - background-color: var(--hiq-radio-hover-background-color); |
43 | | - } |
44 | | - |
45 | | - &:focus + label::before { |
46 | | - background-color: var(--hiq-radio-focus-background-color); |
47 | | - outline: var(--hiq-outline-color) solid var(--hiq-outline-width); |
48 | | - } |
| 29 | + border-radius: var(--hiq-radio-border-radius); |
49 | 30 |
|
50 | | - &:checked + label::before, |
51 | | - &[aria-checked] + label::before { |
52 | | - border-color: var(--hiq-radio-checked-border-color); |
| 31 | + &:checked { |
| 32 | + background-image: var(--hiq-radio-background-image); |
53 | 33 | background-color: var(--hiq-radio-checked-background-color); |
| 34 | + border-color: var(--hiq-radio-checked-border-color); |
54 | 35 | } |
55 | 36 |
|
56 | | - /* style `::after` to look like radio button fill */ |
57 | | - &:checked + label::after, |
58 | | - &[aria-checked] + label::after { |
59 | | - display: block; |
60 | | - position: absolute; |
61 | | - top: 50%; |
62 | | - left: calc(var(--hiq-radio-width) / 2); |
63 | | - width: var(--hiq-radio-check-width); |
64 | | - height: var(--hiq-radio-check-height); |
65 | | - border-radius: var(--hiq-radio-check-border-radius); |
66 | | - background-color: var(--hiq-radio-check-background-color); |
67 | | - transform: translate(-50%, -50%); |
68 | | - content: ''; |
| 37 | + &:focus { |
| 38 | + outline: var(--hiq-outline-color) solid var(--hiq-outline-width); |
69 | 39 | } |
70 | 40 |
|
71 | 41 | :--not-writable + label { |
|
77 | 47 | cursor: not-allowed; |
78 | 48 | } |
79 | 49 |
|
80 | | - :--not-writable + label::before { |
| 50 | + :--not-writable { |
81 | 51 | background-color: var(--hiq-disabled-background-color); |
82 | 52 | } |
83 | 53 | } |
|
0 commit comments