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

$static-themes: 'black' 'white' !default;

@include iro.props-namespace('links') {
    @include iro.props-store((
        --dims: (
            --rounding:          fn.global-dim(--rounding),
            --underline:         fn.global-dim(--border --thin),

            --hover: (
                --underline:     fn.global-dim(--border --medium),
            ),

            --key-focus: (
                --border:        fn.global-dim(--key-focus --border),
                --border-offset: fn.global-dim(--key-focus --border-offset),
                --outline:       fn.global-dim(--key-focus --border),
            ),
        ),
        --colors: (
            --underline: fn.global-color(--text-mute-more),

            --colored: (
                --text:          fn.global-color(--accent --1100),
                --underline:     fn.global-color(--accent --600),

                --hover: (
                    --text:      fn.global-color(--accent --1300),
                ),
    
                --visited: (
                    --text:          fn.global-color(--purple --1100),
                    --underline:     fn.global-color(--purple --600),
    
                    --hover: (
                        --text:      fn.global-color(--purple --1300),
                    ),
                ),
            ),

            --key-focus: (
                --text:          fn.global-color(--focus --text),
                --border:        fn.global-color(--focus --border),
                --outline:       fn.global-color(--focus --outline),
            ),
        ),
    ));

    @each $theme in $static-themes {
        @include iro.props-store((
            --colors: (
                --static-#{$theme}: (
                    --text:          fn.global-color(--#{$theme}-transparent --800),
                    --underline:     fn.global-color(--#{$theme}-transparent --500),
    
                    --hover: (
                        --text:      fn.global-color(--#{$theme}-transparent --900),
                    ),

                    --key-focus: (
                        --text:      fn.global-color(--#{$theme}-transparent --900),
                        --border:    fn.global-color(--#{$theme}-transparent --900),
                        --outline:   fn.global-color(--#{$theme}-transparent --300),
                    ),
                )
            )
        ));
    }

    @include iro.bem-scope(iro.props-namespace()) {
        :link,
        :visited {
            margin:                    calc(-1 * fn.dim(--key-focus --border-offset));
            padding:                   fn.dim(--key-focus --border-offset);
            border-radius:             fn.dim(--rounding);
            color:                     currentColor;
            text-decoration:           underline;
            text-decoration-color:     fn.color(--underline);
            text-decoration-thickness: fn.dim(--underline);
            box-decoration-break:      clone;

            &:hover {
                text-decoration:           underline;
                text-decoration-thickness: fn.dim(--hover --underline);
                text-decoration-skip-ink:  none;
            }

            &:focus-visible {
                outline:          fn.color(--key-focus --border) solid fn.dim(--key-focus --border);
                box-shadow:       0 0 0 calc(fn.dim(--key-focus --border) + fn.dim(--key-focus --outline)) fn.color(--key-focus --outline);
                color:            fn.color(--key-focus --text);
                text-decoration:  none;
            }
        }

        @include iro.bem-modifier('invisible') {
            :link,
            :visited {
                text-decoration: none;
            }
        }

        @include iro.bem-modifier('colored') {
            :link {
                color:                 fn.color(--colored --text);
                text-decoration-color: fn.color(--colored --underline);

                &:hover {
                    color:             fn.color(--colored --hover --text);
                }
            }
    
            :visited {
                color:                 fn.color(--colored --visited --text);
                text-decoration-color: fn.color(--colored --visited --underline);

                &:hover {
                    color:             fn.color(--colored --visited --hover --text);
                }
            }
        }

        @each $theme in $static-themes {
            @include iro.bem-modifier(static-#{$theme}) {
                :link,
                :visited {
                    color:                 fn.color(--static-#{$theme} --text);
                    text-decoration-color: fn.color(--static-#{$theme} --underline);

                    &:hover {
                        color:             fn.color(--static-#{$theme} --hover --text);
                    }

                    &:focus-visible {
                        outline-color: fn.color(--static-#{$theme} --key-focus --border);
                        box-shadow:    0 0 0 calc(fn.dim(--key-focus --border) + fn.dim(--key-focus --outline)) fn.color(--static-#{$theme} --key-focus --outline);
                        color:         fn.color(--static-#{$theme} --key-focus --text);
                    }
                }
            }
        }
    }
}