Type scriptify 'Welcome' store
This commit is contained in:
parent
2ffa3510ee
commit
d3cec6e15b
@ -1,4 +1,4 @@
|
||||
<script>
|
||||
<script lang="ts">
|
||||
import Island from '$lib/islands/island.svelte';
|
||||
export let variables = {
|
||||
title: 'Uninitialised',
|
||||
|
@ -1,4 +1,4 @@
|
||||
<script>
|
||||
<script lang="ts">
|
||||
import { fade } from 'svelte/transition';
|
||||
|
||||
export let variables = { title: '' };
|
||||
|
@ -1,4 +1,4 @@
|
||||
<script>
|
||||
<script lang="ts">
|
||||
import { fade } from 'svelte/transition';
|
||||
|
||||
export let variables = { title: '' };
|
||||
|
@ -1,6 +1,13 @@
|
||||
<script>
|
||||
<script lang="ts">
|
||||
import Island from '$lib/islands/island.svelte';
|
||||
export let resultObject = {
|
||||
|
||||
interface resultObj {
|
||||
results: boolean,
|
||||
title: string,
|
||||
resultLines: string[]
|
||||
}
|
||||
|
||||
export let resultObject: resultObj = {
|
||||
results: true,
|
||||
title: '',
|
||||
resultLines: []
|
||||
|
@ -1,3 +0,0 @@
|
||||
export const version = '2023.7.1';
|
||||
export const versionTag = 'beta.6';
|
||||
export const showWelcome = true;
|
3
src/lib/stores/version.ts
Normal file
3
src/lib/stores/version.ts
Normal file
@ -0,0 +1,3 @@
|
||||
export const version: string = '2023.7.1';
|
||||
export const versionTag: string = 'beta.6';
|
||||
export const showWelcome: boolean = true;
|
@ -1,10 +1,10 @@
|
||||
import { writable } from 'svelte/store';
|
||||
import { writable, type Writable } from 'svelte/store';
|
||||
import { browser } from '$app/environment';
|
||||
|
||||
export const welcome = writable(fromLocalStorage('welcome', '0'));
|
||||
toLocalStorage(welcome, 'welcome');
|
||||
|
||||
function fromLocalStorage(storageKey, fallback) {
|
||||
function fromLocalStorage(storageKey: string, fallback: string) {
|
||||
if (browser) {
|
||||
const storedValue = localStorage.getItem(storageKey);
|
||||
if (storedValue !== 'undefined') {
|
||||
@ -14,9 +14,9 @@ function fromLocalStorage(storageKey, fallback) {
|
||||
return fallback;
|
||||
}
|
||||
|
||||
function toLocalStorage(store, storageKey) {
|
||||
function toLocalStorage(store: Writable<any>, storageKey: string) {
|
||||
if (browser) {
|
||||
store.subscribe((value) => {
|
||||
store.subscribe((value: string) => {
|
||||
localStorage.setItem(storageKey, value);
|
||||
});
|
||||
}
|
Loading…
Reference in New Issue
Block a user