website

#astro#js#html#css

git clone https://git.pyrossh.dev/website

木 Personal website of pyrossh. Built with astrojs, shiki, vite.


e2ac26b — pyrossh 2025-09-27T18:45:05+05:30
add theme switch

Generated files not shown: bun.lock

astro.config.mjs CHANGED
@@ -1,5 +1,6 @@
1
1
  // @ts-check
2
2
  import { defineConfig, fontProviders } from 'astro/config';
3
+ import icon from "astro-icon";
3
4
  import mdx from '@astrojs/mdx';
4
5
  import sitemap from '@astrojs/sitemap';
5
6
 
@@ -9,6 +10,7 @@ export default defineConfig({
9
10
  trailingSlash: 'never',
10
11
  output: 'static',
11
12
  integrations: [
13
+ icon(),
12
14
  mdx(),
13
15
  sitemap(),
14
16
  ],
package.json CHANGED
@@ -18,10 +18,13 @@
18
18
  "@astrojs/rss": "^4.0.12",
19
19
  "@astrojs/sitemap": "^3.4.1",
20
20
  "astro": "^5.9.0",
21
+ "astro-color-scheme": "^1.1.5",
22
+ "astro-icon": "^1.1.5",
21
23
  "simple-git": "^3.27.0",
22
24
  "timeago.js": "^4.0.2"
23
25
  },
24
26
  "devDependencies": {
27
+ "@iconify-json/material-symbols": "^1.2.39",
25
28
  "@playwright/test": "^1.52.0",
26
29
  "@tauri-apps/cli": "^2.8.1",
27
30
  "@types/node": "^22.15.3"
src/assets/icons/moon.svg DELETED
@@ -1,4 +0,0 @@
1
- <?xml version="1.0" encoding="utf-8"?><!-- Uploaded to: SVG Repo, www.svgrepo.com, Generator: SVG Repo Mixer Tools -->
2
- <svg width="24px" height="24px" viewBox="0 0 24 24" fill="currentColor" xmlns="http://www.w3.org/2000/svg">
3
- <path d="M12 22C17.5228 22 22 17.5228 22 12C22 11.5373 21.3065 11.4608 21.0672 11.8568C19.9289 13.7406 17.8615 15 15.5 15C11.9101 15 9 12.0899 9 8.5C9 6.13845 10.2594 4.07105 12.1432 2.93276C12.5392 2.69347 12.4627 2 12 2C6.47715 2 2 6.47715 2 12C2 17.5228 6.47715 22 12 22Z" />
4
- </svg>
src/assets/icons/sun.svg DELETED
@@ -1 +0,0 @@
1
- <svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><g id="SVGRepo_bgCarrier" stroke-width="0"></g><g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round"></g><g id="SVGRepo_iconCarrier"> <path d="M17 12C17 14.7614 14.7614 17 12 17C9.23858 17 7 14.7614 7 12C7 9.23858 9.23858 7 12 7C14.7614 7 17 9.23858 17 12Z" fill="#f1fa8c"></path> <path fill-rule="evenodd" clip-rule="evenodd" d="M12 1.25C12.4142 1.25 12.75 1.58579 12.75 2V4C12.75 4.41421 12.4142 4.75 12 4.75C11.5858 4.75 11.25 4.41421 11.25 4V2C11.25 1.58579 11.5858 1.25 12 1.25ZM3.66865 3.71609C3.94815 3.41039 4.42255 3.38915 4.72825 3.66865L6.95026 5.70024C7.25596 5.97974 7.2772 6.45413 6.9977 6.75983C6.7182 7.06553 6.2438 7.08677 5.9381 6.80727L3.71609 4.77569C3.41039 4.49619 3.38915 4.02179 3.66865 3.71609ZM20.3314 3.71609C20.6109 4.02179 20.5896 4.49619 20.2839 4.77569L18.0619 6.80727C17.7562 7.08677 17.2818 7.06553 17.0023 6.75983C16.7228 6.45413 16.744 5.97974 17.0497 5.70024L19.2718 3.66865C19.5775 3.38915 20.0518 3.41039 20.3314 3.71609ZM1.25 12C1.25 11.5858 1.58579 11.25 2 11.25H4C4.41421 11.25 4.75 11.5858 4.75 12C4.75 12.4142 4.41421 12.75 4 12.75H2C1.58579 12.75 1.25 12.4142 1.25 12ZM19.25 12C19.25 11.5858 19.5858 11.25 20 11.25H22C22.4142 11.25 22.75 11.5858 22.75 12C22.75 12.4142 22.4142 12.75 22 12.75H20C19.5858 12.75 19.25 12.4142 19.25 12ZM17.0255 17.0252C17.3184 16.7323 17.7933 16.7323 18.0862 17.0252L20.3082 19.2475C20.6011 19.5404 20.601 20.0153 20.3081 20.3082C20.0152 20.6011 19.5403 20.601 19.2475 20.3081L17.0255 18.0858C16.7326 17.7929 16.7326 17.3181 17.0255 17.0252ZM6.97467 17.0253C7.26756 17.3182 7.26756 17.7931 6.97467 18.086L4.75244 20.3082C4.45955 20.6011 3.98468 20.6011 3.69178 20.3082C3.39889 20.0153 3.39889 19.5404 3.69178 19.2476L5.91401 17.0253C6.2069 16.7324 6.68177 16.7324 6.97467 17.0253ZM12 19.25C12.4142 19.25 12.75 19.5858 12.75 20V22C12.75 22.4142 12.4142 22.75 12 22.75C11.5858 22.75 11.25 22.4142 11.25 22V20C11.25 19.5858 11.5858 19.25 12 19.25Z" fill="#f1fa8c"></path> </g></svg>
src/components/Header.astro CHANGED
@@ -1,8 +1,8 @@
1
1
  ---
2
+ import { Icon } from "astro-icon/components";
3
+ import { ThemeSwitch } from "astro-color-scheme";
2
4
  import HeaderLink from "./HeaderLink.astro";
3
5
  import Wrapper from "./Wrapper.astro";
4
- import Moon from "@/assets/icons/moon.svg";
5
- import Sun from "@/assets/icons/sun.svg";
6
6
  ---
7
7
 
8
8
  <header>
@@ -10,22 +10,12 @@ import Sun from "@/assets/icons/sun.svg";
10
10
  <nav>
11
11
  <HeaderLink class="logo" href="/"> 木 pyrossh </HeaderLink>
12
12
  <div class="links">
13
+ <ThemeSwitch strategy="button">
13
- <button id="theme-change">
14
+ <button id="theme-change">
14
- <Moon id="dark" style="display: none;" width={"1em"} height={"1em"} />
15
+ <Icon class="sun" style="display: var(--btn-light);" name="material-symbols:sunny-rounded" />
15
- <Sun id="light" width={"1em"} height={"1em"} />
16
+ <Icon class="moon" style="display: var(--btn-dark);" name="material-symbols:moon-stars" />
16
- </button>
17
+ </button>
17
- <script>
18
- const button = document.getElementById("theme-change")!;
19
- document.getElementById("dark")!.style.display = "none";
20
- button.addEventListener("click", () => {
21
- const currentTheme =
22
- document.documentElement.getAttribute("theme") || "dark";
23
- const newTheme = currentTheme === "dark" ? "light" : "dark";
24
- document.documentElement.setAttribute("theme", newTheme);
25
- document.getElementById(currentTheme)!.style.display = "block";
26
- document.getElementById(newTheme)!.style.display = "none";
27
- });
28
- </script>
18
+ </ThemeSwitch>
29
19
  <div>|</div>
30
20
  <HeaderLink href="/cv">cv</HeaderLink>
31
21
  <div>|</div>
@@ -72,9 +62,14 @@ import Sun from "@/assets/icons/sun.svg";
72
62
  line-height: 56px;
73
63
  color: white;
74
64
 
65
+ #astro-color-scheme-switch {
66
+ display: flex;
67
+ align-items: center;
68
+
75
- button {
69
+ button {
76
- padding-right: 12px;
70
+ padding-right: 12px;
77
- cursor: pointer;
71
+ cursor: pointer;
72
+ }
78
73
  }
79
74
 
80
75
  a {
src/layouts/Base.css CHANGED
@@ -1,7 +1,22 @@
1
1
  :root {
2
- --color-accent: #f1fa8c;
3
2
  --color-black: #000000;
4
3
  --color-white: #ffffff;
4
+ --color-accent: #f1fa8c;
5
+ --color-body-bg: #ffffff;
6
+ --color-text: #222;
7
+ --color-card-link: #0600ff;
8
+ --color-box-bg: #f1f5f9;
9
+ --color-link: #0600ff;
10
+ --color-post-link: #000000;
11
+ --color-highlight-bg: #9befee;
12
+ --color-code-fg: #d14;
13
+ --color-md-table-bg: #343a40;
14
+ --btn-light: none;
15
+ --btn-dark: block;
16
+ }
17
+
18
+ [data-theme="light"] {
19
+ --color-accent: #f1fa8c;
5
20
  --color-body-bg: #212529;
6
21
  --color-text: #f8f9fa;
7
22
  --color-card-link: #3395ff;
@@ -11,19 +26,8 @@
11
26
  --color-highlight-bg: #703be1;
12
27
  --color-code-fg: rgb(244, 176, 176);
13
28
  --color-md-table-bg: #343a40;
14
- }
15
-
16
- [theme='light'] {
17
- --color-accent: #f1fa8c;
18
- --color-body-bg: #ffffff;
19
- --color-text: #222;
29
+ --btn-light: block;
20
- --color-card-link: #000000;
21
- --color-box-bg: #f1f5f9;
22
- --color-link: #1c398e;
30
+ --btn-dark: none;
23
- --color-post-link: #000000;
24
- --color-highlight-bg: #9befee;
25
- --color-code-fg: #d14;
26
- --color-md-table-bg: #343a40;
27
31
  }
28
32
 
29
33
  body {
@@ -39,6 +43,7 @@ body {
39
43
  font-size: 14pt;
40
44
  line-height: 1.6;
41
45
  min-height: 100vh;
46
+
42
47
  @media (max-width: 720px) {
43
48
  font-size: 13pt;
44
49
  }
src/pages/index.module.css CHANGED
@@ -105,6 +105,7 @@ section {
105
105
  grid-template-columns: auto auto auto;
106
106
  text-align: center;
107
107
  margin-top: 1rem;
108
+ font-size: 0.95em;
108
109
 
109
110
  li {
110
111
  background-color: var(--color-box-bg);
@@ -126,6 +127,7 @@ section {
126
127
  align-items: baseline;
127
128
  padding: 0.25rem;
128
129
  background-color: var(--color-box-bg);
130
+ font-size: 0.95em;
129
131
 
130
132
  @media (max-width: 720px) {
131
133
  flex-direction: column;