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

$themes: accent negative;

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

    &:link,
    &:visited,
    &:enabled {
        border-color:     fn.color(list.join($key, --bg));
        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:     fn.color(list.join($key, --hover --bg));
            background-color: fn.color(list.join($key, --hover --bg));
            color:            fn.color(list.join($key, --hover --label));
        }

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

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

    @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;
        vertical-align:   top;
    
        @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 button-variant();

        @include iro.bem-modifier('primary') {
            @include button-variant('primary');
        }
    
        @each $theme in $themes {
            @include iro.bem-modifier($theme) {
                @include button-variant($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;
        }
    }
}