refactor: inline single-use components, remove dead code
- Inline TopBar into root layout (+layout.svelte) — only used there - Inline Center into home page (+page.svelte) — only used there - Remove ComboBox.svelte — dead code, no imports - Remove TipTap.svelte — dead code, no imports - Remove empty container/ui/admin/tiptap directories - Keep Window.svelte in components/containers/ — used by 4 pages
This commit is contained in:
@@ -1,9 +1,31 @@
|
||||
<script lang="ts">
|
||||
import { onMount } from 'svelte';
|
||||
import { authClient } from '$lib/auth-client';
|
||||
import { canAccessAdmin } from '$lib/svelte-admin/roles';
|
||||
import './layout.css';
|
||||
import favicon from '$lib/assets/favicon.svg';
|
||||
import TopBar from '$lib/components/ui/topBar/TopBar.svelte';
|
||||
|
||||
let { data, children } = $props();
|
||||
|
||||
const session = authClient.useSession();
|
||||
let isAdmin = $derived(canAccessAdmin(data.userRoleId));
|
||||
|
||||
let dark = $state(false);
|
||||
|
||||
onMount(() => {
|
||||
dark = document.documentElement.classList.contains('dark');
|
||||
});
|
||||
|
||||
function toggleTheme() {
|
||||
dark = !dark;
|
||||
if (dark) {
|
||||
document.documentElement.classList.add('dark');
|
||||
localStorage.setItem('theme', 'dark');
|
||||
} else {
|
||||
document.documentElement.classList.remove('dark');
|
||||
localStorage.setItem('theme', 'light');
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<svelte:head>
|
||||
@@ -18,7 +40,29 @@
|
||||
<meta name="twitter:card" content="summary" />
|
||||
</svelte:head>
|
||||
|
||||
<TopBar userRoleId={data.userRoleId} />
|
||||
<nav class="flex w-full items-center justify-between border-b border-gray-200 px-8 py-6 dark:border-gray-700 dark:bg-gray-950 dark:text-gray-100">
|
||||
<span><a href="/" class="dark:text-gray-100">Rhema Wave Technologies</a></span>
|
||||
<div class="flex items-center gap-4">
|
||||
<button onclick={toggleTheme} class="border border-gray-300 px-3 py-1 text-sm dark:border-gray-600 dark:text-gray-300">
|
||||
{dark ? 'Light' : 'Dark'}
|
||||
</button>
|
||||
{#if $session.data}
|
||||
{#if isAdmin}
|
||||
<a href="/admin" class="dark:text-gray-300 dark:hover:text-gray-100">Admin Panel</a>
|
||||
{/if}
|
||||
<a href="/dashboard" class="dark:text-gray-300 dark:hover:text-gray-100">Dashboard</a>
|
||||
<button
|
||||
class="dark:text-gray-300 dark:hover:text-gray-100"
|
||||
onclick={async () => {
|
||||
await authClient.signOut();
|
||||
window.location.href = '/';
|
||||
}}>Log Out</button
|
||||
>
|
||||
{:else}
|
||||
<span class="dark:text-gray-300"><a href="/login" class="dark:text-gray-300 dark:hover:text-gray-100">Log In</a> | <a href="/register" class="dark:text-gray-300 dark:hover:text-gray-100">Register</a></span>
|
||||
{/if}
|
||||
</div>
|
||||
</nav>
|
||||
<div class="flex min-h-0 flex-1 px-8 dark:bg-gray-950">
|
||||
{@render children()}
|
||||
</div>
|
||||
|
||||
@@ -1,7 +1,3 @@
|
||||
<script lang="ts">
|
||||
import Center from '$lib/components/containers/Center.svelte';
|
||||
</script>
|
||||
|
||||
<Center>
|
||||
<div class="flex flex-1 flex-col items-center justify-center">
|
||||
<h1 class="dark:text-gray-100">Hello</h1>
|
||||
</Center>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user