summaryrefslogtreecommitdiffstats
path: root/src/objects/_tabbar.scss
blob: 68666dcc34026006543766b48b03330cd001954b (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
@use 'sass:map';
@use 'sass:meta';
@use 'sass:string';
@use 'iro-sass/src/bem';
@use 'iro-sass/src/props';
@use '../props' as *;

@forward 'tabbar.vars';
@use 'tabbar.vars' as vars;

@mixin styles {
    @include materialize-at-root(meta.module-variables('vars'));

    @include bem.object('tabbar') {
        position:        relative;
        display:         flex;
        min-inline-size: 0;
        block-size:      props.get(vars.$block-size);
        margin-inline:   calc(-.5 * props.get(vars.$spacing));
        overflow-inline: auto;

        &::after {
            display:            block;
            flex:               1 1 auto;
            block-size:         props.get(vars.$indicator--width);
            margin-block-start: auto;
            margin-inline-end:  calc(.5 * props.get(vars.$spacing));
            content:            '';
            background-color:   props.get(vars.$railing--bg-color);
        }

        @include bem.modifier('quiet') {
            &::after {
                display: none;
            }
        }

        @include bem.modifier('adapt') {
            block-size: 100%;
        }

        @include bem.elem('tab') {
            position:               relative;
            display:                flex;
            align-items:            center;
            padding-inline-end:     calc(.5 * props.get(vars.$spacing));
            color:                  props.get(vars.$tab--text-color);
            white-space:            nowrap;
            border-block:           props.get(vars.$indicator--width) solid transparent;
            border-block-end-color: props.get(vars.$railing--bg-color);

            &::before {
                position:          absolute;
                inset-block-start: 50%;
                inset-inline:      calc(-1 * props.get(vars.$tab--pad-i) + .5 * props.get(vars.$spacing));
                z-index:           -10;
                block-size:        1.5em;
                content:           '';
                border-radius:     props.get(vars.$rounding);
                transform:         translateY(-50%);
            }

            &::after {
                position:         absolute;
                inset-block-end:  0;
                inset-inline:     calc(.5 * props.get(vars.$spacing));
                z-index:          10;
                display:          none;
                content:          '';
                background-color: props.get(vars.$tab--selected--text-color);
            }

            &:link,
            &:visited {
                &:hover,
                &:active,
                &:focus-visible {
                    color: props.get(vars.$tab--selected--text-color);
                }

                &:focus-visible {
                    &::before {
                        color:           props.get(vars.$key-focus--text-color);
                        text-decoration: none;
                        outline:         props.get(vars.$key-focus--border-color) solid props.get(vars.$key-focus--border-width);
                        box-shadow: 0 0 0
                            calc(props.get(vars.$key-focus--border-width) + props.get(vars.$key-focus--outline-width))
                            props.get(vars.$key-focus--outline-color);
                    }
                }
            }

            @include bem.next-twin-elem {
                padding-inline-start: calc(.5 * props.get(vars.$spacing));
            }

            @include bem.is('selected') {
                color: props.get(vars.$tab--selected--text-color);
                
                &::after {
                    display: block;
                }
            }
        }

        @include bem.modifier('accent') {
            @include bem.elem('tab') {
                &::after {
                    background-color: props.get(vars.$tab--accent--text-color);
                }

                @include bem.is('selected') {
                    color: props.get(vars.$tab--accent--text-color);
                }
            }
        }
    }
}