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

@include iro.props-namespace('badge') {
    @include iro.props-store((
        --dims: (
            --pad-x:     fn.px-to-em(4px),
            --pad-y:     0,
            --rounding:  3px,
            --fixed-100: 1em,
            --fixed-200: 1.5em,

            --200: (
                --pad-x: fn.px-to-em(6px),
                --pad-y: fn.px-to-em(2px),
            ),

            --pill: (
                --pad-x: fn.px-to-em(9px),

                --200: (
                    --pad-x: fn.px-to-em(10px),
                ),
            ),
        ),
    ), 'dims');

    @include iro.props-store((
        --colors: (
            --bg:    fn.global-color(--obj-hi),
            --label: fn.global-color(--fg-lo),
            --hover: (
                --bg: fn.global-color(--obj),
            ),
            --active: (
                --bg: fn.global-color(--obj-lo),
            ),
            --key-focus: (
                --border: fn.global-color(--focus --fill),
                --shadow: fn.global-color(--focus --shadow),
            ),

            --primary: (
                --bg:    fn.global-color(--fg-lo),
                --label: fn.global-color(--bg),
                --hover: (
                    --bg: fn.global-color(--fg),
                ),
                --active: (
                    --bg: fn.global-color(--fg),
                ),
            ),

            --accent: (
                --bg:    fn.global-color(--accent --primary --solid --bg),
                --label: fn.global-color(--accent --primary --solid --fg),
                --hover: (
                    --bg: fn.global-color(--accent --primary --solid --obj),
                ),
                --active: (
                    --bg: fn.global-color(--accent --primary --solid --obj-lo),
                ),
            ),

            --accent-quiet: (
                --bg:    fn.global-color(--accent --primary --quiet --bg),
                --label: fn.global-color(--accent --primary --quiet --fg),
                --hover: (
                    --bg: fn.global-color(--accent --primary --quiet --obj),
                ),
                --active: (
                    --bg: fn.global-color(--accent --primary --quiet --obj-lo),
                ),
            )
        ),
    ), 'colors');

    @include iro.bem-object(iro.props-namespace()) {
        display:          inline-block;
        margin-top:       -.5em;
        margin-bottom:    -.5em;
        padding:          fn.dim(--pad-y) fn.dim(--pad-x);
        border-radius:    fn.dim(--rounding);
        background-color: fn.color(--bg);
        color:            fn.color(--label);
        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);
            }
        }
    
        @each $variant in 'primary' 'accent' 'accent-quiet' {
            @include iro.bem-modifier($variant) {
                background-color: fn.color(--#{$variant} --bg);
                color:            fn.color(--#{$variant} --label);
    
                &:link,
                &:visited,
                &:enabled {
                    &:hover {
                        background-color: fn.color(--#{$variant} --hover --bg);
                    }
    
                    &:active {
                        background-color: fn.color(--#{$variant} --active --bg);
                    }
                }
            }
        }

        &:link,
        &:visited,
        &:enabled {
            @include iro.bem-at-theme('keyboard') {
                &:focus {
                    background-color: transparent;
                    box-shadow:       inset 0 0 0 2px fn.color(--key-focus --border), fn.color(--key-focus --shadow);
                    color:            currentColor;
                }
            }
        }
    
        @include iro.bem-modifier('pill') {
            padding-right: fn.dim(--pill --pad-x);
            padding-left:  fn.dim(--pill --pad-x);
            border-radius: 10em;
        }
    
        @include iro.bem-modifier('200') {
            padding: fn.dim(--200 --pad-y) fn.dim(--200 --pad-x);
    
            @include iro.bem-modifier('pill') {
                padding-right: fn.dim(--pill --200 --pad-x);
                padding-left:  fn.dim(--pill --200 --pad-x);
            }
        }
    
        @include iro.bem-modifier('fixed-100') {
            width: fn.dim(--fixed-100);
        }
    
        @include iro.bem-modifier('fixed-200') {
            width: fn.dim(--fixed-200);
        }
    
        @include iro.bem-modifier('sm') {
            font-size: fn.global-dim(--font-size --75);
        }
    
        @include iro.bem-modifier('xs') {
            font-size: fn.global-dim(--font-size --50);
        }
    }
}