-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Progressively enhance theme toggler: use system default when JS not a…
…vailable
- Loading branch information
1 parent
f5d341c
commit c714f8c
Showing
12 changed files
with
160 additions
and
60 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
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,5 +1,17 @@ | ||
// @ts-check | ||
// Adapted from: http://www.quirksmode.org/js/cookies.html | ||
|
||
/** | ||
* @param {string} name | ||
* @param {string} value | ||
*/ | ||
export function createCookie(name, value) { | ||
document.cookie = name + '=' + value + '; SameSite=Strict; path=/'; | ||
} | ||
|
||
/** | ||
* @param {string} name | ||
*/ | ||
export function removeCookie(name) { | ||
document.cookie = name + '=; SameSite=Strict; path=/'; | ||
} |
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,3 @@ | ||
pc-event-form { | ||
display: block; | ||
} |
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 |
---|---|---|
@@ -1,7 +1,19 @@ | ||
[data-theme='dark'] #theme-dark { | ||
@media (prefers-color-scheme: dark) { | ||
html:not([data-theme]) #theme-dark { | ||
display: none; | ||
} | ||
} | ||
|
||
@media (prefers-color-scheme: light) { | ||
html:not([data-theme]) #theme-light { | ||
display: none; | ||
} | ||
} | ||
|
||
html[data-theme='dark'] #theme-dark { | ||
display: none; | ||
} | ||
|
||
[data-theme='light'] #theme-light { | ||
html[data-theme='light'] #theme-light { | ||
display: none; | ||
} |
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,6 +1,10 @@ | ||
{% import 'macros/icons.njk' as icons %} | ||
|
||
<button is="pc-theme-toggler" aria-hidden="true" class="pc-btn pc-btn--secondary pc-btn--circle"> | ||
{{ icons.sun({id: 'theme-light'}) }} | ||
{{ icons.moon({id: 'theme-dark'}) }} | ||
</button> | ||
<pc-theme-toggler data-theme="{{ theme }}"> | ||
<template> | ||
<button aria-hidden="true" class="pc-btn pc-btn--secondary pc-btn--circle"> | ||
{{ icons.sun({id: 'theme-light'}) }} | ||
{{ icons.moon({id: 'theme-dark'}) }} | ||
</button> | ||
</template> | ||
</pc-theme-toggler> |
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