💄 make darkmode standard theme when no javascript
Signed-off-by: Sindre Kjelsrud <kjelsrudsindre@gmail.com>
This commit is contained in:
parent
de636d43d6
commit
791fe66ccf
3 changed files with 34 additions and 34 deletions
|
@ -8,9 +8,9 @@ const today = new Date();
|
|||
|
||||
const updateImageForTheme = () => {
|
||||
const currentTheme = document.documentElement.classList.contains('dark') ? 'dark' : 'light';
|
||||
githubImage.src = currentTheme === 'dark' ? '/socials/github_dark.svg' : '/socials/github_light.svg';
|
||||
spotifyImage.src = currentTheme === 'dark' ? '/socials/spotify_dark.svg' : '/socials/spotify_light.svg';
|
||||
webringImage.src = currentTheme === 'dark' ? '/socials/webring_dark.svg' : '/socials/webring_light.svg';
|
||||
githubImage.src = currentTheme === 'dark' ? '/socials/github_light.svg' : '/socials/github_dark.svg';
|
||||
spotifyImage.src = currentTheme === 'dark' ? '/socials/spotify_light.svg' : '/socials/spotify_dark.svg';
|
||||
webringImage.src = currentTheme === 'dark' ? '/socials/webring_light.svg' : '/socials/webring_dark.svg';
|
||||
};
|
||||
|
||||
updateImageForTheme();
|
||||
|
@ -25,13 +25,13 @@ const today = new Date();
|
|||
<div>Sindre Kjelsrud © {today.getFullYear()}</div>
|
||||
<div class="flex gap-1">
|
||||
<a href="https://github.com/SindreKjelsrud" aria-label="Link to my GitHub">
|
||||
<img id="githubImage" height="30" width="30" src="/socials/github_light.svg" alt="GitHub"/>
|
||||
<img id="githubImage" height="30" width="30" src="/socials/github_dark.svg" alt="GitHub"/>
|
||||
</a>
|
||||
<a href="https://open.spotify.com/user/kjelsrud!" aria-label="Link to my Spotify">
|
||||
<img id="spotifyImage" height="30" width="30" src="/socials/spotify_light.svg" alt="Spotify"/>
|
||||
<img id="spotifyImage" height="30" width="30" src="/socials/spotify_dark.svg" alt="Spotify"/>
|
||||
</a>
|
||||
<a href="https://webring.xxiivv.com/#sid" target="_blank" rel="noopener">
|
||||
<img id="webringImage" height="30" width="30" src="/socials/webring_light.svg" alt="XXIIVV webring"/>
|
||||
<img id="webringImage" height="30" width="30" src="/socials/webring_dark.svg" alt="XXIIVV webring"/>
|
||||
</a>
|
||||
</div>
|
||||
</footer>
|
||||
|
|
|
@ -12,12 +12,12 @@
|
|||
border: 0;
|
||||
background: none;
|
||||
}
|
||||
.sun { fill: #3B2C29; }
|
||||
.moon { fill: transparent; }
|
||||
.sun { fill: transparent; }
|
||||
.moon { fill: #9AD3BB; }
|
||||
|
||||
|
||||
:global(.dark) .sun { fill: transparent; }
|
||||
:global(.dark) .moon { fill: #9AD3BB; }
|
||||
:global(.dark) .sun { fill: #3B2C29; }
|
||||
:global(.dark) .moon { fill: transparent; }
|
||||
</style>
|
||||
|
||||
<script is:inline>
|
||||
|
@ -25,16 +25,16 @@
|
|||
if (typeof localStorage !== 'undefined' && localStorage.getItem('theme')) {
|
||||
return localStorage.getItem('theme');
|
||||
}
|
||||
if (window.matchMedia('(prefers-color-scheme: dark)').matches) {
|
||||
return 'dark';
|
||||
}
|
||||
if (window.matchMedia('(prefers-color-scheme: light)').matches) {
|
||||
return 'light';
|
||||
}
|
||||
return 'dark';
|
||||
})();
|
||||
|
||||
if (theme === 'light') {
|
||||
document.documentElement.classList.remove('dark');
|
||||
if (theme === 'dark') {
|
||||
document.documentElement.classList.remove('light');
|
||||
} else {
|
||||
document.documentElement.classList.add('dark');
|
||||
document.documentElement.classList.add('light');
|
||||
}
|
||||
|
||||
window.localStorage.setItem('theme', theme);
|
||||
|
|
|
@ -14,13 +14,13 @@
|
|||
}
|
||||
|
||||
html {
|
||||
background-color: var(--light-bg);
|
||||
color: var(--light-1);
|
||||
background-color: var(--dark-bg);
|
||||
color: var(--dark-1);
|
||||
}
|
||||
|
||||
html.dark {
|
||||
background-color: var(--dark-bg);
|
||||
color: var(--dark-1);
|
||||
background-color: var(--light-bg);
|
||||
color: var(--light-1);
|
||||
}
|
||||
|
||||
body {
|
||||
|
@ -33,13 +33,13 @@ p {
|
|||
|
||||
/* FOOTER */
|
||||
.footerbg {
|
||||
background-color: var(--light-bg);
|
||||
border-top: 1px solid var(--light-1);
|
||||
background-color: var(--dark-bg);
|
||||
border-top: 1px solid var(--dark-1);
|
||||
}
|
||||
|
||||
.dark .footerbg {
|
||||
background-color: var(--dark-bg);
|
||||
border-top: 1px solid var(--dark-1);
|
||||
background-color: var(--light-bg);
|
||||
border-top: 1px solid var(--light-1);
|
||||
}
|
||||
|
||||
/* BLOG */
|
||||
|
@ -84,25 +84,25 @@ p {
|
|||
font-weight: 600;
|
||||
}
|
||||
|
||||
.blog a { color: var(--light-link);}
|
||||
.blog a { color: var(--dark-link);}
|
||||
|
||||
.dark .blog a { color: var(--dark-link);}
|
||||
.dark .blog a { color: var(--light-link);}
|
||||
|
||||
.blog a:hover { text-decoration: underline 2px;}
|
||||
|
||||
.blogtime { color: var(--light-2); }
|
||||
.blogtime { color: var(--dark-2); }
|
||||
|
||||
.dark .blogtime { color: var(--dark-2); }
|
||||
.dark .blogtime { color: var(--light-2); }
|
||||
|
||||
/* LOGS */
|
||||
.borderbottom {
|
||||
border-bottom-width: 2px;
|
||||
border-color: var(--light-3);
|
||||
border-color: var(--dark-3);
|
||||
}
|
||||
|
||||
.dark .borderbottom {
|
||||
border-bottom-width: 2px;
|
||||
border-color: var(--dark-3);
|
||||
border-color: var(--light-3);
|
||||
}
|
||||
|
||||
/* GALLERY */
|
||||
|
@ -134,11 +134,11 @@ p {
|
|||
}
|
||||
|
||||
.cv a {
|
||||
color: var(--light-link);
|
||||
color: var(--dark-link);
|
||||
font-size: small;
|
||||
}
|
||||
|
||||
.dark .cv a { color: var(--dark-link);}
|
||||
.dark .cv a { color: var(--light-link);}
|
||||
|
||||
.cv a:hover { text-decoration: underline 2px;;}
|
||||
|
||||
|
@ -162,10 +162,10 @@ code {
|
|||
|
||||
blockquote {
|
||||
padding: 0 0 0 10px;
|
||||
border-left: 5px solid var(--light-1);
|
||||
border-left: 5px solid var(--dark-1);
|
||||
}
|
||||
|
||||
.dark blockquote {
|
||||
padding: 0 0 0 10px;
|
||||
border-left: 5px solid var(--dark-1);
|
||||
border-left: 5px solid var(--light-1);
|
||||
}
|
Loading…
Reference in a new issue