Skip to content

Commit

Permalink
add dark colors and update images
Browse files Browse the repository at this point in the history
  • Loading branch information
insectengine committed Apr 23, 2024
1 parent ebc64c4 commit 799bd05
Show file tree
Hide file tree
Showing 7 changed files with 99 additions and 34 deletions.
14 changes: 14 additions & 0 deletions site/_includes/layouts/base.vto
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
<link rel="apple-touch-icon" href="/apple-touch-icon.png">
<link rel="manifest" href="/site.webmanifest">
<link rel="preconnect" href="https://fonts.googleapis.com">
<script type="text/javascript" src="/assets/theme.js" inline></script>
<script type="text/javascript" src="/assets/scroll-toggle.js" inline></script>
{{- for x of page.data.scripts }}
<script type="text/javascript" src="{{ x }}"></script>
Expand Down Expand Up @@ -53,6 +54,19 @@
{{- /for }}
</ul>
</nav>
<button class="theme-toggle" id="theme-toggle" title="Toggles light & dark" aria-label="auto" aria-live="polite">
<svg
xmlns="http://www.w3.org/2000/svg"
aria-hidden="true"
class="theme-toggle__half-sun"
height="1em"
width="1em"
viewBox="0 0 32 32"
fill="currentColor"
>
<path d="M27.5 11.5v-7h-7L16 0l-4.5 4.5h-7v7L0 16l4.5 4.5v7h7L16 32l4.5-4.5h7v-7L32 16l-4.5-4.5zM16 25.4V6.6c5.2 0 9.4 4.2 9.4 9.4s-4.2 9.4-9.4 9.4z" />
</svg>
</button>
</header>
<main {{ if page.data.cssclasses }} class="{{ page.data.cssclasses |> join(' ') }}"{{ /if }}>
{{ content -}}
Expand Down
15 changes: 15 additions & 0 deletions site/_includes/scss/_colors.scss
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,19 @@ body {
--button-border-color: transparent;

background-color: var(--bg-primary);
}


.dark body {

--bg-primary: #1e1e1e;
--text-normal: #B3B3B3;
--border-color: #434343;
--bg-navigation-top: #011212;
--bg-navigation-bottom: #0f0f0f;
--fg-navigation: #c8c7c7;

a {color: #c8c7c7;}
a.button {color: var(--dark-green);}

}
4 changes: 3 additions & 1 deletion site/_includes/scss/text.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

body {
--button-border-radius: 30px;
color: var(--text-normal);
}

// General links
Expand Down Expand Up @@ -31,9 +32,10 @@ a.github,
.h-site-more,
.act-status-icon,
.aside-nav-icon {
min-height: var(--font-smaller);
min-width: var(--font-smaller);
svg {
height: var(--font-smaller);
width: var(--font-smaller);
}
}

Expand Down
40 changes: 40 additions & 0 deletions site/assets/theme.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
function setTheme() {
const storedTheme = localStorage.getItem('color-theme') || 'system';
document.documentElement.dataset.storedTheme = storedTheme;
let theme_color = "#fafafa";
if (storedTheme === 'dark' || (storedTheme === 'system' && window.matchMedia('(prefers-color-scheme: dark)').matches)) {
document.documentElement.classList.add('dark');
theme_color = "#1e1e1e";
} else {
document.documentElement.classList.remove('dark');
}
return theme_color;
}
function toggleTheme() {
const themeOrder = ['dark', 'light', 'system'];
const storedTheme = localStorage.getItem('color-theme') || 'system';
const newTheme = themeOrder[(themeOrder.indexOf(storedTheme) + 1) % themeOrder.length];
localStorage.setItem('color-theme', newTheme);
document.querySelector('meta[name="theme-color"]').content = setTheme();
updateButton();
}
function updateButton() {
const button = document.getElementById('theme-toggle');
const storedTheme = localStorage.getItem('color-theme') || 'system';
const themeTitles = {
'dark': 'Color scheme: dark; next: light',
'light': 'Color scheme: light; next: system preferences',
'system': 'Color scheme: system preferences; next: dark'
};
button.setAttribute('aria-label', storedTheme);
button.setAttribute('title', themeTitles[storedTheme]);
return button;
}
const meta = document.createElement('meta');
meta.name = "theme-color";
meta.content = setTheme();
document.head.appendChild(meta);
window.onload = function() {
const button = updateButton();
button.addEventListener('click', toggleTheme);
};
28 changes: 12 additions & 16 deletions site/static/images/home_access.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 4 additions & 6 deletions site/static/images/home_homeburst.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 799bd05

Please sign in to comment.