-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathLanguagePicker.astro
More file actions
87 lines (78 loc) · 2.16 KB
/
LanguagePicker.astro
File metadata and controls
87 lines (78 loc) · 2.16 KB
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
---
import { defaultLang } from "../i18n/ui";
import { useTranslatedPath } from "../i18n/utils";
const { lang } = Astro.props;
const path = Astro.url.pathname;
const translatePath = useTranslatedPath(defaultLang, lang);
---
<div class="language-switcher-language-url" role="navigation">
<ul class="links">
<li
class:list={[lang === "en" && "is-active"]}
aria-current={lang === "en" ? "page" : undefined}
>
<a
href={translatePath(path, "en")}
class:list={["language-link", lang === "en" && "is-active"]}
hreflang="en-gb"
aria-current={lang === "en" ? "page" : undefined}
>
EN
</a>
</li>
<li
class:list={[lang === "es" && "is-active"]}
aria-current={lang === "es" ? "page" : undefined}
>
<a
href={translatePath(path, "es")}
class:list={["language-link", lang === "es" && "is-active"]}
hreflang="es"
aria-current={lang === "es" ? "page" : undefined}
>
ES
</a>
</li>
</ul>
</div>
<style>
a {
text-decoration-color: transparent;
transition: text-decoration-color ease-in-out 200ms;
}
.language-switcher-language-url {
flex: none;
}
.language-switcher-language-url .links {
display: flex;
list-style: none;
padding: 0;
margin-inline-start: var(--space-2xs);
}
.language-switcher-language-url .links li:first-child::after {
display: inline-flex;
content: "|";
}
.language-switcher-language-url .links a {
margin: var(--space-3xs);
padding: var(--space-xs) var(--space-2xs);
text-underline-offset: 8px;
text-decoration: underline 1.5px transparent;
color: var(--color-primary-fallback);
color: var(--color-primary);
}
.language-switcher-language-url .links a.is-active {
text-decoration-color: currentColor;
}
.language-switcher-language-url .links a:hover {
background-color: var(--color-nav-hover);
border-radius: var(--border-radius);
}
@media screen and (max-width: 1159px) {
.language-switcher-language-url {
position: absolute;
top: 25px;
right: calc(var(--space-m) + var(--space-xs) + 24px);
}
}
</style>