Skip to content

Commit 038f444

Browse files
committed
UPD: Some darks
1 parent 1b675c4 commit 038f444

File tree

2 files changed

+78
-15
lines changed

2 files changed

+78
-15
lines changed

index.html

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,87 @@
1313
width: 100%;
1414
height: 100%;
1515
}
16+
17+
.aside {
18+
position: fixed;
19+
bottom: 5px;
20+
right: 5px;
21+
}
22+
23+
.w-5 { width: 20px; }
24+
.h-5 { height: 20px; }
25+
26+
.hidden { display: none; }
1627
</style>
1728
</head>
1829
<body class="d-flex flex-column">
1930
<div id="app" class="d-flex flex-column h-100"></div>
31+
32+
<aside class="aside">
33+
<span id="theme-toggle" type="button">
34+
<svg id="light-icon" class="hidden w-5 h-5" fill="currentColor" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg">
35+
<path d="M17.293 13.293A8 8 0 016.707 2.707a8.001 8.001 0 1010.586 10.586z"></path>
36+
</svg>
37+
<svg id="dark-icon" class="hidden w-5 h-5" fill="currentColor" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg">
38+
<path d="M10 2a1 1 0 011 1v1a1 1 0 11-2 0V3a1 1 0 011-1zm4 8a4 4 0 11-8 0 4 4 0 018 0zm-.464 4.95l.707.707a1 1 0 001.414-1.414l-.707-.707a1 1 0 00-1.414 1.414zm2.12-10.607a1 1 0 010 1.414l-.706.707a1 1 0 11-1.414-1.414l.707-.707a1 1 0 011.414 0zM17 11a1 1 0 100-2h-1a1 1 0 100 2h1zm-7 4a1 1 0 011 1v1a1 1 0 11-2 0v-1a1 1 0 011-1zM5.05 6.464A1 1 0 106.465 5.05l-.708-.707a1 1 0 00-1.414 1.414l.707.707zm1.414 8.486l-.707.707a1 1 0 01-1.414-1.414l.707-.707a1 1 0 011.414 1.414zM4 11a1 1 0 100-2H3a1 1 0 000 2h1z" fill-rule="evenodd" clip-rule="evenodd"></path>
39+
</svg>
40+
<span/>
41+
</aside>
42+
43+
<script>
44+
const docElm = document.documentElement;
45+
const themeToggleBtn = docElm.querySelector("#theme-toggle");
46+
const darkIcon = themeToggleBtn.querySelector("#dark-icon");
47+
const lightIcon = themeToggleBtn.querySelector("#light-icon");
48+
49+
if (localStorage.getItem("color-theme") === "dark") {
50+
darkIcon.classList.remove("hidden");
51+
docElm.classList.remove("light");
52+
docElm.classList.add("dark");
53+
docElm.dataset.bsTheme = "dark";
54+
} else {
55+
if ((!('color-theme' in localStorage)) && (window.matchMedia('(prefers-color-scheme: dark)').matches)) {
56+
darkIcon.classList.remove("hidden");
57+
docElm.classList.remove("light");
58+
docElm.classList.add("dark");
59+
docElm.dataset.bsTheme = "dark";
60+
localStorage.setItem("color-theme", "dark");
61+
} else {
62+
lightIcon.classList.remove("hidden");
63+
docElm.classList.remove("dark");
64+
docElm.classList.add("light");
65+
docElm.dataset.bsTheme = "light";
66+
localStorage.setItem("color-theme", "light");
67+
}
68+
}
69+
70+
themeToggleBtn.addEventListener("click", function () {
71+
darkIcon.classList.toggle("hidden");
72+
lightIcon.classList.toggle("hidden");
73+
74+
if (localStorage.getItem("color-theme")) {
75+
if (localStorage.getItem("color-theme") === "light") {
76+
docElm.classList.add("dark");
77+
docElm.dataset.bsTheme = "dark";
78+
localStorage.setItem("color-theme", "dark");
79+
} else {
80+
docElm.classList.remove("dark");
81+
docElm.dataset.bsTheme = "light";
82+
localStorage.setItem("color-theme", "light");
83+
}
84+
} else {
85+
if (docElm.classList.contains("dark")) {
86+
docElm.classList.remove("dark");
87+
docElm.dataset.bsTheme = "light";
88+
localStorage.setItem("color-theme", "light");
89+
} else {
90+
docElm.classList.add("dark");
91+
docElm.dataset.bsTheme = "dark";
92+
localStorage.setItem("color-theme", "dark");
93+
}
94+
}
95+
});
96+
</script>
2097
<script type="module" src="./src/main.ts"></script>
2198
</body>
2299
</html>

src/components/Nav.vue

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<template>
22
<div class="container">
3-
<nav class="navbar navbar-expand-lg navbar-light mb-4 border-bottom">
3+
<nav class="navbar navbar-expand-lg mb-4 border-bottom">
44
<router-link :to="routes[0].path" class="navbar-brand d-flex align-items-center text-dark text-decoration-none">
55
<svg xmlns="http://www.w3.org/2000/svg" height="32" viewBox="0 0 261.76 226.69">
66
<path d="M161.096.001l-30.225 52.351L100.647.001H-.005l130.877 226.688L261.749.001z" fill="#41b883" />
@@ -69,20 +69,6 @@ const isActive = (path: string) => path === activeRoute.value;
6969
</script>
7070

7171
<style lang="scss" scoped>
72-
$blc: #000;
73-
$lblc: rgba($blc, 0.5);
74-
75-
a {
76-
text-decoration: none;
77-
color: $lblc;
78-
transition: all 0.25s;
79-
80-
&.nav-link.router-link-active.router-link-exact-active,
81-
&:hover {
82-
color: $blc;
83-
}
84-
}
85-
8672
ul {
8773
list-style: none;
8874
}

0 commit comments

Comments
 (0)