summaryrefslogtreecommitdiffstats
path: root/src/objects/_button.vars.scss
blob: f70bde73d3b2491f8b72b6b59c00965ea1f5a059 (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
@use 'sass:map';
@use 'sass:string';
@use 'iro-sass/src/props';
@use '../core.vars' as core;

$line-height:  props.def(--o-button--line-height, 1.4) !default;
$pad-i:        props.def(--o-button--pad-i, props.get(core.$size--200)) !default;
$pad-i-label:  props.def(--o-button--pad-i-label, props.get(core.$size--50)) !default;
$pad-b:        props.def(--o-button--pad-b, props.get(core.$size--65)) !default;
$border-width: props.def(--o-button--border-width, props.get(core.$border-width--medium)) !default;
$rounding:     props.def(--o-button--rounding, 10em) !default;
$font-size:    props.def(--o-button--font-size, props.get(core.$font-size--100)) !default;

$pad-i--sm:       props.def(--o-button--sm--pad-i, props.get(core.$size--150)) !default;
$pad-i-label--sm: props.def(--o-button--sm--pad-i-label, props.get(core.$size--25)) !default;
$pad-b--sm:       props.def(--o-button--sm--pad-b, props.get(core.$size--25)) !default;
$font-size--sm:   props.def(--o-button--sm--font-size, props.get(core.$font-size--75)) !default;

$pad-i--lg:       props.def(--o-button--lg--pad-i, props.get(core.$size--250)) !default;
$pad-i-label--lg: props.def(--o-button--lg--pad-i-label, props.get(core.$size--100)) !default;
$pad-b--lg:       props.def(--o-button--lg--pad-b, props.get(core.$size--100)) !default;
$font-size--lg:   props.def(--o-button--lg--font-size, props.get(core.$font-size--150)) !default;

$pad-i--xl:       props.def(--o-button--xl--pad-i, props.get(core.$size--300)) !default;
$pad-i-label--xl: props.def(--o-button--xl--pad-i-label, props.get(core.$size--150)) !default;
$pad-b--xl:       props.def(--o-button--xl--pad-b, props.get(core.$size--150)) !default;
$font-size--xl:   props.def(--o-button--xl--font-size, props.get(core.$font-size--200)) !default;

$key-focus--border-width:  props.def(--o-button--key-focus--border-width, props.get(core.$key-focus--border-width)) !default;
$key-focus--border-offset: props.def(--o-button--key-focus--border-offset, props.get(core.$key-focus--border-offset)) !default;
$key-focus--outline-width: props.def(--o-button--key-focus--outline-width, props.get(core.$key-focus--outline-width)) !default;

$sizes: (
    'sm' $pad-i--sm $pad-i-label--sm $pad-b--sm $font-size--sm,
    'lg' $pad-i--lg $pad-i-label--lg $pad-b--lg $font-size--lg,
    'xl' $pad-i--xl $pad-i-label--xl $pad-b--xl $font-size--xl,
) !default;

$default-theme-override: () !default;
$default-theme: props.def(--o-button, (
    --bg:             props.get(core.$theme, --border-mute),
    --label:          props.get(core.$theme, --text),
    --outline-border: props.get(core.$theme, --border),
    --outline-label:  props.get(core.$theme, --text),

    --hover: (
        --bg:     props.get(core.$theme, --border),
        --label:  props.get(core.$theme, --heading),
    ),

    --active: (
        --bg:     props.get(core.$theme, --border-strong),
        --label:  props.get(core.$theme, --heading),
    ),

    --disabled: (
        --bg:             props.get(core.$theme, --border-mute),
        --outline-border: props.get(core.$theme, --border),
        --label:          props.get(core.$theme, --text-disabled),
    ),

    --key-focus: (
        --label:   props.get(core.$theme, --focus, --text),
        --border:  props.get(core.$theme, --focus, --border),
        --outline: props.get(core.$theme, --focus, --outline),
    ),

    --primary: (
        --bg:             props.get(core.$theme, --base, --900),
        --label:          props.get(core.$theme, --base, --900-text),
        --outline-border: props.get(core.$theme, --base, --900),
        --outline-label:  props.get(core.$theme, --text),

        --hover: (
            --bg:     props.get(core.$theme, --base, --800),
            --label:  props.get(core.$theme, --base, --800-text),
        ),

        --active: (
            --bg:     props.get(core.$theme, --base, --700),
            --label:  props.get(core.$theme, --base, --700-text),
        ),
    ),
), 'color');
$default-theme: props.merge($default-theme, $default-theme-override);

$static-themes: props.def(--o-button, (), 'color');

@each $theme in map.keys(props.get(core.$transparent-colors)) {
    $button-theme: --static-#{string.slice($theme, 3)};

    $static-themes: props.merge($static-themes, (
        $button-theme: (
            --bg:             props.get(core.$transparent-colors, $theme, --200),
            --label:          props.get(core.$transparent-colors, $theme, --900),
            --outline-border: props.get(core.$transparent-colors, $theme, --300),
            --outline-label:  props.get(core.$transparent-colors, $theme, --900),

            --hover: (
                --bg:     props.get(core.$transparent-colors, $theme, --300),
                --label:  props.get(core.$transparent-colors, $theme, --900),
            ),

            --active: (
                --bg:     props.get(core.$transparent-colors, $theme, --400),
                --label:  props.get(core.$transparent-colors, $theme, --900),
            ),

            --disabled: (
                --bg:             props.get(core.$transparent-colors, $theme, --200),
                --outline-border: props.get(core.$transparent-colors, $theme, --300),
                --label:          props.get(core.$transparent-colors, $theme, --500),
            ),

            --key-focus: (
                --bg:      props.get(core.$transparent-colors, $theme, --100),
                --label:   props.get(core.$transparent-colors, $theme, --900),
                --border:  props.get(core.$transparent-colors, $theme, --900),
                --outline: props.get(core.$transparent-colors, $theme, --300),
            ),

            --primary: (
                --bg:             props.get(core.$transparent-colors, $theme, --800),
                --label:          props.get(core.$transparent-colors, $theme, --text),
                --outline-border: props.get(core.$transparent-colors, $theme, --800),
                --outline-label:  props.get(core.$transparent-colors, $theme, --900),
    
                --hover: (
                    --bg:     props.get(core.$transparent-colors, $theme, --900),
                    --label:  props.get(core.$transparent-colors, $theme, --text),
                ),

                --active: (
                    --bg:     props.get(core.$transparent-colors, $theme, --900),
                    --label:  props.get(core.$transparent-colors, $theme, --text),
                ),
            )
        )
    ));
}

$themes-config: (
    accent:   --accent,
    negative: --negative,
) !default;

$themes: props.def(--o-button, (), 'color');

@each $theme, $key in $themes-config {
    $themes: props.merge($themes, (
        --#{$theme}: (
            --bg:             props.get(core.$theme, #{$key}-static, --900),
            --label:          props.get(core.$theme, #{$key}-static, --900-text),
            --outline-border: props.get(core.$theme, $key, --900),
            --outline-label:  props.get(core.$theme, $key, --1000),

            --hover: (
                --bg:     props.get(core.$theme, #{$key}-static, --1000),
                --label:  props.get(core.$theme, #{$key}-static, --1000-text),
            ),

            --active: (
                --bg:     props.get(core.$theme, #{$key}-static, --1100),
                --label:  props.get(core.$theme, #{$key}-static, --1100-text),
            ),
        )
    ));
}