From 4e30ae95eaf52a7f427bdf020d118f40e00ab291 Mon Sep 17 00:00:00 2001 From: Zach Berwaldt Date: Mon, 9 Oct 2023 13:41:04 -0400 Subject: add some homemade svg, wpartials, and darkmode --- assets/Fullscreen.svg | 19 ++++++++++++ assets/Smallscreen.svg | 21 ++++++++++++++ assets/css/main.css | 59 +++++++++++++++++++++++++++++++++++++- assets/js/darkmode.js | 11 +++++++ assets/js/fullscreen.js | 27 ++++++++++++++--- layouts/_default/baseof.html | 2 +- layouts/partials/func/GetSvg.html | 5 ++++ layouts/partials/head.html | 4 +-- layouts/partials/scripts.html | 3 +- layouts/partials/site-actions.html | 12 ++++++++ 10 files changed, 154 insertions(+), 9 deletions(-) create mode 100755 assets/Fullscreen.svg create mode 100755 assets/Smallscreen.svg create mode 100644 assets/js/darkmode.js create mode 100644 layouts/partials/func/GetSvg.html create mode 100644 layouts/partials/site-actions.html diff --git a/assets/Fullscreen.svg b/assets/Fullscreen.svg new file mode 100755 index 0000000..0de34f0 --- /dev/null +++ b/assets/Fullscreen.svg @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + + diff --git a/assets/Smallscreen.svg b/assets/Smallscreen.svg new file mode 100755 index 0000000..de417ed --- /dev/null +++ b/assets/Smallscreen.svg @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/css/main.css b/assets/css/main.css index 97d1f73..a7d2bf8 100644 --- a/assets/css/main.css +++ b/assets/css/main.css @@ -17,6 +17,35 @@ footer { background: #00000055; } +.fixed { + position: fixed; + top: 0; +} + +#actions { + width: 100%; + padding: .5rem; +} + +#actions button:first-of-type { + margin-right: 1rem; +} + +#actions button { + background: transparent; + border: none; + width: fit-content; + padding: 0; +} + +#actions button:hover { + color:aquamarine !important; +} + +.aligned.right { + justify-content: flex-end; +} + .flex { display: flex; } @@ -25,6 +54,11 @@ footer { flex-direction: row; } +.centered { + align-items: center; + justify-content: center; +} + .flex.col { flex-direction: column; } @@ -75,4 +109,27 @@ footer { text-transform: uppercase; font-weight: 600; } - \ No newline at end of file + +.icon svg { + width: 1em; + height: 1em; + margin-right: .4em; +} + +.hide { + display: none; +} + +.icon:hover { + color: inherit !important; +} + +html[data-theme="dark"] .icon, +html[data-theme="dark"] #actions button { + color: white; +} + +html[data-theme="light"] .icon, +html[data-theme="light"] #actions button { + color: #24333e; +} \ No newline at end of file diff --git a/assets/js/darkmode.js b/assets/js/darkmode.js new file mode 100644 index 0000000..c6094d0 --- /dev/null +++ b/assets/js/darkmode.js @@ -0,0 +1,11 @@ +// get with web apis #fullscren element and on click toggle fullscreen +const darkmode = document.getElementById('darkmode'); +const html = document.querySelector('html'); +darkmode.addEventListener('click', () => { + if (html.dataset.theme === 'dark') { + html.dataset.theme = 'light'; + } else { + html.dataset.theme = 'dark'; + } +}); + diff --git a/assets/js/fullscreen.js b/assets/js/fullscreen.js index e191854..e3cc342 100644 --- a/assets/js/fullscreen.js +++ b/assets/js/fullscreen.js @@ -1,15 +1,27 @@ -// get with web apis #fullscren element and on click toggle fullscreen +// page const fullscreen = document.getElementById('fullscreen'); +const fullscreenIcon = document.getElementById('fullscreen-icon'); +const smallscreenIcon = document.getElementById('smallscreen-icon'); const elem = document.documentElement; -fullscreen.addEventListener('click', () => { + +// Functions + +function toggleFullscreen(event) { + // check if the event is a keydown event or a click event + if (event.type === 'keydown') { + // check if the key pressed is '/' key + if (event.key !== '/') return; + } if (document.fullscreenElement) { closeFullscreen(); } else { openFullscreen(); } -}); +} function openFullscreen() { + smallscreenIcon.classList.toggle('hide'); + fullscreenIcon.classList.toggle('hide'); if (elem.requestFullscreen) { elem.requestFullscreen(); } else if (elem.webkitRequestFullscreen) { /* Safari */ @@ -20,6 +32,8 @@ function openFullscreen() { } function closeFullscreen() { + smallscreenIcon.classList.toggle('hide'); + fullscreenIcon.classList.toggle('hide'); if (document.exitFullscreen) { document.exitFullscreen(); } else if (document.webkitExitFullscreen) { /* Safari */ @@ -27,4 +41,9 @@ function closeFullscreen() { } else if (document.msExitFullscreen) { /* IE11 */ document.msExitFullscreen(); } -} \ No newline at end of file +} + +// Listeners + +fullscreen.addEventListener('click', toggleFullscreen); +document.addEventListener('keydown', toggleFullscreen); \ No newline at end of file diff --git a/layouts/_default/baseof.html b/layouts/_default/baseof.html index bb27232..cceaa25 100644 --- a/layouts/_default/baseof.html +++ b/layouts/_default/baseof.html @@ -2,7 +2,7 @@ {{- partial "head.html" . -}} - + {{- partial "site-actions" . -}} {{- partial "header.html" . -}}
{{ .Title }} - + {{ end }} {{ with resources.Get "css/main.css" }} {{ end }} diff --git a/layouts/partials/scripts.html b/layouts/partials/scripts.html index 152c32b..f7c95bd 100644 --- a/layouts/partials/scripts.html +++ b/layouts/partials/scripts.html @@ -1,4 +1,5 @@ {{ $scripts := resources.Match "js/*.js" }} {{ range $script := $scripts }} + {{ $script := $script | minify | fingerprint }} -{{ end }} \ No newline at end of file +{{ end }} diff --git a/layouts/partials/site-actions.html b/layouts/partials/site-actions.html new file mode 100644 index 0000000..b9afa66 --- /dev/null +++ b/layouts/partials/site-actions.html @@ -0,0 +1,12 @@ +
+ + +
\ No newline at end of file -- cgit v1.1