summaryrefslogtreecommitdiffstats
path: root/src/objects/_action-button.scss
blob: 7fe9d448d3a90e7fed1a77d1b998c20533989214 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
@use 'sass:list';
@use 'iro-sass/src/index' as iro;
@use '../functions' as fn;

$sizes:         'sm' 'lg' 'xl' !default;
$static-themes: 'black' 'white' !default;

@mixin static-theme($theme: ()) {
    border-color:     fn.color(list.join($theme, --disabled --border));
    background-color: fn.color(list.join($theme, --disabled --bg));
    color:            fn.color(list.join($theme, --disabled --label));

    &::after {
        outline-color: fn.color(list.join($theme, --key-focus --border));
        box-shadow:    0 0 0 calc(fn.dim(--key-focus --border) + fn.dim(--key-focus --outline)) fn.color(list.join($theme, --key-focus --outline));
    }

    &:link,
    &:visited,
    &:enabled {
        border-color:     fn.color(list.join($theme, --border));
        background-color: fn.color(list.join($theme, --bg));
        color:            fn.color(list.join($theme, --label));

        &:hover,
        &:focus-visible {
            border-color:     fn.color(list.join($theme, --hover --border));
            background-color: fn.color(list.join($theme, --hover --bg));
            color:            fn.color(list.join($theme, --hover --label));
        }

        &:active {
            border-color:     fn.color(list.join($theme, --active --border));
            background-color: fn.color(list.join($theme, --active --bg));
            color:            fn.color(list.join($theme, --active --label));
        }
    }

    @include iro.bem-modifier('quiet') {
        border-color:     transparent;
        background-color: transparent;
        color:            fn.color(list.join($theme, --quiet --disabled --label));

        &:link,
        &:visited,
        &:enabled {
            border-color:     transparent;
            background-color: transparent;
            color:            fn.color(list.join($theme, --quiet --label));

            &:hover,
            &:focus-visible {
                border-color:     transparent;
                background-color: fn.color(list.join($theme, --quiet --hover --bg));
                color:            fn.color(list.join($theme, --quiet --hover --label));
            }

            &:active {
                border-color:     transparent;
                background-color: fn.color(list.join($theme, --quiet --active --bg));
                color:            fn.color(list.join($theme, --quiet --active --label));
            }
        }
    }

    @include iro.bem-is('selected') {
        border-color:     fn.color(list.join($theme, --selected --disabled --border));
        background-color: fn.color(list.join($theme, --selected --disabled --bg));
        color:            fn.color(list.join($theme, --selected --disabled --label));

        &:link,
        &:visited,
        &:enabled {
            border-color:     fn.color(list.join($theme, --selected --border));
            background-color: fn.color(list.join($theme, --selected --bg));
            color:            fn.color(list.join($theme, --selected --label));
    
            &:hover,
            &:focus-visible {
                border-color:     fn.color(list.join($theme, --selected --hover --border));
                background-color: fn.color(list.join($theme, --selected --hover --bg));
                color:            fn.color(list.join($theme, --selected --hover --label));
            }
    
            &:active {
                border-color:     fn.color(list.join($theme, --selected --active --border));
                background-color: fn.color(list.join($theme, --selected --active --bg));
                color:            fn.color(list.join($theme, --selected --active --label));
            }
        }
    }
}

@include iro.props-namespace('action-button') {
    @include iro.props-store((
        --dims: (
            --line-height: 1.4,
            --pad-i:       fn.global-dim(--size --150),
            --pad-i-pill:  fn.global-dim(--size --200),
            --pad-b:       fn.global-dim(--size --85),
            --border:      fn.global-dim(--border --thin),
            --rounding:    fn.global-dim(--rounding),
            --font-size:   fn.global-dim(--font-size --100),

            --sm: (
                --pad-i:      fn.global-dim(--size --100),
                --pad-i-pill: fn.global-dim(--size --150),
                --pad-b:      fn.global-dim(--size --40),
                --font-size:  fn.global-dim(--font-size --75),
            ),
            --lg: (
                --pad-i:      fn.global-dim(--size --175),
                --pad-i-pill: fn.global-dim(--size --225),
                --pad-b:      fn.global-dim(--size --115),
                --font-size:  fn.global-dim(--font-size --150),
            ),
            --xl: (
                --pad-i:      fn.global-dim(--size --225),
                --pad-i-pill: fn.global-dim(--size --300),
                --pad-b:      fn.global-dim(--size --150),
                --font-size:  fn.global-dim(--font-size --200),
            ),
            
            --key-focus: (
                --border:        fn.global-dim(--key-focus --border),
                --border-offset: fn.global-dim(--key-focus --border-offset),
                --outline:       fn.global-dim(--key-focus --outline),
            ),
        ),
        --colors: (
            --bg:     fn.global-color(--base --75),
            --label:  fn.global-color(--text),
            --border: fn.global-color(--border-strong),
    
            --hover: (
                --bg:     fn.global-color(--border-mute),
                --label:  fn.global-color(--heading),
                --border: fn.global-color(--text-mute-more),
            ),
            --active: (
                --bg:     fn.global-color(--border),
                --label:  fn.global-color(--heading),
                --border: fn.global-color(--text-mute),
            ),
            --disabled: (
                --bg:     fn.global-color(--bg-l1),
                --label:  fn.global-color(--border-strong),
                --border: fn.global-color(--border),
            ),
            --key-focus: (
                --border:  fn.global-color(--focus --border),
                --outline: fn.global-color(--focus --outline),
            ),

            --selected: (
                --bg:     fn.global-color(--text-mute),
                --label:  fn.global-color(--base --50),
                --border: fn.global-color(--text-mute),

                --hover: (
                    --bg:     fn.global-color(--text),
                    --label:  fn.global-color(--base --50),
                    --border: fn.global-color(--text),
                ),
                --active: (
                    --bg:     fn.global-color(--heading),
                    --label:  fn.global-color(--base --50),
                    --border: fn.global-color(--heading),
                ),
                --disabled: (
                    --bg:     fn.global-color(--border-mute),
                    --label:  fn.global-color(--border-strong),
                    --border: fn.global-color(--border-mute),
                ),
            ),

            --quiet: (
                --label: fn.global-color(--text),
    
                --hover: (
                    --bg:    fn.global-color(--border-mute),
                    --label: fn.global-color(--heading),
                ),
                --active: (
                    --bg:    fn.global-color(--border),
                    --label: fn.global-color(--heading),
                ),
                --disabled: (
                    --label: fn.global-color(--border-strong),
                ),
            ),
        ),
    ));

    @each $theme in $static-themes {
        @include iro.props-store((
            --colors: (
                --static-#{$theme}: (
                    --bg:     fn.global-color(--#{$theme}-transparent --100),
                    --label:  fn.global-color(--#{$theme}-transparent --900),
                    --border: fn.global-color(--#{$theme}-transparent --400),
            
                    --hover: (
                        --bg:     fn.global-color(--#{$theme}-transparent --300),
                        --label:  fn.global-color(--#{$theme}-transparent --900),
                        --border: fn.global-color(--#{$theme}-transparent --500),
                    ),
                    --active: (
                        --bg:     fn.global-color(--#{$theme}-transparent --400),
                        --label:  fn.global-color(--#{$theme}-transparent --900),
                        --border: fn.global-color(--#{$theme}-transparent --600),
                    ),
                    --disabled: (
                        --bg:     fn.global-color(--#{$theme}-transparent --100),
                        --label:  fn.global-color(--#{$theme}-transparent --500),
                        --border: fn.global-color(--#{$theme}-transparent --300),
                    ),
                    --key-focus: (
                        --border:  fn.global-color(--#{$theme}-transparent --900),
                        --outline: fn.global-color(--#{$theme}-transparent --300),
                    ),

                    --selected: (
                        --bg:     fn.global-color(--#{$theme}-transparent --800),
                        --label:  fn.global-color(--#{$theme}-transparent --text),
                        --border: fn.global-color(--#{$theme}-transparent --100),
        
                        --hover: (
                            --bg:     fn.global-color(--#{$theme}-transparent --900),
                            --label:  fn.global-color(--#{$theme}-transparent --text),
                            --border: fn.global-color(--#{$theme}-transparent --100),
                        ),
                        --active: (
                            --bg:     fn.global-color(--#{$theme}-transparent --900),
                            --label:  fn.global-color(--#{$theme}-transparent --text),
                            --border: fn.global-color(--#{$theme}-transparent --100),
                        ),
                        --disabled: (
                            --bg:     fn.global-color(--#{$theme}-transparent --200),
                            --label:  fn.global-color(--#{$theme}-transparent --500),
                            --border: fn.global-color(--#{$theme}-transparent --100),
                        ),
                    ),

                    --quiet: (
                        --label: fn.global-color(--#{$theme}-transparent --900),
            
                        --hover: (
                            --bg:    fn.global-color(--#{$theme}-transparent --300),
                            --label: fn.global-color(--#{$theme}-transparent --900),
                        ),
                        --active: (
                            --bg:    fn.global-color(--#{$theme}-transparent --400),
                            --label: fn.global-color(--#{$theme}-transparent --900),
                        ),
                        --disabled: (
                            --label: fn.global-color(--#{$theme}-transparent --500),
                        ),
                    ),
                ),
            )
        ));
    }

    @include iro.bem-object(iro.props-namespace()) {
        display:          inline-block;
        position:         relative;
        padding-block:    fn.dim(--pad-b);
        padding-inline:   fn.dim(--pad-i);
        border:           fn.dim(--border) solid fn.color(--disabled --border);
        border-radius:    fn.dim(--rounding);
        background-color: fn.color(--disabled --bg);
        color:            fn.color(--disabled --label);
        line-height:      fn.dim(--line-height);
        text-align:       center;
        text-decoration:  none;
        text-overflow:    ellipsis;
        white-space:      nowrap;

        &::after {
            content:        '';
            display:        none;
            position:       absolute;
            z-index:        1;
            inset:          calc(-1 * fn.dim(--border) - fn.dim(--key-focus --border-offset));
            border-radius:  calc(fn.dim(--rounding) + fn.dim(--key-focus --border-offset));
            outline:        fn.color(--key-focus --border) solid fn.dim(--key-focus --border);
            box-shadow:     0 0 0 calc(fn.dim(--key-focus --border) + fn.dim(--key-focus --outline)) fn.color(--key-focus --outline);
            pointer-events: none;
        }

        &:link,
        &:visited,
        &:enabled {
            &:focus-visible {
                &::after {
                    display: block;
                }
            }
        }

        @include static-theme;

        @each $theme in $static-themes {
            @include iro.bem-modifier(static-#{$theme}) {
                @include static-theme(--static-#{$theme});
            }
        }

        @include iro.bem-modifier('pill') {
            padding-inline: fn.dim(--pad-i-pill);
            border-radius:  100em;

            &::after {
                border-radius:  100em;
            }
        }

        @each $size in $sizes {
            @include iro.bem-modifier($size) {
                padding-block:  fn.dim(--#{$size} --pad-b);
                padding-inline: fn.dim(--#{$size} --pad-i);
                font-size:      fn.dim(--#{$size} --font-size);

                @include iro.bem-modifier('pill') {
                    padding-inline: fn.dim(--#{$size} --pad-i-pill);
                }
            }
        }

        @include iro.bem-modifier('icon') {
            inline-size:    calc(1em * fn.dim(--line-height) + 2 * fn.dim(--pad-b));
            padding-inline: 0;

            @each $size in $sizes {
                @include iro.bem-modifier($size) {
                    inline-size:    calc(1em * fn.dim(--line-height) + 2 * fn.dim(--#{$size} --pad-b));
                    padding-inline: 0;
                }
            }
        }
    }
}