diff options
author | Volpeon <git@volpeon.ink> | 2024-06-23 19:05:33 +0200 |
---|---|---|
committer | Volpeon <git@volpeon.ink> | 2024-06-23 19:05:33 +0200 |
commit | 64a841c69ead262666dd0754218585d0f05cf735 (patch) | |
tree | 2e6d3462d544c18d51e1e9930a2d95f98111e219 /src/objects/_radio.scss | |
parent | Update (diff) | |
download | iro-design-64a841c69ead262666dd0754218585d0f05cf735.tar.gz iro-design-64a841c69ead262666dd0754218585d0f05cf735.tar.bz2 iro-design-64a841c69ead262666dd0754218585d0f05cf735.zip |
WIP: New color calculations
Diffstat (limited to 'src/objects/_radio.scss')
-rw-r--r-- | src/objects/_radio.scss | 197 |
1 files changed, 197 insertions, 0 deletions
diff --git a/src/objects/_radio.scss b/src/objects/_radio.scss new file mode 100644 index 0000000..5f461ce --- /dev/null +++ b/src/objects/_radio.scss | |||
@@ -0,0 +1,197 @@ | |||
1 | @use 'iro-sass/src/index' as iro; | ||
2 | @use '../functions' as fn; | ||
3 | |||
4 | @include iro.props-namespace('radio') { | ||
5 | @include iro.props-store(( | ||
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 | ), | ||
15 | --colors: ( | ||
16 | --circle-border: fn.global-color(--text-mute), | ||
17 | --circle-bg: fn.global-color(--base --75), | ||
18 | |||
19 | --hover: ( | ||
20 | --label: fn.global-color(--heading), | ||
21 | --circle-border: fn.global-color(--text), | ||
22 | ), | ||
23 | --accent: ( | ||
24 | --circle-border: fn.global-color(--accent --900), | ||
25 | |||
26 | --hover: ( | ||
27 | --circle-border: fn.global-color(--accent --1000), | ||
28 | ), | ||
29 | ), | ||
30 | --key-focus: ( | ||
31 | --bg: fn.global-color(--focus-static --400), | ||
32 | --label: fn.global-color(--focus-static --400-text), | ||
33 | --circle-border: fn.global-color(--focus-static --1000), | ||
34 | --circle-bg: fn.global-color(--focus-static --1000-text), | ||
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 | ), | ||
42 | )); | ||
43 | |||
44 | @include iro.bem-object(iro.props-namespace()) { | ||
45 | display: inline-flex; | ||
46 | position: relative; | ||
47 | align-items: flex-start; | ||
48 | margin-inline: calc(-1 * fn.dim(--pad-i)) calc(fn.dim(--spacing-sibling) - fn.dim(--pad-i)); | ||
49 | padding-block: fn.dim(--pad-b); | ||
50 | padding-inline: fn.dim(--pad-i); | ||
51 | |||
52 | @include iro.bem-elem('bg') { | ||
53 | display: block; | ||
54 | position: absolute; | ||
55 | z-index: -1; | ||
56 | inset-block: 0; | ||
57 | inset-inline: 0; | ||
58 | border-radius: fn.dim(--rounding); | ||
59 | pointer-events: none; | ||
60 | } | ||
61 | |||
62 | @include iro.bem-elem('circle') { | ||
63 | display: block; | ||
64 | box-sizing: border-box; | ||
65 | flex: 0 0 auto; | ||
66 | inline-size: fn.dim(--diameter); | ||
67 | block-size: fn.dim(--diameter); | ||
68 | margin-block-start: calc(.5 * (fn.global-dim(--font --standard --line-height) * 1em - fn.dim(--diameter))); | ||
69 | border-radius: 2em; | ||
70 | background-color: fn.color(--circle-border); | ||
71 | |||
72 | &::after { | ||
73 | content: ''; | ||
74 | display: block; | ||
75 | position: relative; | ||
76 | inset-block-start: fn.dim(--border); | ||
77 | inset-inline-start: fn.dim(--border); | ||
78 | inline-size: calc(fn.dim(--diameter) - 2 * fn.dim(--border)); | ||
79 | block-size: calc(fn.dim(--diameter) - 2 * fn.dim(--border)); | ||
80 | transition: transform .2s ease; | ||
81 | border-radius: fn.dim(--diameter); | ||
82 | background-color: fn.color(--circle-bg); | ||
83 | } | ||
84 | } | ||
85 | |||
86 | @include iro.bem-elem('label') { | ||
87 | align-self: baseline; | ||
88 | margin-inline-start: fn.dim(--label-gap); | ||
89 | } | ||
90 | |||
91 | @include iro.bem-elem('native') { | ||
92 | position: absolute; | ||
93 | inset-block-start: 0; | ||
94 | inset-inline-start: 0; | ||
95 | inline-size: 100%; | ||
96 | block-size: 100%; | ||
97 | margin: 0; | ||
98 | padding: 0; | ||
99 | overflow: hidden; | ||
100 | opacity: .0001; | ||
101 | |||
102 | &:hover { | ||
103 | @include iro.bem-sibling-elem('label') { | ||
104 | color: fn.color(--hover --label); | ||
105 | } | ||
106 | |||
107 | @include iro.bem-sibling-elem('circle') { | ||
108 | background-color: fn.color(--hover --circle-border); | ||
109 | } | ||
110 | } | ||
111 | |||
112 | &:checked { | ||
113 | @include iro.bem-sibling-elem('circle') { | ||
114 | &::after { | ||
115 | transform: scale(.44); | ||
116 | } | ||
117 | } | ||
118 | } | ||
119 | |||
120 | &:disabled { | ||
121 | @include iro.bem-sibling-elem('label') { | ||
122 | color: fn.color(--disabled --label); | ||
123 | } | ||
124 | |||
125 | @include iro.bem-sibling-elem('circle') { | ||
126 | background-color: fn.color(--disabled --circle-border); | ||
127 | |||
128 | &::after { | ||
129 | background-color: fn.color(--disabled --circle-bg); | ||
130 | } | ||
131 | } | ||
132 | } | ||
133 | |||
134 | &:focus-visible { | ||
135 | @include iro.bem-sibling-elem('bg') { | ||
136 | background-color: fn.color(--key-focus --bg); | ||
137 | } | ||
138 | |||
139 | @include iro.bem-sibling-elem('label') { | ||
140 | color: fn.color(--key-focus --label); | ||
141 | } | ||
142 | |||
143 | @include iro.bem-sibling-elem('circle') { | ||
144 | background-color: fn.color(--key-focus --circle-border); | ||
145 | |||
146 | &::after { | ||
147 | background-color: fn.color(--key-focus --circle-bg); | ||
148 | } | ||
149 | } | ||
150 | } | ||
151 | } | ||
152 | |||
153 | @include iro.bem-modifier('standalone') { | ||
154 | @include iro.bem-elem('circle') { | ||
155 | margin-block-start: 0; | ||
156 | } | ||
157 | } | ||
158 | |||
159 | @include iro.bem-modifier('accent') { | ||
160 | @include iro.bem-elem('native') { | ||
161 | &:checked { | ||
162 | @include iro.bem-sibling-elem('circle') { | ||
163 | background-color: fn.color(--accent --circle-border); | ||
164 | } | ||
165 | |||
166 | &:hover { | ||
167 | @include iro.bem-sibling-elem('circle') { | ||
168 | background-color: fn.color(--accent --hover --circle-border); | ||
169 | } | ||
170 | } | ||
171 | } | ||
172 | |||
173 | &:disabled { | ||
174 | @include iro.bem-sibling-elem('circle') { | ||
175 | background-color: fn.color(--disabled --circle-border); | ||
176 | |||
177 | &::after { | ||
178 | background-color: fn.color(--disabled --circle-bg); | ||
179 | } | ||
180 | } | ||
181 | |||
182 | &:checked { | ||
183 | @include iro.bem-sibling-elem('circle') { | ||
184 | background-color: fn.color(--disabled --circle-border); | ||
185 | } | ||
186 | } | ||
187 | } | ||
188 | |||
189 | &:focus-visible { | ||
190 | @include iro.bem-sibling-elem('circle') { | ||
191 | background-color: fn.color(--key-focus --circle-border); | ||
192 | } | ||
193 | } | ||
194 | } | ||
195 | } | ||
196 | } | ||
197 | } | ||