|
@@ -3,6 +3,8 @@
|
|
|
import { Button, Cell, Icon, Calendar } from 'stdf';
|
|
import { Button, Cell, Icon, Calendar } from 'stdf';
|
|
|
import en_US from 'stdf/lang/en_US';
|
|
import en_US from 'stdf/lang/en_US';
|
|
|
import zh_CN from 'stdf/lang/zh_CN';
|
|
import zh_CN from 'stdf/lang/zh_CN';
|
|
|
|
|
+ import { stdfTheme, switchTheme, darkMode } from 'stdf/theme';
|
|
|
|
|
+ import NintendoTheme from '../data/Nintendo';
|
|
|
import Counter from './Counter.svelte';
|
|
import Counter from './Counter.svelte';
|
|
|
|
|
|
|
|
import { browser } from '$app/environment';
|
|
import { browser } from '$app/environment';
|
|
@@ -17,21 +19,21 @@
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
//切换亮暗模式(toggle light or dark mode)
|
|
//切换亮暗模式(toggle light or dark mode)
|
|
|
- let theme = sessionStorage.getItem('theme') === 'dark' ? 'dark' : 'light';
|
|
|
|
|
- if (theme === 'dark') {
|
|
|
|
|
- document.documentElement.classList.add('dark');
|
|
|
|
|
|
|
+ let mode = sessionStorage.getItem('mode') === 'dark' ? 'dark' : 'light';
|
|
|
|
|
+ if (mode === 'dark') {
|
|
|
|
|
+ darkMode();
|
|
|
}
|
|
}
|
|
|
const toggleModeFun = () => {
|
|
const toggleModeFun = () => {
|
|
|
- if (theme === 'dark') {
|
|
|
|
|
|
|
+ if (mode === 'dark') {
|
|
|
// 切换到(light switch to light)
|
|
// 切换到(light switch to light)
|
|
|
- theme = 'light';
|
|
|
|
|
- document.documentElement.classList.remove('dark');
|
|
|
|
|
- sessionStorage.setItem('theme', 'light');
|
|
|
|
|
|
|
+ mode = 'light';
|
|
|
|
|
+ darkMode(false);
|
|
|
|
|
+ sessionStorage.setItem('mode', 'light');
|
|
|
} else {
|
|
} else {
|
|
|
// 切换到(dark switch to dark)
|
|
// 切换到(dark switch to dark)
|
|
|
- theme = 'dark';
|
|
|
|
|
- document.documentElement.classList.add('dark');
|
|
|
|
|
- sessionStorage.setItem('theme', 'dark');
|
|
|
|
|
|
|
+ mode = 'dark';
|
|
|
|
|
+ darkMode();
|
|
|
|
|
+ sessionStorage.setItem('mode', 'dark');
|
|
|
}
|
|
}
|
|
|
};
|
|
};
|
|
|
|
|
|
|
@@ -57,6 +59,18 @@
|
|
|
|
|
|
|
|
// 日历(calendar)
|
|
// 日历(calendar)
|
|
|
let visible = false;
|
|
let visible = false;
|
|
|
|
|
+
|
|
|
|
|
+ // 主题(theme)
|
|
|
|
|
+ let theme = 'STDF';
|
|
|
|
|
+ const toggleThemeFun = () => {
|
|
|
|
|
+ if (theme === 'STDF') {
|
|
|
|
|
+ theme = 'Nintendo';
|
|
|
|
|
+ switchTheme(NintendoTheme);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ theme = 'STDF';
|
|
|
|
|
+ switchTheme(stdfTheme);
|
|
|
|
|
+ }
|
|
|
|
|
+ };
|
|
|
</script>
|
|
</script>
|
|
|
|
|
|
|
|
<div class="flex justify-center items-center text-center gap-4 pt-10">
|
|
<div class="flex justify-center items-center text-center gap-4 pt-10">
|
|
@@ -76,7 +90,7 @@
|
|
|
</svg>
|
|
</svg>
|
|
|
</a>
|
|
</a>
|
|
|
</div>
|
|
</div>
|
|
|
-<div class="text-center my-8 text-xs">
|
|
|
|
|
|
|
+<div class="text-center my-6 text-xs">
|
|
|
{#if isZh}
|
|
{#if isZh}
|
|
|
<p>这是一个使用 SvelteKit + UnoCSS + STDF 构建的模板。</p>
|
|
<p>这是一个使用 SvelteKit + UnoCSS + STDF 构建的模板。</p>
|
|
|
<p class="mt-2">点击上方 LOGO 了解更多。</p>
|
|
<p class="mt-2">点击上方 LOGO 了解更多。</p>
|
|
@@ -85,13 +99,13 @@
|
|
|
<p class="mt-2">Click the logo above to learn more.</p>
|
|
<p class="mt-2">Click the logo above to learn more.</p>
|
|
|
{/if}
|
|
{/if}
|
|
|
</div>
|
|
</div>
|
|
|
-<div class="my-8">
|
|
|
|
|
|
|
+<div class="my-6">
|
|
|
<a href="about">
|
|
<a href="about">
|
|
|
<Cell title={isZh ? '跳转 ABOUT' : 'Go to ABOUT'} />
|
|
<Cell title={isZh ? '跳转 ABOUT' : 'Go to ABOUT'} />
|
|
|
</a>
|
|
</a>
|
|
|
</div>
|
|
</div>
|
|
|
-<div class="my-8">
|
|
|
|
|
- <Cell title={isZh ? '暗模式' : 'Dark mode'} right={{ type: 'switch', switch: { check: theme === 'dark' } }} on:click={toggleModeFun} />
|
|
|
|
|
|
|
+<div class="my-6">
|
|
|
|
|
+ <Cell title={isZh ? '暗模式' : 'Dark mode'} right={{ type: 'switch', switch: { check: mode === 'dark' } }} on:click={toggleModeFun} />
|
|
|
</div>
|
|
</div>
|
|
|
<div class="mt-8">
|
|
<div class="mt-8">
|
|
|
<Counter bind:percent />
|
|
<Counter bind:percent />
|
|
@@ -101,21 +115,23 @@
|
|
|
<div class="flex divide-x">
|
|
<div class="flex divide-x">
|
|
|
<!-- svelte-ignore a11y-click-events-have-key-events -->
|
|
<!-- svelte-ignore a11y-click-events-have-key-events -->
|
|
|
<!-- svelte-ignore a11y-no-static-element-interactions -->
|
|
<!-- svelte-ignore a11y-no-static-element-interactions -->
|
|
|
- <div class="flex-1 py-2 active:opacity-80" on:click={reduceFunc}>-10</div>
|
|
|
|
|
|
|
+ <div class="flex-1 border-primary dark:border-dark py-2 active:opacity-80" on:click={reduceFunc}>-10</div>
|
|
|
<!-- svelte-ignore a11y-click-events-have-key-events -->
|
|
<!-- svelte-ignore a11y-click-events-have-key-events -->
|
|
|
<!-- svelte-ignore a11y-no-static-element-interactions -->
|
|
<!-- svelte-ignore a11y-no-static-element-interactions -->
|
|
|
- <div class="flex-1 py-2 active:opacity-80" on:click={increaseFunc}>+10</div>
|
|
|
|
|
|
|
+ <div class="flex-1 border-primary dark:border-dark py-2 active:opacity-80" on:click={increaseFunc}>+10</div>
|
|
|
<!-- svelte-ignore a11y-click-events-have-key-events -->
|
|
<!-- svelte-ignore a11y-click-events-have-key-events -->
|
|
|
<!-- svelte-ignore a11y-no-static-element-interactions -->
|
|
<!-- svelte-ignore a11y-no-static-element-interactions -->
|
|
|
- <div class="flex-1 py-2 active:opacity-80" on:click={() => (percent = 20)}>{isZh ? '重置' : 'Reset'}</div>
|
|
|
|
|
|
|
+ <div class="flex-1 border-primary dark:border-dark py-2 active:opacity-80" on:click={() => (percent = 20)}>
|
|
|
|
|
+ {isZh ? '重置' : 'Reset'}
|
|
|
|
|
+ </div>
|
|
|
</div>
|
|
</div>
|
|
|
</Button>
|
|
</Button>
|
|
|
</div>
|
|
</div>
|
|
|
-<div class="my-8">
|
|
|
|
|
|
|
+<div class="my-6">
|
|
|
<Button fill="lineTheme" on:click={() => (visible = true)}>{isZh ? '日历' : 'Calendar'}</Button>
|
|
<Button fill="lineTheme" on:click={() => (visible = true)}>{isZh ? '日历' : 'Calendar'}</Button>
|
|
|
</div>
|
|
</div>
|
|
|
<Calendar bind:visible />
|
|
<Calendar bind:visible />
|
|
|
-<div class="my-8 px-8 flex justify-between">
|
|
|
|
|
|
|
+<div class="my-6 px-8 flex justify-between">
|
|
|
<Icon name="cake" theme path="symbols/Heroicons.svg" />
|
|
<Icon name="cake" theme path="symbols/Heroicons.svg" />
|
|
|
<Icon name="riding-line" path="symbols/Remix.svg" />
|
|
<Icon name="riding-line" path="symbols/Remix.svg" />
|
|
|
<Icon name="spy-line" theme path="symbols/Remix.svg" />
|
|
<Icon name="spy-line" theme path="symbols/Remix.svg" />
|
|
@@ -127,6 +143,7 @@
|
|
|
,{isZh ? '最后一个来自' : 'the last one comes from'} <a class="underline" href="https://iconpark.oceanengine.com">IconPark</a>
|
|
,{isZh ? '最后一个来自' : 'the last one comes from'} <a class="underline" href="https://iconpark.oceanengine.com">IconPark</a>
|
|
|
,{isZh ? '其余来自' : 'the rest come from'} <a class="underline" href="https://remixicon.com">Remix Icon</a> 。
|
|
,{isZh ? '其余来自' : 'the rest come from'} <a class="underline" href="https://remixicon.com">Remix Icon</a> 。
|
|
|
</div>
|
|
</div>
|
|
|
-<div class="my-8">
|
|
|
|
|
|
|
+<div class="my-6">
|
|
|
<Button on:click={toggleLangFun}>{isZh ? '切换语言' : 'Toggle language'}</Button>
|
|
<Button on:click={toggleLangFun}>{isZh ? '切换语言' : 'Toggle language'}</Button>
|
|
|
|
|
+ <Button fill="lineTheme" on:click={toggleThemeFun}>{isZh ? '切换主题' : 'Toggle theme'}</Button>
|
|
|
</div>
|
|
</div>
|