Modify some lib components for Svelte 5

This commit is contained in:
Neshura 2023-12-05 19:25:34 +01:00
parent f0c66fb4a2
commit fdbb265ae6
Signed by: Neshura
GPG key ID: B6983AAA6B9A7A6C
5 changed files with 58 additions and 3 deletions

View file

@ -1,6 +1,12 @@
<svelte:options runes={true} />
<script lang="ts">
export let text: string;
export let action: any = () => {};
import UserSettingsStore from '$lib/stores/UserSettingsStore';
import { themes } from '$lib/types/themes';
let {children, onclick} = $props()
let themeId = $derived($UserSettingsStore.themeId)
</script>
<button class="btn px-4 py-2 mx-2 rounded-token variant-ringed-primary hover:variant-filled-primary active:variant-filled-primary" on:click={action}>{text}</button>
<button {onclick} class="border-2 border-{themes[themeId].primaryAction} hover:border-{themes[themeId].secondaryAction}">{@render children()}</button>

View file

@ -0,0 +1,8 @@
<script lang="ts">
let {href} = $props()
// {$page.url.pathname === '/'}
</script>
<li>
<a {href}><slot /></a>
</li>

View file

@ -0,0 +1,6 @@
import { writable, type Writable } from "svelte/store";
import { UserSettings } from '$lib/types/userSettings';
const UserSettingsStore: Writable<UserSettings> = writable(new UserSettings());
export default UserSettingsStore;

View file

@ -0,0 +1,27 @@
export type Theme = {
backgroundColor: string,
textColor: string,
primaryAction: string,
secondaryAction: string,
}
const lightTheme = {
backgroundColor: "slate-50",
textColor: "slate-950",
primaryAction: "sky-300",
secondaryAction: "sky-600",
}
const darkTheme = {
backgroundColor: "slate-950",
textColor: "slate-50",
primaryAction: "sky-300",
secondaryAction: "sky-600",
}
export const themes = [
lightTheme,
darkTheme
]

View file

@ -0,0 +1,8 @@
export class UserSettings {
themeId: number
constructor() {
this.themeId = 1 // DEBUG
return this
}
}