1
1
---
2
2
interface Props {}
3
3
4
- import { getLangFromUrl , useTranslations } from ' ../i18n/utils' ;
5
- import { Image } from ' astro:assets' ;
6
- import aux from ' ../../public/aux.svg' ;
4
+ import { getLangFromUrl , useTranslations } from " ../i18n/utils" ;
5
+ import { Image } from " astro:assets" ;
6
+ import aux from " ../../public/aux.svg" ;
7
+ import { languages } from " ../i18n/ui" ;
7
8
8
9
const lang = getLangFromUrl (Astro .url );
9
10
const translation = useTranslations (lang );
10
11
---
11
12
12
- <header >
13
- <div class =" left" >
14
- <a href =" https://auxolotl.org" class =" brand" >
15
- <Image class =" icon" src ={ aux } alt =" auxolotl.org logo" />
16
- <span class =" title" >auxolotl.org</span >
13
+ <header
14
+ class =" sticky flex justify-between top-0 bg-[rgb(var(--background))] z-10 max-w-4xl mx-auto p-4 text-lg"
15
+ >
16
+ <div class =" flex items-center" >
17
+ <a href =" https://auxolotl.org" class =" flex items-center text-lg gap-4" >
18
+ <Image class =" w-12 h-12" src ={ aux } alt =" auxolotl.org logo" />
19
+ <span >Auxolotl</span >
17
20
</a >
18
21
</div >
19
22
<div class =" right" >
@@ -23,67 +26,36 @@ const translation = useTranslations(lang);
23
26
<li><a href="https://auxolotl.org/contribute">Contribute</a></li>
24
27
-->
25
28
26
- <li ><a href =" https://wiki.auxolotl.org" >Wiki</a ></li >
27
- <li ><a href =" https://forum.auxolotl.org" >{ translation (" header.community" )} </a ></li >
28
- <li ><a href =" https://github.com/auxolotl" >GitHub</a ></li >
29
- </ul >
30
- </nav >
31
- </div >
29
+ <nav >
30
+ <ul class =" flex gap-4 items-center h-full" >
31
+ <!--
32
+ <li><a href="https://auxolotl.org/contribute">Contribute</a></li>
33
+ -->
34
+
35
+ <li ><a href =" https://wiki.auxolotl.org" >Wiki</a ></li >
36
+ <li ><a href =" https://forum.auxolotl.org" >{ translation (" header.community" )} </a ></li >
37
+ <li ><a href =" https://github.com/auxolotl" >GitHub</a ></li >
38
+
39
+ <select data-lang-selector class =" bg-transparent" >
40
+ {
41
+ Object .keys (languages ).map ((lang ) => (
42
+ <option value = { lang } class = " text-black" >
43
+ { languages [lang as keyof typeof languages ]}
44
+ </option >
45
+ ))
46
+ }
47
+ </select >
48
+ </ul >
49
+ </nav >
32
50
</header >
33
51
34
- <style >
35
- header {
36
- position: sticky;
37
- display: flex;
38
- justify-content: space-between;
39
- top: 0;
40
- background: rgb(var(--background));
41
- padding: 0.5rem 0;
42
- z-index: 100;
43
- }
44
-
45
- .left {
46
- display: flex;
47
- align-items: center;
48
- padding-left: 0.5rem;
49
- }
50
-
51
- .left .brand {
52
- display: flex;
53
- align-items: center;
54
- font-size: 1.5rem;
55
- }
56
-
57
- .left .brand .title {
58
- padding-left: 0.5rem;
59
- }
60
-
61
- .icon {
62
- width: 48px;
63
- height: 48px;
64
- }
65
-
66
- .right {
67
- display: flex;
68
- justify-content: flex-end;
69
- align-items: center;
70
- padding-right: 1rem;
71
- }
72
-
73
- .right nav {
74
- display: flex;
75
- align-items: center;
76
- }
77
-
78
- .right nav ul {
79
- display: flex;
80
- list-style: none;
81
- }
82
-
83
- .right nav ul li {
84
- }
85
-
86
- .right nav ul li:not(:last-child) {
87
- margin-right: 1rem;
88
- }
89
- </style >
52
+ <script >
53
+ import { switchLang } from "../i18n/utils";
54
+ import type { languages } from "../i18n/ui";
55
+ const select: HTMLSelectElement | null = document.querySelector(
56
+ "[data-lang-selector]",
57
+ );
58
+ select?.addEventListener("change", () => {
59
+ switchLang(select.value as keyof typeof languages);
60
+ });
61
+ </script >
0 commit comments