diff --git a/Makefile b/Makefile index e31cc76..46241a1 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,7 @@ run: @go run main.go templ: - @templ generate -watch -proxy=http://localhost:3000 + @templ generate -watch -proxy=http://127.0.0.1:3000 sass: @sass --no-source-map --watch view/stylesheets/tallytome.scss public/tallytome.css diff --git a/README.md b/README.md index b53d23f..625e622 100644 --- a/README.md +++ b/README.md @@ -5,8 +5,8 @@ Small tracker site build with GO and HTMX. ## ToDo - [ ] Add how to setup to README -- [ ] More lauch options for executable (ip, cert path) - [ ] Login Page - [ ] Database connection - [ ] Page to track critical hits or misses -- [ ] Remove the main PicoCSS files from Git +- [ ] Dark Mode +- [x] Remove the main PicoCSS files from Git diff --git a/go.mod b/go.mod index 9091b1b..4c90257 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/itsig0/tallytome go 1.22.1 require ( - github.com/a-h/templ v0.2.598 + github.com/a-h/templ v0.2.663 github.com/gofiber/fiber/v3 v3.0.0-beta.2 ) diff --git a/go.sum b/go.sum index 1d29219..155eaeb 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,7 @@ github.com/a-h/templ v0.2.598 h1:6jMIHv6wQZvdPxTuv87erW4RqN/FPU0wk7ZHN5wVuuo= github.com/a-h/templ v0.2.598/go.mod h1:SA7mtYwVEajbIXFRh3vKdYm/4FYyLQAtPH1+KxzGPA8= +github.com/a-h/templ v0.2.663 h1:aa0WMm27InkYHGjimcM7us6hJ6BLhg98ZbfaiDPyjHE= +github.com/a-h/templ v0.2.663/go.mod h1:SA7mtYwVEajbIXFRh3vKdYm/4FYyLQAtPH1+KxzGPA8= github.com/andybalholm/brotli v1.1.0 h1:eLKJA0d02Lf0mVpIDgYnqXcUn0GqVmEFny3VuID1U3M= github.com/andybalholm/brotli v1.1.0/go.mod h1:sms7XGricyQI9K10gOSf56VKKWS4oLer58Q+mhRPtnY= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= diff --git a/public/scripts/tallytome.js b/public/scripts/tallytome.js index 939343f..e71356c 100644 --- a/public/scripts/tallytome.js +++ b/public/scripts/tallytome.js @@ -1,41 +1,73 @@ // HTMX event listener document.addEventListener("DOMContentLoaded", (event) => { - document.body.addEventListener("htmx:beforeSwap", function (evt) { - if (evt.detail.xhr.status === 422) { - evt.detail.shouldSwap = true; - evt.detail.isError = false; - } - }); + document.body.addEventListener("htmx:beforeSwap", function(evt) { + if (evt.detail.xhr.status === 422) { + evt.detail.shouldSwap = true; + evt.detail.isError = false; + } + }); - document.body.addEventListener("HPUpdated", function () { - var input = document.getElementById("damageInput"); - input.value = ""; - input.removeAttribute("aria-invalid"); + document.body.addEventListener("HPUpdated", function() { + var input = document.getElementById("damageInput"); + input.value = ""; + input.removeAttribute("aria-invalid"); - var errorMessage = document.getElementById("damageError"); - if (errorMessage) { - errorMessage.parentNode.removeChild(errorMessage); - } + var errorMessage = document.getElementById("damageError"); + if (errorMessage) { + errorMessage.parentNode.removeChild(errorMessage); + } - var savingthrow = document.getElementById("savingthrow"); - savingthrow.checked = false; - }); + var savingthrow = document.getElementById("savingthrow"); + savingthrow.checked = false; + }); - document.body.addEventListener("ManaUpdated", function () { - var input = document.getElementById("manaInput"); - input.value = ""; - input.removeAttribute("aria-invalid"); + document.body.addEventListener("ManaUpdated", function() { + var input = document.getElementById("manaInput"); + input.value = ""; + input.removeAttribute("aria-invalid"); - var errorMessage = document.getElementById("manaError"); - if (errorMessage) { - errorMessage.parentNode.removeChild(errorMessage); - } - }); + var errorMessage = document.getElementById("manaError"); + if (errorMessage) { + errorMessage.parentNode.removeChild(errorMessage); + } + }); + + document.body.addEventListener("BaseUpdated", function() { + var errorMessage = document.getElementById("baseError"); + if (errorMessage) { + errorMessage.parentNode.removeChild(errorMessage); + } + }); - document.body.addEventListener("BaseUpdated", function () { - var errorMessage = document.getElementById("baseError"); - if (errorMessage) { - errorMessage.parentNode.removeChild(errorMessage); - } - }); }); + +// theme switching +let atr = 'data-theme'; +let localTheme = localStorage.getItem(atr) +if (localTheme) { + setTheme(localTheme); +} + +// if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches && localTheme == null) { +// // dark mode +// setTheme('dark'); +// } + +function toggleColorMode() { + let el = document.documentElement; + let atr_data = el.getAttribute(atr); + + if (atr_data == 'light') { + setTheme('dark'); + } else { + setTheme('light'); + } +} + +function setTheme(theme) { + let el = document.documentElement; + el.getAttribute(atr); + el.setAttribute(atr, theme); + localStorage.setItem(atr, theme) +} + diff --git a/public/tally-logo-no-bg.svg b/public/tally-logo-no-bg.svg new file mode 100644 index 0000000..54e3bdc --- /dev/null +++ b/public/tally-logo-no-bg.svg @@ -0,0 +1,97 @@ + + + + + + + + + + + + + + diff --git a/view/hptracker/tracker.templ b/view/hptracker/tracker.templ index 2018b1a..5ce0776 100644 --- a/view/hptracker/tracker.templ +++ b/view/hptracker/tracker.templ @@ -70,7 +70,10 @@ templ Show(hx bool, td TrackerData) { @Mana(md) - +
+ Extras + +
} } @@ -169,9 +172,11 @@ templ Hp(dd DamageData) { }
diff --git a/view/layout/header.templ b/view/layout/header.templ index 12c7bc9..3384b7f 100644 --- a/view/layout/header.templ +++ b/view/layout/header.templ @@ -5,8 +5,8 @@ templ header(){ +} -} \ No newline at end of file +templ logo(){ + + + + + + + + + + + + + + +}