diff options
author | Volpeon <git@volpeon.ink> | 2022-02-06 17:17:33 +0100 |
---|---|---|
committer | Volpeon <git@volpeon.ink> | 2022-02-06 17:17:33 +0100 |
commit | 3524f1bac11c8a9d1640bfeac5ceb063ff96d623 (patch) | |
tree | 52907b3161045c2d24bba18442c1ece9c12986a6 /src/objects/_checkbox.scss | |
parent | Updated action button (diff) | |
download | iro-design-3524f1bac11c8a9d1640bfeac5ceb063ff96d623.tar.gz iro-design-3524f1bac11c8a9d1640bfeac5ceb063ff96d623.tar.bz2 iro-design-3524f1bac11c8a9d1640bfeac5ceb063ff96d623.zip |
Improved variable structure
Diffstat (limited to 'src/objects/_checkbox.scss')
-rw-r--r-- | src/objects/_checkbox.scss | 112 |
1 files changed, 58 insertions, 54 deletions
diff --git a/src/objects/_checkbox.scss b/src/objects/_checkbox.scss index 587321b..360fa1d 100644 --- a/src/objects/_checkbox.scss +++ b/src/objects/_checkbox.scss | |||
@@ -1,60 +1,64 @@ | |||
1 | @use 'iro-sass/src/index' as iro; | 1 | @use 'iro-sass/src/index' as iro; |
2 | @use '../functions' as fn; | ||
2 | 3 | ||
3 | @include iro.props-namespace('checkbox') { | 4 | @include iro.props-namespace('checkbox') { |
4 | @include iro.props-store(( | 5 | @include iro.props-store(( |
5 | --dims: ( | 6 | --dims: ( |
6 | --size: iro.fn-px-to-rem(14px), | 7 | --size: iro.fn-px-to-rem(14px), |
7 | --label-gap: .6rem, | 8 | --label-gap: .6rem, |
8 | --border-width: iro.props-get(--dims --border-width --medium, $global: true), | 9 | --border-width: fn.dim(--border-width --medium, $global: true), |
9 | --padding-x: .3rem, | 10 | --padding-x: .3rem, |
10 | --padding-y: .3rem, | 11 | --padding-y: .3rem, |
11 | --margin-right: iro.props-get(--dims --spacing --x --md, $global: true), | 12 | --margin-right: fn.dim(--spacing --x --md, $global: true), |
12 | ), | 13 | ), |
14 | ), 'dims'); | ||
15 | |||
16 | @include iro.props-store(( | ||
13 | --colors: ( | 17 | --colors: ( |
14 | --box-border: iro.props-get(--colors --fg-hi, $global: true), | 18 | --box-border: fn.color(--fg-hi, $global: true), |
15 | --box-bg: iro.props-get(--colors --bg-hi, $global: true), | 19 | --box-bg: fn.color(--bg-hi, $global: true), |
16 | 20 | ||
17 | --hover: ( | 21 | --hover: ( |
18 | --label: iro.props-get(--colors --fg-lo, $global: true), | 22 | --label: fn.color(--fg-lo, $global: true), |
19 | --box-border: iro.props-get(--colors --fg, $global: true), | 23 | --box-border: fn.color(--fg, $global: true), |
20 | ), | 24 | ), |
21 | --accent: ( | 25 | --accent: ( |
22 | --box-border: iro.props-get(--colors --accent --primary, $global: true), | 26 | --box-border: fn.color(--accent --primary, $global: true), |
23 | 27 | ||
24 | --hover: ( | 28 | --hover: ( |
25 | --box-border: iro.props-get(--colors --accent --primary-lo, $global: true), | 29 | --box-border: fn.color(--accent --primary-lo, $global: true), |
26 | ), | 30 | ), |
27 | ), | 31 | ), |
28 | --key-focus: ( | 32 | --key-focus: ( |
29 | --label: iro.props-get(--colors --focus --text, $global: true), | 33 | --label: fn.color(--focus --text, $global: true), |
30 | --box-border: iro.props-get(--colors --focus --fill, $global: true), | 34 | --box-border: fn.color(--focus --fill, $global: true), |
31 | --shadow: iro.props-get(--colors --focus --shadow, $global: true), | 35 | --shadow: fn.color(--focus --shadow, $global: true), |
32 | ), | 36 | ), |
33 | --disabled: ( | 37 | --disabled: ( |
34 | --label: iro.props-get(--colors --fg-hi3, $global: true), | 38 | --label: fn.color(--fg-hi3, $global: true), |
35 | --box-border: iro.props-get(--colors --obj-lo, $global: true), | 39 | --box-border: fn.color(--obj-lo, $global: true), |
36 | --box-bg: iro.props-get(--colors --bg-hi, $global: true), | 40 | --box-bg: fn.color(--bg-hi, $global: true), |
37 | ) | 41 | ) |
38 | ), | 42 | ), |
39 | )); | 43 | ), 'colors'); |
40 | 44 | ||
41 | @include iro.bem-object(iro.props-namespace()) { | 45 | @include iro.bem-object(iro.props-namespace()) { |
42 | display: inline-flex; | 46 | display: inline-flex; |
43 | position: relative; | 47 | position: relative; |
44 | align-items: flex-start; | 48 | align-items: flex-start; |
45 | margin-right: calc(-1 * #{iro.props-get(--dims --padding-x)} + #{iro.props-get(--dims --margin-right)}); | 49 | margin-right: calc(-1 * #{fn.dim(--padding-x)} + #{fn.dim(--margin-right)}); |
46 | margin-left: calc(-1 * #{iro.props-get(--dims --padding-x)}); | 50 | margin-left: calc(-1 * #{fn.dim(--padding-x)}); |
47 | padding: iro.props-get(--dims --padding-y) iro.props-get(--dims --padding-x); // sass-lint:disable-line shorthand-values | 51 | padding: fn.dim(--padding-y) fn.dim(--padding-x); // sass-lint:disable-line shorthand-values |
48 | 52 | ||
49 | @include iro.bem-elem('box') { | 53 | @include iro.bem-elem('box') { |
50 | display: block; | 54 | display: block; |
51 | position: relative; | 55 | position: relative; |
52 | flex: 0 0 auto; | 56 | flex: 0 0 auto; |
53 | width: iro.props-get(--dims --size); | 57 | width: fn.dim(--size); |
54 | height: iro.props-get(--dims --size); | 58 | height: fn.dim(--size); |
55 | margin-top: calc(.5 * (#{$line-height * 1em} - #{iro.props-get(--dims --size)})); | 59 | margin-top: calc(.5 * (#{$line-height * 1em} - #{fn.dim(--size)})); |
56 | border-radius: iro.props-get(--dims --border-width); | 60 | border-radius: fn.dim(--border-width); |
57 | background-color: iro.props-get(--colors --box-border); | 61 | background-color: fn.color(--box-border); |
58 | 62 | ||
59 | &::before, | 63 | &::before, |
60 | &::after { | 64 | &::after { |
@@ -65,27 +69,27 @@ | |||
65 | 69 | ||
66 | &::before { | 70 | &::before { |
67 | z-index: 2; | 71 | z-index: 2; |
68 | top: iro.props-get(--dims --border-width); | 72 | top: fn.dim(--border-width); |
69 | left: iro.props-get(--dims --border-width); | 73 | left: fn.dim(--border-width); |
70 | width: calc(iro.props-get(--dims --size) - 2 * iro.props-get(--dims --border-width)); | 74 | width: calc(fn.dim(--size) - 2 * fn.dim(--border-width)); |
71 | height: calc(iro.props-get(--dims --size) - 2 * iro.props-get(--dims --border-width)); | 75 | height: calc(fn.dim(--size) - 2 * fn.dim(--border-width)); |
72 | transition: transform .2s ease; | 76 | transition: transform .2s ease; |
73 | background-color: iro.props-get(--colors --box-bg); | 77 | background-color: fn.color(--box-bg); |
74 | } | 78 | } |
75 | 79 | ||
76 | &::after { | 80 | &::after { |
77 | z-index: 3; | 81 | z-index: 3; |
78 | top: calc(.5 * #{iro.props-get(--dims --size)} - 1px); | 82 | top: calc(.5 * #{fn.dim(--size)} - 1px); |
79 | left: calc(1.5 * #{iro.props-get(--dims --border-width)}); | 83 | left: calc(1.5 * #{fn.dim(--border-width)}); |
80 | box-sizing: border-box; | 84 | box-sizing: border-box; |
81 | width: calc(iro.props-get(--dims --size) - 3 * iro.props-get(--dims --border-width)); | 85 | width: calc(fn.dim(--size) - 3 * fn.dim(--border-width)); |
82 | height: 0; | 86 | height: 0; |
83 | transform: scale(0); | 87 | transform: scale(0); |
84 | transition: transform .2s ease; | 88 | transition: transform .2s ease; |
85 | border-width: 0 2px 2px 0; | 89 | border-width: 0 2px 2px 0; |
86 | border-style: solid; | 90 | border-style: solid; |
87 | border-radius: 2px; | 91 | border-radius: 2px; |
88 | border-color: iro.props-get(--colors --box-bg); | 92 | border-color: fn.color(--box-bg); |
89 | } | 93 | } |
90 | } | 94 | } |
91 | 95 | ||
@@ -93,20 +97,20 @@ | |||
93 | display: block; | 97 | display: block; |
94 | position: absolute; | 98 | position: absolute; |
95 | z-index: 2; | 99 | z-index: 2; |
96 | top: calc(1 * iro.props-get(--dims --border-width)); | 100 | top: calc(1 * fn.dim(--border-width)); |
97 | left: calc(1 * iro.props-get(--dims --border-width)); | 101 | left: calc(1 * fn.dim(--border-width)); |
98 | width: calc(100% - 2 * iro.props-get(--dims --border-width)); | 102 | width: calc(100% - 2 * fn.dim(--border-width)); |
99 | height: calc(100% - 2 * iro.props-get(--dims --border-width)); | 103 | height: calc(100% - 2 * fn.dim(--border-width)); |
100 | transform: scale(0); | 104 | transform: scale(0); |
101 | transform-origin: 40% 90%; | 105 | transform-origin: 40% 90%; |
102 | transition: transform .2s ease; | 106 | transition: transform .2s ease; |
103 | stroke-width: iro.fn-px-to-rem(3px); | 107 | stroke-width: iro.fn-px-to-rem(3px); |
104 | color: iro.props-get(--colors --box-bg); | 108 | color: fn.color(--box-bg); |
105 | } | 109 | } |
106 | 110 | ||
107 | @include iro.bem-elem('label') { | 111 | @include iro.bem-elem('label') { |
108 | align-self: baseline; | 112 | align-self: baseline; |
109 | margin-left: iro.props-get(--dims --label-gap); | 113 | margin-left: fn.dim(--label-gap); |
110 | } | 114 | } |
111 | 115 | ||
112 | @include iro.bem-elem('native') { | 116 | @include iro.bem-elem('native') { |
@@ -122,11 +126,11 @@ | |||
122 | 126 | ||
123 | &:hover { | 127 | &:hover { |
124 | @include iro.bem-sibling-elem('label') { | 128 | @include iro.bem-sibling-elem('label') { |
125 | color: iro.props-get(--colors --hover --label); | 129 | color: fn.color(--hover --label); |
126 | } | 130 | } |
127 | 131 | ||
128 | @include iro.bem-sibling-elem('box') { | 132 | @include iro.bem-sibling-elem('box') { |
129 | background-color: iro.props-get(--colors --hover --box-border); | 133 | background-color: fn.color(--hover --box-border); |
130 | } | 134 | } |
131 | } | 135 | } |
132 | 136 | ||
@@ -160,14 +164,14 @@ | |||
160 | 164 | ||
161 | &:disabled { | 165 | &:disabled { |
162 | @include iro.bem-sibling-elem('label') { | 166 | @include iro.bem-sibling-elem('label') { |
163 | color: iro.props-get(--colors --disabled --label); | 167 | color: fn.color(--disabled --label); |
164 | } | 168 | } |
165 | 169 | ||
166 | @include iro.bem-sibling-elem('box') { | 170 | @include iro.bem-sibling-elem('box') { |
167 | background-color: iro.props-get(--colors --disabled --box-border); | 171 | background-color: fn.color(--disabled --box-border); |
168 | 172 | ||
169 | &::before { | 173 | &::before { |
170 | background-color: iro.props-get(--colors --disabled --box-bg); | 174 | background-color: fn.color(--disabled --box-bg); |
171 | } | 175 | } |
172 | } | 176 | } |
173 | } | 177 | } |
@@ -175,12 +179,12 @@ | |||
175 | @include iro.bem-at-theme('keyboard') { | 179 | @include iro.bem-at-theme('keyboard') { |
176 | &:focus { | 180 | &:focus { |
177 | @include iro.bem-sibling-elem('label') { | 181 | @include iro.bem-sibling-elem('label') { |
178 | color: iro.props-get(--colors --key-focus --label); | 182 | color: fn.color(--key-focus --label); |
179 | } | 183 | } |
180 | 184 | ||
181 | @include iro.bem-sibling-elem('box') { | 185 | @include iro.bem-sibling-elem('box') { |
182 | background-color: iro.props-get(--colors --key-focus --box-border); | 186 | background-color: fn.color(--key-focus --box-border); |
183 | box-shadow: iro.props-get(--colors --key-focus --shadow); | 187 | box-shadow: fn.color(--key-focus --shadow); |
184 | } | 188 | } |
185 | } | 189 | } |
186 | } | 190 | } |
@@ -190,46 +194,46 @@ | |||
190 | @include iro.bem-elem('native') { | 194 | @include iro.bem-elem('native') { |
191 | &:checked { | 195 | &:checked { |
192 | @include iro.bem-sibling-elem('box') { | 196 | @include iro.bem-sibling-elem('box') { |
193 | background-color: iro.props-get(--colors --accent --box-border); | 197 | background-color: fn.color(--accent --box-border); |
194 | } | 198 | } |
195 | 199 | ||
196 | &:hover { | 200 | &:hover { |
197 | @include iro.bem-sibling-elem('box') { | 201 | @include iro.bem-sibling-elem('box') { |
198 | background-color: iro.props-get(--colors --accent --hover --box-border); | 202 | background-color: fn.color(--accent --hover --box-border); |
199 | } | 203 | } |
200 | } | 204 | } |
201 | } | 205 | } |
202 | 206 | ||
203 | &:indeterminate { | 207 | &:indeterminate { |
204 | @include iro.bem-sibling-elem('box') { | 208 | @include iro.bem-sibling-elem('box') { |
205 | background-color: iro.props-get(--colors --accent --box-border); | 209 | background-color: fn.color(--accent --box-border); |
206 | } | 210 | } |
207 | 211 | ||
208 | &:hover { | 212 | &:hover { |
209 | @include iro.bem-sibling-elem('box') { | 213 | @include iro.bem-sibling-elem('box') { |
210 | background-color: iro.props-get(--colors --accent --hover --box-border); | 214 | background-color: fn.color(--accent --hover --box-border); |
211 | } | 215 | } |
212 | } | 216 | } |
213 | } | 217 | } |
214 | 218 | ||
215 | &:disabled { | 219 | &:disabled { |
216 | @include iro.bem-sibling-elem('box') { | 220 | @include iro.bem-sibling-elem('box') { |
217 | background-color: iro.props-get(--colors --disabled --box-border); | 221 | background-color: fn.color(--disabled --box-border); |
218 | 222 | ||
219 | &::before { | 223 | &::before { |
220 | background-color: iro.props-get(--colors --disabled --box-bg); | 224 | background-color: fn.color(--disabled --box-bg); |
221 | } | 225 | } |
222 | } | 226 | } |
223 | 227 | ||
224 | &:checked { | 228 | &:checked { |
225 | @include iro.bem-sibling-elem('box') { | 229 | @include iro.bem-sibling-elem('box') { |
226 | background-color: iro.props-get(--colors --disabled --box-border); | 230 | background-color: fn.color(--disabled --box-border); |
227 | } | 231 | } |
228 | } | 232 | } |
229 | 233 | ||
230 | &:indeterminate { | 234 | &:indeterminate { |
231 | @include iro.bem-sibling-elem('box') { | 235 | @include iro.bem-sibling-elem('box') { |
232 | background-color: iro.props-get(--colors --disabled --box-border); | 236 | background-color: fn.color(--disabled --box-border); |
233 | } | 237 | } |
234 | } | 238 | } |
235 | } | 239 | } |