feat(m4): SvelteKit frontend - today, week, history, settings views
This commit is contained in:
@@ -0,0 +1,78 @@
|
||||
<script lang="ts">
|
||||
import { page } from '$app/state';
|
||||
import { hasToken } from '$lib/api/client';
|
||||
import { onMount } from 'svelte';
|
||||
import { goto } from '$app/navigation';
|
||||
|
||||
let { children } = $props();
|
||||
|
||||
onMount(() => {
|
||||
if (!hasToken() && page.url.pathname !== '/settings') {
|
||||
goto('/settings');
|
||||
}
|
||||
});
|
||||
|
||||
const navItems = [
|
||||
{ href: '/today', label: 'Today' },
|
||||
{ href: '/week', label: 'Week' },
|
||||
{ href: '/history', label: 'History' },
|
||||
{ href: '/settings', label: 'Settings' }
|
||||
];
|
||||
</script>
|
||||
|
||||
<nav>
|
||||
{#each navItems as item}
|
||||
<a href={item.href} class:active={page.url.pathname === item.href}>{item.label}</a>
|
||||
{/each}
|
||||
</nav>
|
||||
|
||||
<main>
|
||||
{@render children()}
|
||||
</main>
|
||||
|
||||
<style>
|
||||
:global(*, *::before, *::after) {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
:global(body) {
|
||||
margin: 0;
|
||||
font-family: system-ui, sans-serif;
|
||||
background: #f8f9fa;
|
||||
color: #212529;
|
||||
}
|
||||
:global(button) {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
nav {
|
||||
display: flex;
|
||||
gap: 0.5rem;
|
||||
padding: 0.75rem 1rem;
|
||||
background: #1a1a2e;
|
||||
position: sticky;
|
||||
top: 0;
|
||||
z-index: 10;
|
||||
}
|
||||
nav a {
|
||||
color: #adb5bd;
|
||||
text-decoration: none;
|
||||
padding: 0.4rem 0.8rem;
|
||||
border-radius: 6px;
|
||||
font-size: 0.9rem;
|
||||
font-weight: 500;
|
||||
transition: background 0.15s, color 0.15s;
|
||||
}
|
||||
nav a:hover {
|
||||
background: #16213e;
|
||||
color: #e9ecef;
|
||||
}
|
||||
nav a.active {
|
||||
background: #0f3460;
|
||||
color: #e9ecef;
|
||||
}
|
||||
main {
|
||||
max-width: 800px;
|
||||
margin: 0 auto;
|
||||
padding: 1.5rem 1rem;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user