generated from prokawsar/dashboard-starter
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Improve code and mixpanel * Fix * data preload
- Loading branch information
Showing
8 changed files
with
106 additions
and
93 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
<script lang="ts"> | ||
import { slide } from 'svelte/transition' | ||
import Icon from '@iconify/svelte' | ||
import { page } from '$app/stores' | ||
import { enhance } from '$app/forms' | ||
import mixpanel from '$lib/utils/mixpanel' | ||
export let showSettings = false | ||
export let showAbout = false | ||
export let loading = false | ||
const navItems = [ | ||
{ href: '/', label: 'Home', icon: 'clarity:home-line' }, | ||
{ href: '/history', label: 'Cost History', icon: 'ph:read-cv-logo-light', preload: true } | ||
] | ||
function toggleSettings() { | ||
showSettings = !showSettings | ||
} | ||
</script> | ||
|
||
<footer | ||
class="relative max-w-6xl mx-auto w-full px-5 bg-slate-50 border-t border-teal-500 rounded-t-lg" | ||
> | ||
<nav class="flex flex-row h-11 items-center justify-between"> | ||
{#each navItems as { href, label, icon, preload }} | ||
<a | ||
{href} | ||
class="flex flex-row items-center gap-1" | ||
class:text-orange-500={$page.url.pathname === href} | ||
data-sveltekit-preload-data={preload ? 'tap' : null} | ||
> | ||
<Icon {icon} /> | ||
{label} | ||
</a> | ||
{/each} | ||
<button on:click={toggleSettings} class="flex flex-row gap-1 items-center"> | ||
<Icon icon="solar:settings-linear" /> Settings | ||
</button> | ||
</nav> | ||
|
||
{#if showSettings} | ||
<div | ||
transition:slide={{ axis: 'y', duration: 200 }} | ||
class="absolute w-20 right-3 bottom-11 flex flex-col items-start divide-y divide-orange-400 gap-1 bg-slate-50 p-2 rounded" | ||
> | ||
<button | ||
on:click={() => { | ||
showAbout = true | ||
toggleSettings() | ||
}}>About</button | ||
> | ||
<form | ||
method="post" | ||
action="/?/logout" | ||
use:enhance={() => { | ||
loading = true | ||
return async ({ update }) => { | ||
await update() | ||
loading = false | ||
mixpanel.reset() | ||
mixpanel.track('logout') | ||
} | ||
}} | ||
> | ||
<button type="submit">Logout</button> | ||
</form> | ||
</div> | ||
{/if} | ||
</footer> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { browser, dev } from '$app/environment' | ||
import mixpanel from 'mixpanel-browser' | ||
|
||
mixpanel.init('4f9140ba92bf9817723887501ce35853', { | ||
track_pageview: true, | ||
persistence: 'localStorage' | ||
}) | ||
if (dev) mixpanel.disable() | ||
|
||
export default mixpanel |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters