-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: astro view transitions were blocked by global styles.
fix: theme reverted to default on route change, and toggle button would break until page was reloaded. feature: added about page for showcase
- Loading branch information
1 parent
6c6bfa7
commit aaf0b61
Showing
6 changed files
with
111 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,34 @@ | ||
<style is:global> | ||
::view-transition-old(root), | ||
::view-transition-new(root) { | ||
animation: none; | ||
mix-blend-mode: normal; | ||
} | ||
</style> | ||
<script is:inline> | ||
"use strict";(()=>{(()=>{let t="theme-toggle";function o(){return window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function l(){let e=localStorage.getItem(t);return e==="dark"||e==="light"?e:null}function n(){return l()||o()}function c(e){e===o()?localStorage.removeItem(t):localStorage.setItem(t,e)}function s(e){let m=document.documentElement;m.classList.toggle("dark",e==="dark"),m.style.colorScheme=e}function r(e){c(e),s(e)}r(n()),window.astroThemeToggle={setTheme:r,getTheme:n}})();})(); | ||
"use strict"; | ||
const themeToggle = () => { | ||
(() => { | ||
let t = "theme-toggle"; | ||
function o() { | ||
return window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light"; | ||
} | ||
function l() { | ||
let e = localStorage.getItem(t); | ||
return e === "dark" || e === "light" ? e : null; | ||
} | ||
function n() { | ||
return l() || o(); | ||
} | ||
function c(e) { | ||
e === o() ? localStorage.removeItem(t) : localStorage.setItem(t, e); | ||
} | ||
function s(e) { | ||
let m = document.documentElement; | ||
m.classList.toggle("dark", e === "dark"), (m.style.colorScheme = e); | ||
} | ||
function r(e) { | ||
c(e), s(e); | ||
} | ||
r(n()), (window.astroThemeToggle = { setTheme: r, getTheme: n }); | ||
})(); | ||
} | ||
themeToggle(); | ||
|
||
document.addEventListener("astro:after-swap", () => { | ||
themeToggle(); | ||
}); | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
--- | ||
import AstroLogoBackground from '../components/astro-logo-background.astro' | ||
import GithubCorner from '../components/github-corner.astro' | ||
import ThemeToggleButton from '../components/theme-toggle-button.astro' | ||
import Layout from '../layouts/Layout.astro' | ||
--- | ||
|
||
<Layout title="About page"> | ||
<main> | ||
<AstroLogoBackground /> | ||
<h1>about page</h1> | ||
<div class="instructions"> | ||
<span | ||
>Add a ripple-style theme toggle animation to your Astro project with | ||
ease</span | ||
> | ||
<a href="/">home</a> | ||
</div> | ||
<div class="instructions"> | ||
<ThemeToggleButton /> | ||
</div> | ||
<GithubCorner /> | ||
</main> | ||
</Layout> | ||
|
||
<style> | ||
main { | ||
margin: auto; | ||
padding: 1rem; | ||
width: 800px; | ||
max-width: calc(100% - 2rem); | ||
color: var(--text-color); | ||
font-size: 20px; | ||
line-height: 1.6; | ||
} | ||
|
||
h1 { | ||
font-size: 4rem; | ||
font-weight: 700; | ||
line-height: 1; | ||
text-align: center; | ||
margin-bottom: 1em; | ||
} | ||
|
||
.instructions { | ||
margin-bottom: 5rem; | ||
text-align: center; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters