Default to theme based on user pref (#13)

* Default to theme based on user pref

* Reset font-weight for tags
This commit is contained in:
Avijit Gupta
2021-06-04 18:06:23 +02:00
committed by GitHub
parent 3ab9fd2950
commit 35a0b3069b
2 changed files with 2 additions and 2 deletions

View File

@@ -98,7 +98,6 @@ html {
color: white;
display: inline-block;
font-size: 14px;
font-weight: 700;
padding: 4px 12px;
}
.post-tag a {

View File

@@ -13,7 +13,8 @@ function ready() {
darkThemeCss = document.getElementById("dark-theme");
// TODO: Fetch programatically by user's system preference
const savedTheme = localStorage.getItem(THEME_PREF_STORAGE_KEY) || 'light';
const savedTheme = localStorage.getItem(THEME_PREF_STORAGE_KEY) ||
window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark': 'light';
setTheme(savedTheme);
document.getElementById('dark-theme-toggle').addEventListener('click', () => {
if (toggleIcon.className === THEME_TO_ICON_CLASS.dark) {