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

$themes:        'accent' 'negative';
$static-themes: 'black' 'white';

@mixin theme($theme: null) {
    $key: if($theme == null, (), --#{$theme});

    &:link,
    &:visited,
    &:enabled {
        border-color:     transparent;
        background-color: fn.color(list.join($key, --bg));
        color:            fn.color(list.join($key, --label));
    }
    
    @include iro.bem-modifier('outline') {
        &:link,
        &:visited,
        &:enabled {
            border-color:     fn.color(list.join($key, --outline-border));
            background-color: transparent;
            color:            fn.color(list.join($key, --outline-label));
        }
    }

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

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

@mixin static-theme($theme, $disabled-theme: $theme) {
    $key: --static-#{$disabled-theme};

    border-color:     transparent;
    background-color: fn.color(list.join($key, --disabled --bg));
    color:            fn.color(list.join($key, --disabled --label));

    @include theme(static-#{$theme});
}

@include iro.props-namespace('button') {
    @include iro.props-store((
        --dims: (
            --line-height: 1.4,
            --pad-i:       fn.global-dim(--size --225),
            --pad-b:       fn.global-dim(--size --65),
            --border:      fn.global-dim(--border --medium),
            --rounding:    10em,
            --font-size:   fn.global-dim(--font-size --100),

            --sm: (
                --pad-i:      fn.global-dim(--size --150),
                --pad-b:      fn.global-dim(--size --25),
                --font-size:  fn.global-dim(--font-size --75),
            ),
            --lg: (
                --pad-i:      fn.global-dim(--size --300),
                --pad-b:      fn.global-dim(--size --100),
                --font-size:  fn.global-dim(--font-size --150),
            ),
            --xl: (
                --pad-i:      fn.global-dim(--size --400),
                --pad-b:      fn.global-dim(--size --150),
                --font-size:  fn.global-dim(--font-size --200),
            ),
            
            --key-focus: (
                --border: fn.global-dim(--key-focus --border),
            ),
        ),
        --colors: (
            --bg:             fn.global-color(--border-mute),
            --label:          fn.global-color(--text),
            --outline-border: fn.global-color(--border),
            --outline-label:  fn.global-color(--text),

            --hover: (
                --bg:     fn.global-color(--border),
                --label:  fn.global-color(--heading),
            ),
            --active: (
                --bg:     fn.global-color(--border-strong),
                --label:  fn.global-color(--heading),
            ),
            --disabled: (
                --bg:             fn.global-color(--border-mute),
                --outline-border: fn.global-color(--border),
                --label:          fn.global-color(--text-disabled),
            ),
            --key-focus: (
                --bg:      fn.global-color(--base --50),
                --label:   fn.global-color(--heading),
                --border:  fn.global-color(--focus-static --400),
            ),
            
            --primary: (
                --bg:             fn.global-color(--base --800),
                --label:          fn.global-color(--base --800-text),
                --outline-border: fn.global-color(--base --800),
                --outline-label:  fn.global-color(--text),

                --hover: (
                    --bg:     fn.global-color(--base --900),
                    --label:  fn.global-color(--base --900-text),
                ),
                --active: (
                    --bg:     fn.global-color(--base --900),
                    --label:  fn.global-color(--base --900-text),
                ),
            ),
        ),
    ));

    @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),
                    --outline-border: fn.global-color(--#{$theme} --900),
                    --outline-label:  fn.global-color(--#{$theme} --1000),

                    --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 --1100-text),
                    ),
                ),
            ),
        ));
    }

    @each $theme in $static-themes {
        @include iro.props-store((
            --colors: (
                --static-#{$theme}: (
                    --bg:             fn.global-color(--#{$theme}-transparent --200),
                    --label:          fn.global-color(--#{$theme}-transparent --900),
                    --outline-border: fn.global-color(--#{$theme}-transparent --300),
                    --outline-label:  fn.global-color(--#{$theme}-transparent --900),

                    --disabled: (
                        --bg:             fn.global-color(--#{$theme}-transparent --200),
                        --outline-border: fn.global-color(--#{$theme}-transparent --100),
                        --label:          fn.global-color(--#{$theme}-transparent --500),
                    ),
                    --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),
                    ),
                ),
                --static-#{$theme}-primary: (
                    --bg:             fn.global-color(--#{$theme}-transparent --800),
                    --label:          fn.global-color(--#{$theme}-transparent --text),
                    --outline-border: fn.global-color(--#{$theme}-transparent --800),
                    --outline-label:  fn.global-color(--#{$theme}-transparent --900),

                    --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),
                    ),
                ),
            ),
        ));
    }

    @include iro.bem-object(iro.props-namespace()) {
        display:          inline-block;
        padding-block:    fn.dim(--pad-b);
        padding-inline:   fn.dim(--pad-i);
        border:           fn.dim(--border) solid transparent;
        border-radius:    fn.dim(--rounding);
        border-color:     fn.color(--disabled --bg);
        background-color: fn.color(--disabled --bg);
        color:            fn.color(--disabled --label);
        font-size:        fn.dim(--font-size);
        font-weight:      500;
        line-height:      fn.dim(--line-height);
        text-align:       center;
        text-decoration:  none;
    
        @include iro.bem-modifier('block') {
            display: block;
        }
    
        @include iro.bem-modifier('outline') {
            border-color:     fn.color(--disabled --outline-border);
            background-color: transparent;
            box-shadow:       none;
        }

        @each $size in sm lg xl {
            @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 theme();

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

            @include iro.bem-modifier(static-#{$theme}-primary) {
                @include static-theme(#{$theme}-primary, $theme);
            }
        }

        &:link,
        &:visited,
        &:enabled {
            &:focus-visible {
                border-color:     fn.color(--key-focus --border);
                background-color: fn.color(--key-focus --bg);
                box-shadow:       0 0 0 calc(fn.dim(--key-focus --border) - fn.dim(--border)) fn.color(--key-focus --border);
                color:            fn.color(--key-focus --label);
            }
        }
    
        @include iro.bem-modifier('round') {
            inline-size:    calc(1em * fn.dim(--line-height) + 2 * fn.dim(--pad-b));
            padding-inline: 0;
            border-radius:  100em;
        }
    }
}