diff options
Diffstat (limited to 'src/objects/_radio.scss')
-rw-r--r-- | src/objects/_radio.scss | 118 |
1 files changed, 43 insertions, 75 deletions
diff --git a/src/objects/_radio.scss b/src/objects/_radio.scss index ad3e8d4..c1182d0 100644 --- a/src/objects/_radio.scss +++ b/src/objects/_radio.scss | |||
@@ -1,88 +1,51 @@ | |||
1 | @use 'sass:meta'; | ||
1 | @use 'iro-sass/src/iro-sass' as iro; | 2 | @use 'iro-sass/src/iro-sass' as iro; |
2 | @use '../functions' as fn; | 3 | @use '../props'; |
4 | @use '../core.vars' as core; | ||
3 | 5 | ||
4 | @include iro.props-namespace('radio') { | 6 | @forward 'radio.vars'; |
5 | @include iro.props-store(( | 7 | @use 'radio.vars' as vars; |
6 | --dims: ( | ||
7 | --diameter: fn.global-dim(--size --200), | ||
8 | --label-gap: fn.global-dim(--size --125), | ||
9 | --border: fn.global-dim(--border --medium), | ||
10 | --pad-i: fn.global-dim(--size --65), | ||
11 | --pad-b: fn.global-dim(--size --65), | ||
12 | --rounding: fn.global-dim(--rounding), | ||
13 | --spacing-sibling: fn.global-dim(--size --300), | ||
14 | 8 | ||
15 | --key-focus: ( | 9 | @mixin styles { |
16 | --border: fn.global-dim(--key-focus --border), | 10 | @include props.materialize(meta.module-variables('vars')); |
17 | --border-offset: fn.global-dim(--key-focus --border-offset), | ||
18 | --outline: fn.global-dim(--key-focus --outline), | ||
19 | ), | ||
20 | ), | ||
21 | --colors: ( | ||
22 | --circle-border: fn.global-color(--text-mute-more), | ||
23 | --circle-bg: fn.global-color(--base --75), | ||
24 | |||
25 | --hover: ( | ||
26 | --label: fn.global-color(--heading), | ||
27 | --circle-border: fn.global-color(--text-mute), | ||
28 | ), | ||
29 | --accent: ( | ||
30 | --circle-border: fn.global-color(--accent --900), | ||
31 | |||
32 | --hover: ( | ||
33 | --circle-border: fn.global-color(--accent --1000), | ||
34 | ), | ||
35 | ), | ||
36 | --disabled: ( | ||
37 | --label: fn.global-color(--text-disabled), | ||
38 | --circle-border: fn.global-color(--border-strong), | ||
39 | --circle-bg: fn.global-color(--base --75), | ||
40 | ), | ||
41 | --key-focus: ( | ||
42 | --label: fn.global-color(--focus --text), | ||
43 | --border: fn.global-color(--focus --border), | ||
44 | --outline: fn.global-color(--focus --outline), | ||
45 | ), | ||
46 | ), | ||
47 | )); | ||
48 | 11 | ||
49 | @include iro.bem-object(iro.props-namespace()) { | 12 | @include iro.bem-object('radio') { |
50 | position: relative; | 13 | position: relative; |
51 | display: inline-block; | 14 | display: inline-block; |
52 | padding-block: fn.dim(--pad-b); | 15 | padding-block: props.get(vars.$pad-b); |
53 | padding-inline: fn.dim(--pad-i); | 16 | padding-inline: props.get(vars.$pad-i); |
54 | margin-inline: | 17 | margin-inline: |
55 | calc(-1 * fn.dim(--pad-i) - fn.dim(--key-focus --border-offset)) | 18 | calc(-1 * props.get(vars.$pad-i) - props.get(vars.$key-focus--border-offset)) |
56 | calc(fn.dim(--spacing-sibling) - fn.dim(--pad-i) - fn.dim(--key-focus --border-offset)); | 19 | calc(props.get(vars.$spacing-sibling) - props.get(vars.$pad-i) - props.get(vars.$key-focus--border-offset)); |
57 | 20 | ||
58 | @include iro.bem-elem('circle') { | 21 | @include iro.bem-elem('circle') { |
59 | display: inline-block; | 22 | display: inline-block; |
60 | flex: 0 0 auto; | 23 | flex: 0 0 auto; |
61 | inline-size: fn.dim(--diameter); | 24 | inline-size: props.get(vars.$diameter); |
62 | block-size: fn.dim(--diameter); | 25 | block-size: props.get(vars.$diameter); |
63 | margin-block-start: calc(.5em * fn.global-dim(--font --standard --line-height) - .5 * fn.dim(--diameter) - fn.dim(--key-focus --border-offset)); | 26 | margin-block-start: calc(.5em * props.get(core.$font--standard--line-height) - .5 * props.get(vars.$diameter) - props.get(vars.$key-focus--border-offset)); |
64 | vertical-align: top; | 27 | vertical-align: top; |
65 | background-color: fn.color(--circle-border); | 28 | background-color: props.get(vars.$circle-border-color); |
66 | background-clip: padding-box; | 29 | background-clip: padding-box; |
67 | border: fn.dim(--key-focus --border-offset) solid transparent; | 30 | border: props.get(vars.$key-focus--border-offset) solid transparent; |
68 | border-radius: 2em; | 31 | border-radius: 2em; |
69 | 32 | ||
70 | &::after { | 33 | &::after { |
71 | position: relative; | 34 | position: relative; |
72 | inset-block-start: fn.dim(--border); | 35 | inset-block-start: props.get(vars.$border-width); |
73 | inset-inline-start: fn.dim(--border); | 36 | inset-inline-start: props.get(vars.$border-width); |
74 | display: block; | 37 | display: block; |
75 | inline-size: calc(fn.dim(--diameter) - 2 * fn.dim(--border)); | 38 | inline-size: calc(props.get(vars.$diameter) - 2 * props.get(vars.$border-width)); |
76 | block-size: calc(fn.dim(--diameter) - 2 * fn.dim(--border)); | 39 | block-size: calc(props.get(vars.$diameter) - 2 * props.get(vars.$border-width)); |
77 | content: ''; | 40 | content: ''; |
78 | background-color: fn.color(--circle-bg); | 41 | background-color: props.get(vars.$circle-bg-color); |
79 | border-radius: fn.dim(--diameter); | 42 | border-radius: props.get(vars.$diameter); |
80 | transition: transform .2s ease; | 43 | transition: transform .2s ease; |
81 | } | 44 | } |
82 | } | 45 | } |
83 | 46 | ||
84 | @include iro.bem-elem('label') { | 47 | @include iro.bem-elem('label') { |
85 | margin-inline-start: calc(fn.dim(--label-gap) - fn.dim(--key-focus --border-offset)); | 48 | margin-inline-start: calc(props.get(vars.$label-gap) - props.get(vars.$key-focus--border-offset)); |
86 | } | 49 | } |
87 | 50 | ||
88 | @include iro.bem-elem('native') { | 51 | @include iro.bem-elem('native') { |
@@ -96,16 +59,16 @@ | |||
96 | margin: 0; | 59 | margin: 0; |
97 | overflow: hidden; | 60 | overflow: hidden; |
98 | appearance: none; | 61 | appearance: none; |
99 | border-radius: fn.dim(--rounding); | 62 | border-radius: props.get(vars.$rounding); |
100 | 63 | ||
101 | &:hover, | 64 | &:hover, |
102 | &:focus-visible { | 65 | &:focus-visible { |
103 | @include iro.bem-sibling-elem('label') { | 66 | @include iro.bem-sibling-elem('label') { |
104 | color: fn.color(--hover --label); | 67 | color: props.get(vars.$hover--label-color); |
105 | } | 68 | } |
106 | 69 | ||
107 | @include iro.bem-sibling-elem('circle') { | 70 | @include iro.bem-sibling-elem('circle') { |
108 | background-color: fn.color(--hover --circle-border); | 71 | background-color: props.get(vars.$hover--circle-border-color); |
109 | } | 72 | } |
110 | } | 73 | } |
111 | 74 | ||
@@ -119,26 +82,31 @@ | |||
119 | 82 | ||
120 | &:disabled { | 83 | &:disabled { |
121 | @include iro.bem-sibling-elem('label') { | 84 | @include iro.bem-sibling-elem('label') { |
122 | color: fn.color(--disabled --label); | 85 | color: props.get(vars.$disabled--label-color); |
123 | } | 86 | } |
124 | 87 | ||
125 | @include iro.bem-sibling-elem('circle') { | 88 | @include iro.bem-sibling-elem('circle') { |
126 | background-color: fn.color(--disabled --circle-border); | 89 | background-color: props.get(vars.$disabled--circle-border-color); |
127 | 90 | ||
128 | &::after { | 91 | &::after { |
129 | background-color: fn.color(--disabled --circle-bg); | 92 | background-color: props.get(vars.$disabled--circle-bg-color); |
130 | } | 93 | } |
131 | } | 94 | } |
132 | } | 95 | } |
133 | 96 | ||
134 | &:focus-visible { | 97 | &:focus-visible { |
135 | @include iro.bem-sibling-elem('label') { | 98 | @include iro.bem-sibling-elem('label') { |
136 | color: fn.color(--key-focus --label); | 99 | color: props.get(vars.$key-focus--label-color); |
137 | } | 100 | } |
138 | 101 | ||
139 | @include iro.bem-sibling-elem('circle') { | 102 | @include iro.bem-sibling-elem('circle') { |
140 | outline: fn.color(--key-focus --border) solid fn.dim(--key-focus --border); | 103 | outline: props.get(vars.$key-focus--border-color) solid props.get(vars.$key-focus--border-width); |
141 | box-shadow: 0 0 0 calc(fn.dim(--key-focus --border) + fn.dim(--key-focus --outline)) fn.color(--key-focus --outline); | 104 | box-shadow: |
105 | 0 | ||
106 | 0 | ||
107 | 0 | ||
108 | calc(props.get(vars.$key-focus--border-width) + props.get(vars.$key-focus--outline-width)) | ||
109 | props.get(vars.$key-focus--outline-color); | ||
142 | } | 110 | } |
143 | } | 111 | } |
144 | } | 112 | } |
@@ -153,29 +121,29 @@ | |||
153 | @include iro.bem-elem('native') { | 121 | @include iro.bem-elem('native') { |
154 | &:checked { | 122 | &:checked { |
155 | @include iro.bem-sibling-elem('circle') { | 123 | @include iro.bem-sibling-elem('circle') { |
156 | background-color: fn.color(--accent --circle-border); | 124 | background-color: props.get(vars.$accent--circle-border-color); |
157 | } | 125 | } |
158 | 126 | ||
159 | &:hover, | 127 | &:hover, |
160 | &:focus-visible { | 128 | &:focus-visible { |
161 | @include iro.bem-sibling-elem('circle') { | 129 | @include iro.bem-sibling-elem('circle') { |
162 | background-color: fn.color(--accent --hover --circle-border); | 130 | background-color: props.get(vars.$accent--hover--circle-border-color); |
163 | } | 131 | } |
164 | } | 132 | } |
165 | } | 133 | } |
166 | 134 | ||
167 | &:disabled { | 135 | &:disabled { |
168 | @include iro.bem-sibling-elem('circle') { | 136 | @include iro.bem-sibling-elem('circle') { |
169 | background-color: fn.color(--disabled --circle-border); | 137 | background-color: props.get(vars.$disabled--circle-border-color); |
170 | 138 | ||
171 | &::after { | 139 | &::after { |
172 | background-color: fn.color(--disabled --circle-bg); | 140 | background-color: props.get(vars.$disabled--circle-bg-color); |
173 | } | 141 | } |
174 | } | 142 | } |
175 | 143 | ||
176 | &:checked { | 144 | &:checked { |
177 | @include iro.bem-sibling-elem('circle') { | 145 | @include iro.bem-sibling-elem('circle') { |
178 | background-color: fn.color(--disabled --circle-border); | 146 | background-color: props.get(vars.$disabled--circle-border-color); |
179 | } | 147 | } |
180 | } | 148 | } |
181 | } | 149 | } |