Skip to content

Commit

Permalink
Fix responsive (colinhacks#3585)
Browse files Browse the repository at this point in the history
* Fix responsive

* Remove theme button

* Remove localstorage
  • Loading branch information
colinhacks authored Jun 19, 2024
1 parent 457a095 commit 826d6a2
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 25 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -196,9 +196,9 @@ Sponsorship at any level is appreciated and encouraged. For individual developer

<div align="center">
<a href="https://go.clerk.com/PKHrcwh">
<picture height="120px">
<picture height="120px" >
<source media="(prefers-color-scheme: dark)" srcset="https://github.com/colinhacks/zod/assets/3084745/167ea625-bf23-4f7b-afc2-1dbb0ad60a3e">
<img alt="speakeasy'" height="120px" src="https://github.com/colinhacks/zod/assets/3084745/68a43b31-62e5-4344-a112-7066dcf3d830">
<img alt="clerk logo" height="120px" src="https://github.com/colinhacks/zod/assets/3084745/68a43b31-62e5-4344-a112-7066dcf3d830">
</picture>
</a>
<br/>
Expand Down
12 changes: 6 additions & 6 deletions blog/index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!doctype html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
Expand Down Expand Up @@ -233,7 +233,7 @@
</head>

<body>
<div class="theme-btn"></div>
<!-- <div class="theme-btn"></div> -->
<div id="app"></div>
<script src="//cdnjs.cloudflare.com/ajax/libs/docsify/4.12.2/docsify.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/prism/1.28.0/components/prism-typescript.min.js"></script>
Expand Down Expand Up @@ -264,23 +264,23 @@
auto2top: true,
repo: "colinhacks/zod",
routerMode: "history",
homepage: 'clerk-fellowship.md',
homepage: "clerk-fellowship.md",
crossOriginLinks: [
"https://twitter.com/colinhacks",
"https://github.com/sponsors/colinhacks",
"https://twitter.com/tweetsbycolin",
"https://authjs.dev",
"https://authjs.dev/getting-started"
"https://authjs.dev/getting-started",
],
};
</script>
<script>
<!-- <script>
window.addEventListener("DOMContentLoaded", () => {
document
.querySelector("aside")
.prepend(document.querySelector(".theme-btn"));
});
</script>
</script> -->
<script src="https://www.unpkg.com/zod/lib/index.umd.js"></script>
</body>
</html>
4 changes: 2 additions & 2 deletions deno/lib/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -196,9 +196,9 @@ Sponsorship at any level is appreciated and encouraged. For individual developer

<div align="center">
<a href="https://go.clerk.com/PKHrcwh">
<picture height="120px">
<picture height="120px" >
<source media="(prefers-color-scheme: dark)" srcset="https://github.com/colinhacks/zod/assets/3084745/167ea625-bf23-4f7b-afc2-1dbb0ad60a3e">
<img alt="speakeasy'" height="120px" src="https://github.com/colinhacks/zod/assets/3084745/68a43b31-62e5-4344-a112-7066dcf3d830">
<img alt="clerk logo" height="120px" src="https://github.com/colinhacks/zod/assets/3084745/68a43b31-62e5-4344-a112-7066dcf3d830">
</picture>
</a>
<br/>
Expand Down
61 changes: 46 additions & 15 deletions index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!doctype html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
Expand Down Expand Up @@ -221,31 +221,62 @@
.dark .theme-btn {
background-image: url("./static/sun.svg");
}
/* .dark .light-mode-logo {
display: block !important;
}
@media (prefers-color-scheme: light) {
.dark .light-mode-logo {
display: block !important;
}
.dark picture {
display: none;
}
.dark .light-mode-logo {
display: none !important;
}
} */
</style>
</head>

<body>
<div class="theme-btn"></div>
<body data-theme="dark">
<!-- <div class="theme-btn"></div> -->
<div id="app"></div>
<script src="//cdnjs.cloudflare.com/ajax/libs/docsify/4.12.2/docsify.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/prism/1.28.0/components/prism-typescript.min.js"></script>
<script>
toggleDarkTheme(localStorage.getItem("dark-theme") === "true" || false);
localStorage.removeItem("dark-theme");
function checkDark() {
return (
// localStorage.getItem("dark-theme") === "true" ??
window.matchMedia("(prefers-color-scheme: dark)").matches ?? false
);
}

let isDark = checkDark();
toggleDarkTheme(isDark);

window
.matchMedia("(prefers-color-scheme: dark)")
.addEventListener("change", (e) => toggleDarkTheme(e.matches));
.addEventListener("change", (e) => toggleDarkTheme(e.matches()));

document.querySelector(".theme-btn").addEventListener("click", () => {
const isDark = checkDark();
console.log("isDark", isDark);
toggleDarkTheme(!isDark);
});

document
.querySelector(".theme-btn")
.addEventListener("click", () => toggleDarkTheme());
function toggleDarkTheme(isDark) {
if (isDark) {
document.body.classList.add("dark");
} else {
document.body.classList.remove("dark");
}

function toggleDarkTheme(force) {
document.body.classList.toggle("dark", force);
localStorage.setItem(
"dark-theme",
document.body.classList.contains("dark")
document.documentElement.setAttribute(
"data-theme",
isDark ? "dark" : "light"
);
// localStorage.setItem("dark-theme", isDark ? "true" : "false");
}
</script>

Expand All @@ -271,13 +302,13 @@
],
};
</script>
<script>
<!-- <script>
window.addEventListener("DOMContentLoaded", () => {
document
.querySelector("aside")
.prepend(document.querySelector(".theme-btn"));
});
</script>
</script> -->
<script src="https://www.unpkg.com/zod/lib/index.umd.js"></script>
</body>
</html>

0 comments on commit 826d6a2

Please sign in to comment.