blob: 21dcc60d3c4fa0bdf29f4123a5c8af012fe97afc (
plain)
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
|
---
import "@styles/terminal.css";
import Nav from "@components/Nav.astro";
import Head from "@components/Head.astro";
interface Props {
path: string;
}
const { path: title } = Astro.props;
---
<!doctype html>
<html lang="en">
<Head title=`${title}` description="My personal website" />
<body>
<main
class="w-[95vw] h-[97vh] p-[2.2svh] text-[3vw]
sm:w-[68.75vw] sm:h-[35vw] sm:p-[2.2vw] sm:text-[1.125vw] sm:border-[0.2vw] sm:border-solid"
>
<Nav path={title} />
<slot />
</main>
</body>
</html>
<style>
main {
display: block;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
background: var(--background);
font-weight: 300;
}
</style>
<script>
function setTheme(theme) {
const root = document.documentElement;
// Get current values from root
const computed = getComputedStyle(root);
const existingTheme = {};
const themeKeys = ["primary", "secondary", "accent", "extra", "text", "alt", "background", "font"];
themeKeys.forEach(key => {
existingTheme[key] = theme[key] ?? computed.getPropertyValue(`--${key}`).trim();
root.style.setProperty(`--${key}`, existingTheme[key]);
});
localStorage.setItem("theme", JSON.stringify(existingTheme));
}
function loadTheme() {
const savedTheme = localStorage.getItem("theme");
if (savedTheme) {
setTheme(JSON.parse(savedTheme));
}
}
// Attach to window so it's accessible globally
window.setTheme = setTheme;
// Load theme on page load
loadTheme();
</script>
|