summaryrefslogtreecommitdiffstats
path: root/src/scopes/_links.scss
blob: fea78f11a6d34309a3a6cb5f57c3e37201873c17 (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 "sass:map";
@use "sass:meta";
@use "sass:string";
@use "pkg:iro-sass/bem";
@use "pkg:iro-sass/props";
@use "../props" as *;

@forward "links.vars";
@use "links.vars" as vars;

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

	@include bem.scope("links") {
		:link,
		:visited {
			color: currentColor;
			text-decoration: underline;
			text-decoration-thickness: props.get(vars.$underline-width);
			text-decoration-color: props.get(vars.$underline-color);
			border-radius: props.get(vars.$rounding-sm);
			box-decoration-break: clone;

			&:hover {
				text-decoration: underline;
				text-decoration-thickness: props.get(vars.$hover--underline-width);
				text-decoration-skip-ink: none;
			}

			&:focus-visible {
				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.modifier("invisible") {
			:link,
			:visited {
				text-decoration: none;
			}
		}

		@include bem.modifier("colored") {
			:link {
				color: props.get(vars.$colored--text-color);
				text-decoration-color: props.get(vars.$colored--underline-color);

				&:hover {
					color: props.get(vars.$colored--hover--text-color);
				}
			}

			:visited {
				color: props.get(vars.$colored--visited--text-color);
				text-decoration-color: props.get(vars.$colored--visited--underline-color);

				&:hover {
					color: props.get(vars.$colored--visited--hover--text-color);
				}
			}
		}

		@include bem.modifier("mark-external") {
			:link,
			:visited {
				&[href^="http"] {
					&::after {
						content: " ↗";
					}
				}
			}
		}

		@each $theme in map.keys(props.get(vars.$static-themes)) {
			@include bem.modifier(string.slice($theme, 3)) {
				:link,
				:visited {
					color: props.get(vars.$static-themes, $theme, --text-color);
					text-decoration-color: props.get(
						vars.$static-themes,
						$theme,
						--underline-color
					);

					&:hover {
						color: props.get(vars.$static-themes, $theme, --hover, --text-color);
					}

					&:focus-visible {
						color: props.get(vars.$static-themes, $theme, --key-focus, --text-color);
						outline-color: props.get(
							vars.$static-themes,
							$theme,
							--key-focus,
							--border-color
						);
						box-shadow: 0 0 0
							calc(
								props.get(vars.$key-focus--border-width) +
									props.get(vars.$key-focus--outline-width)
							)
							props.get(vars.$static-themes, $theme, --key-focus, --outline-color);
					}
				}
			}
		}

		:has(img) {
			img {
				margin-inline: calc(-1 * props.get(vars.$key-focus--border-offset));
				border: props.get(vars.$key-focus--border-offset) solid transparent;
				border-radius: calc(
					props.get(vars.$rounding) + props.get(vars.$key-focus--border-offset)
				);
			}

			&:link,
			&:visited {
				&:focus-visible {
					outline: none;
					box-shadow: none;

					img {
						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);
					}
				}
			}
		}
	}
}