mirror of
https://github.com/seanmorley15/AdventureLog.git
synced 2025-07-24 15:29:36 +02:00
Add Nord theme option to theme selection dropdown in Navbar.svelte
This commit is contained in:
parent
5efb2912c0
commit
f0eb5441f0
4 changed files with 13 additions and 4 deletions
|
@ -8,6 +8,7 @@
|
|||
import { onMount } from "svelte";
|
||||
import InfoModal from "./InfoModal.svelte";
|
||||
import infoIcon from "$lib/assets/info.svg";
|
||||
import type { SubmitFunction } from "@sveltejs/kit";
|
||||
async function goHome() {
|
||||
goto("/");
|
||||
}
|
||||
|
@ -27,6 +28,13 @@
|
|||
goto("/worldtravel");
|
||||
}
|
||||
|
||||
const submitUpdateTheme: SubmitFunction = ({ action }) => {
|
||||
const theme = action.searchParams.get("theme");
|
||||
if (theme) {
|
||||
document.documentElement.setAttribute("data-theme", theme);
|
||||
}
|
||||
};
|
||||
|
||||
let count = 0;
|
||||
|
||||
let infoModalOpen = false;
|
||||
|
@ -104,10 +112,11 @@
|
|||
tabindex="0"
|
||||
class="dropdown-content z-[1] menu p-2 shadow bg-base-100 rounded-box w-52"
|
||||
>
|
||||
<form method="POST">
|
||||
<form method="POST" use:enhance={submitUpdateTheme}>
|
||||
<li><button formaction="/?/setTheme&theme=light">Light</button></li>
|
||||
<li><button formaction="/?/setTheme&theme=dark">Dark</button></li>
|
||||
<li><button formaction="/?/setTheme&theme=night">Night</button></li>
|
||||
<!-- <li><button formaction="/?/setTheme&theme=nord">Nord</button></li> -->
|
||||
<!-- <li><button formaction="/?/setTheme&theme=retro">Retro</button></li> -->
|
||||
<li><button formaction="/?/setTheme&theme=forest">Forest</button></li>
|
||||
</form>
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
export let data;
|
||||
import Footer from "$lib/components/Footer.svelte";
|
||||
import Navbar from "$lib/components/Navbar.svelte";
|
||||
import type { SubmitFunction } from "@sveltejs/kit";
|
||||
import "../app.css";
|
||||
// only show footer if scrolled to the bottom
|
||||
</script>
|
||||
|
||||
<!-- passes the user object to the navbar component -->
|
||||
|
|
|
@ -31,7 +31,7 @@ export const actions: Actions = {
|
|||
setTheme: async ( { url, cookies }) => {
|
||||
const theme = url.searchParams.get("theme");
|
||||
// change the theme only if it is one of the allowed themes
|
||||
if (theme && ["light", "dark", "night", "retro", "forest"].includes(theme)) {
|
||||
if (theme && ["light", "dark", "night", "retro", "forest", "nord"].includes(theme)) {
|
||||
cookies.set("colortheme", theme, {
|
||||
path: "/",
|
||||
maxAge: 60 * 60 * 24 * 365,
|
||||
|
|
|
@ -6,6 +6,6 @@ export default {
|
|||
},
|
||||
plugins: [require("@tailwindcss/typography"), require("daisyui")],
|
||||
daisyui: {
|
||||
themes: ["light", "dark", "night", "retro", "forest"],
|
||||
themes: ["light", "dark", "night", "retro", "forest", "nord"],
|
||||
},
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue