diff --git a/src/components/layout/Modals.svelte b/src/components/layout/Modals.svelte index 03b829d..cd90b19 100644 --- a/src/components/layout/Modals.svelte +++ b/src/components/layout/Modals.svelte @@ -14,6 +14,7 @@ import UnstakeCAP from '../modals/UnstakeCAP.svelte' import HistoryOrderStatus from '../modals/HistoryOrderStatus.svelte' import Settings from '../modals/Settings.svelte' +import Welcome from '../modals/Welcome.svelte' @@ -21,6 +22,10 @@ {/if} +{#if $activeModal && $activeModal.name == 'Welcome'} + +{/if} + {#if $activeModal && $activeModal.name == 'AssetSelect'} {/if} diff --git a/src/components/modals/Welcome.svelte b/src/components/modals/Welcome.svelte new file mode 100644 index 0000000..43c3387 --- /dev/null +++ b/src/components/modals/Welcome.svelte @@ -0,0 +1,164 @@ + + + + + + + + + + CAP is a perpetuals exchange and liquidity protocol on Arbitrum. Here's a quick tour to get you started. + + + + {#each STEPS as step, i} + + {i + 1} + + {step.title} + {step.body} + + + {/each} + + + + Don't show again + Got it + Open bridge + + + + + \ No newline at end of file diff --git a/src/lib/utils.js b/src/lib/utils.js index bf3669f..e1c95a5 100644 --- a/src/lib/utils.js +++ b/src/lib/utils.js @@ -142,4 +142,33 @@ export function getMargin(size, leverage) { } export function getSize(margin, leverage) { return Math.ceil(10**8 * (margin || 0) * leverage) / 10**8; +} + +// ====== bounty/13: localStorageStore helper ====== +// localStorageStore — Svelte writable store that auto-persists to localStorage. +// Returns a Svelte writable. SSR-safe: falls back to defaultValue when localStorage +// is missing (e.g. Node prerender). + +import { writable } from 'svelte/store' + +export function localStorageStore(key, defaultValue) { + let initial = defaultValue + try { + if (typeof localStorage !== 'undefined') { + const raw = localStorage.getItem(key) + if (raw !== null) { + try { initial = JSON.parse(raw) } catch (_) { initial = raw } + } + } + } catch (_) { /* ignore */ } + + const store = writable(initial) + try { + if (typeof localStorage !== 'undefined') { + store.subscribe((v) => { + try { localStorage.setItem(key, JSON.stringify(v)) } catch (_) {} + }) + } + } catch (_) { /* ignore */ } + return store } \ No newline at end of file