summaryrefslogtreecommitdiffstats
path: root/src/objects/_badge.scss
blob: b9020b63c9336294cd2e285948f392cc255ecc74 (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
@use 'sass:string';
@use 'iro-sass/src/index' as iro;
@use '../functions' as fn;

$themes:        'accent' 'positive' 'negative' 'warning' !default;
$static-themes: 'black' 'white' !default;

@mixin theme($theme) {
    background-color: fn.color(--#{$theme} --bg);
    color:            fn.color(--#{$theme} --label);

    &:link,
    &:visited,
    &:enabled {
        &:hover {
            background-color: fn.color(--#{$theme} --hover --bg);
            color:            fn.color(--#{$theme} --hover --label);
        }

        &:active {
            background-color: fn.color(--#{$theme} --active --bg);
            color:            fn.color(--#{$theme} --active --label);
        }
    }

    @include iro.bem-modifier('quiet') {
        background-color: fn.color(--#{$theme}-quiet --bg);
        color:            fn.color(--#{$theme}-quiet --label);

        &:link,
        &:visited,
        &:enabled {
            &:hover {
                background-color: fn.color(--#{$theme}-quiet --hover --bg);
                color:            fn.color(--#{$theme}-quiet --hover --label);
            }

            &:active {
                background-color: fn.color(--#{$theme}-quiet --active --bg);
                color:            fn.color(--#{$theme}-quiet --active --label);
            }
        }
    }

    @if string.slice($theme, 1, 7) == 'static-' {
        &:link,
        &:visited,
        &:enabled {
            &:focus-visible {
                border-color:     fn.color(--#{$theme} --key-focus --border);
                outline:          fn.color(--#{$theme} --key-focus --outline) solid fn.dim(--key-focus --outline);
                background-color: fn.color(--#{$theme} --key-focus --bg);
                color:            fn.color(--#{$theme} --key-focus --label);
            }
        }
    }
}

@include iro.props-namespace('badge') {
    @include iro.props-store((
        --dims: (
            --pad-b:      fn.global-dim(--size --50),
            --pad-i:      fn.global-dim(--size --150),
            --pad-i-pill: fn.global-dim(--size --200),
            --rounding:   fn.global-dim(--rounding),
            --font-size:  fn.global-dim(--font-size --75),

            --sm: (
                --pad-b:      fn.global-dim(--size --25),
                --pad-i:      fn.global-dim(--size --115),
                --pad-i-pill: fn.global-dim(--size --150),
                --font-size:  fn.global-dim(--font-size --50),
            ),
            --lg: (
                --pad-b:      fn.global-dim(--size --75),
                --pad-i:      fn.global-dim(--size --175),
                --pad-i-pill: fn.global-dim(--size --225),
                --font-size:  fn.global-dim(--font-size --100),
            ),
            --xl: (
                --pad-b:      fn.global-dim(--size --100),
                --pad-i:      fn.global-dim(--size --225),
                --pad-i-pill: fn.global-dim(--size --300),
                --font-size:  fn.global-dim(--font-size --150),
            ),
            
            --key-focus: (
                --border:  fn.global-dim(--border --medium),
                --outline: fn.global-dim(--key-focus --border),
            ),
        ),
        --colors: (
            --bg:    fn.global-color(--text-mute),
            --label: fn.global-color(--bg-l2),
            --hover: (
                --bg: fn.global-color(--text),
            ),
            --active: (
                --bg: fn.global-color(--heading),
            ),
            --key-focus: (
                --bg:      fn.global-color(--base --50),
                --label:   fn.global-color(--heading),
                --border:  fn.global-color(--focus --1100),
                --outline: fn.global-color(--focus --400),
            ),

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

    @each $theme in $themes {
        @include iro.props-store((
            --colors: (
                --#{$theme}: (
                    --bg:    fn.global-color(--#{$theme}-static --900),
                    --label: fn.global-color(--#{$theme}-static --900-text),
                    --hover: (
                        --bg:    fn.global-color(--#{$theme}-static --1000),
                        --label: fn.global-color(--#{$theme}-static --1000-text),
                    ),
                    --active: (
                        --bg:    fn.global-color(--#{$theme}-static --1100),
                        --label: fn.global-color(--#{$theme}-static --1000-text),
                    ),
                ),

                --#{$theme}-quiet: (
                    --bg:    fn.global-color(--#{$theme} --200),
                    --label: fn.global-color(--#{$theme} --1100),
                    --hover: (
                        --bg:    fn.global-color(--#{$theme} --300),
                        --label: fn.global-color(--#{$theme} --1200),
                    ),
                    --active: (
                        --bg:    fn.global-color(--#{$theme} --400),
                        --label: fn.global-color(--#{$theme} --1300),
                    ),
                )
            ),
        ));
    }

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

                --static-#{$theme}-quiet: (
                    --bg:    fn.global-color(--#{$theme}-transparent --200),
                    --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),
                    ),
                )
            )
        ));
    }

    @include iro.bem-object(iro.props-namespace()) {
        display:          inline-block;
        padding-block:    calc(fn.dim(--pad-b) - fn.dim(--key-focus --border));
        padding-inline:   calc(fn.dim(--pad-i) - fn.dim(--key-focus --border));
        border:           fn.dim(--key-focus --border) solid transparent;
        border-radius:    fn.dim(--rounding);
        background-color: fn.color(--bg);
        color:            fn.color(--label);
        font-size:        fn.dim(--font-size);
        line-height:      fn.global-dim(--font --standard --line-height);
        text-align:       center;
        text-decoration:  none;

        &:link,
        &:visited,
        &:enabled {
            &:hover {
                background-color: fn.color(--hover --bg);
            }

            &:active {
                background-color: fn.color(--active --bg);
            }
        }

        @include iro.bem-modifier('quiet') {
            background-color: fn.color(--quiet --bg);
            color:            fn.color(--quiet --label);

            &:link,
            &:visited,
            &:enabled {
                &:hover {
                    background-color: fn.color(--quiet --hover --bg);
                }

                &:active {
                    background-color: fn.color(--quiet --active --bg);
                }
            }
        }
    
        @each $theme in $themes {
            @include iro.bem-modifier($theme) {
                @include theme($theme);
            }
        }

        &:link,
        &:visited,
        &:enabled {
            &:focus-visible {
                border-color:     fn.color(--key-focus --border);
                outline:          fn.color(--key-focus --outline) solid fn.dim(--key-focus --outline);
                background-color: fn.color(--key-focus --bg);
                color:            fn.color(--key-focus --label);
            }
        }
    
        @each $theme in $static-themes {
            @include iro.bem-modifier(static-#{$theme}) {
                @include theme(static-#{$theme});
            }
        }
    
        @include iro.bem-modifier('pill') {
            padding-inline: fn.dim(--pad-i-pill);
            border-radius:  10em;
        }
    
        @each $size in sm lg xl {
            @include iro.bem-modifier($size) {
                padding-block:  calc(fn.dim(--#{$size} --pad-b) - fn.dim(--key-focus --border));
                padding-inline: calc(fn.dim(--#{$size} --pad-i) - fn.dim(--key-focus --border));
                font-size:      fn.dim(--#{$size} --font-size);
        
                @include iro.bem-modifier('pill') {
                    padding-inline: fn.dim(--#{$size} --pad-i-pill);
                }
            }
        }
    }
}