fixed onboarding feature

This commit is contained in:
Felix Baumgärtner 2024-01-16 11:26:06 +01:00
parent e20d393f76
commit 670ad25d1a
3 changed files with 14 additions and 24 deletions

View File

@ -1,24 +1,11 @@
<script> <script>
import { onMount } from 'svelte';
import { Stepper, Step } from '@skeletonlabs/skeleton'; import { Stepper, Step } from '@skeletonlabs/skeleton';
var onboarding, onboardingStore; import { localStorageStore } from '@skeletonlabs/skeleton';
const onboardingShow = localStorageStore('onboarding', true);
onMount(() => {
onboardingStore = localStorage.getItem('onboarding');
if (onboardingStore === null) {
onboarding = true;
localStorage.setItem('onboarding', onboarding);
} else if (onboardingStore === 'true') {
onboarding = true;
} else if (onboardingStore === 'false') {
onboarding = false;
}
});
function onCompleteHandler(e) { function onCompleteHandler(e) {
onboarding = false; $onboardingShow = false;
localStorage.setItem('onboarding', onboarding);
} }
var stepsObj = [ var stepsObj = [
@ -49,7 +36,6 @@
]; ];
</script> </script>
{#if onboarding == true}
<div id="stepper-wrapper" class="fixed top-0 left-0 w-full h-full p-12 bg-slate-50 z-10"> <div id="stepper-wrapper" class="fixed top-0 left-0 w-full h-full p-12 bg-slate-50 z-10">
<Stepper on:complete={onCompleteHandler} class="h-full flex flex-col" regionContent="grow" buttonCompleteLabel="Start" buttonNext='btn-lg variant-filled-primary' buttonBack='btn-lg variant-filled-surface' buttonComplete='btn-lg variant-filled-primary'> <Stepper on:complete={onCompleteHandler} class="h-full flex flex-col" regionContent="grow" buttonCompleteLabel="Start" buttonNext='btn-lg variant-filled-primary' buttonBack='btn-lg variant-filled-surface' buttonComplete='btn-lg variant-filled-primary'>
{#each stepsObj as item} {#each stepsObj as item}
@ -63,4 +49,3 @@
{/each} {/each}
</Stepper> </Stepper>
</div> </div>
{/if}

View File

@ -22,6 +22,10 @@
var mapVisible = false; var mapVisible = false;
$: $page.url.pathname == '/' || $page.url.pathname == '/control' ? mapVisible = true : mapVisible = false; $: $page.url.pathname == '/' || $page.url.pathname == '/control' ? mapVisible = true : mapVisible = false;
import { localStorageStore } from '@skeletonlabs/skeleton';
const onboardingShow = localStorageStore('onboarding', true);
</script> </script>
<main class="min-h-screen p-8 pb-32"> <main class="min-h-screen p-8 pb-32">
@ -31,7 +35,9 @@
<Map /> <Map />
</div> </div>
<Navigation /> <Navigation />
{#if $onboardingShow}
<Onboarding /> <Onboarding />
{/if}
</main> </main>
<Drawer position="right"> <Drawer position="right">
{#if $drawerStore.id === 'edit-device'} {#if $drawerStore.id === 'edit-device'}

View File

@ -1,9 +1,8 @@
<script> <script>
import { LightSwitch } from '@skeletonlabs/skeleton'; import { LightSwitch } from '@skeletonlabs/skeleton';
function resetOnboarding() { import { localStorageStore } from '@skeletonlabs/skeleton';
localStorage.setItem('onboarding', true); const onboardingShow = localStorageStore('onboarding', true);
}
import { getModalStore } from '@skeletonlabs/skeleton'; import { getModalStore } from '@skeletonlabs/skeleton';
const modalStore = getModalStore(); const modalStore = getModalStore();
@ -27,7 +26,7 @@
<LightSwitch bgDark="bg-surface-700" /> <LightSwitch bgDark="bg-surface-700" />
</div> </div>
<button type="button" class="btn variant-filled-surface w-full" on:click={resetOnboarding}>Restart Onboarding</button> <button type="button" class="btn variant-filled-surface w-full" on:click={() => {$onboardingShow = true}}>Restart Onboarding</button>
<button type="button" class="btn variant-ghost-error w-full" on:click={resetModal}>Reset</button> <button type="button" class="btn variant-ghost-error w-full" on:click={resetModal}>Reset</button>
</div> </div>