Skip to content

Commit 0448241

Browse files
committed
chore: add DarkToggle in playground
1 parent 854617c commit 0448241

File tree

4 files changed

+22
-10
lines changed

4 files changed

+22
-10
lines changed

packages/playground/src/App.preview.vue

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import LargeData from './components/LargeData.vue'
66
import { useAppStore } from './stores'
77
88
import { availableLocales, loadLanguageAsync } from './modules/i18n'
9+
import DarkToggle from './components/DarkToggle.vue'
910
1011
const age = ref(10)
1112
const app = useAppStore()
@@ -27,6 +28,7 @@ async function toggleLocales() {
2728
<p>
2829
<em text-sm opacity-75>{{ t('intro.desc') }}</em>
2930
</p>
31+
<DarkToggle />
3032
<p>
3133
<a icon-btn :title="t('button.toggle_langs')" @click="toggleLocales()">
3234
Toggle Langs

packages/playground/src/App.vue

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
<script setup lang="ts">
2-
import { useDark } from '@vueuse/core'
32
import { computed, reactive, ref } from 'vue'
43
import { useRoute, useRouter } from 'vue-router'
54
import { useAppStore } from './stores'
65
import EditState from './components/EditState.vue'
6+
import DarkToggle from './components/DarkToggle.vue'
77
88
const app = useAppStore()
9-
const isDark = useDark()
109
const doubleCount = computed(() => {
1110
return app.count * 2
1211
})
@@ -25,13 +24,10 @@ const route = useRoute()
2524

2625
<template>
2726
<div>
28-
<button @click="isDark = !isDark">
29-
toggle dark mode
30-
</button>
27+
<DarkToggle />
3128
<EditState />
3229
<RouterView />
3330
{{ doubleCount }}
34-
{{ isDark }}
3531
{{ app.count }}
3632
<RouterLink to="/hello">
3733
<div>
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<script setup lang="ts">
2+
import { useDark } from '@vueuse/core'
3+
4+
const isDark = useDark()
5+
</script>
6+
7+
<template>
8+
<button @click="isDark = !isDark">
9+
toggle dark mode
10+
</button>
11+
<div>isDark: {{ isDark }}</div>
12+
</template>

packages/playground/src/style.css

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,15 @@
44
line-height: 24px;
55
font-weight: 400;
66

7-
color-scheme: light dark;
8-
color: rgba(255, 255, 255, 0.87);
9-
background-color: #242424;
10-
117
font-synthesis: none;
128
text-rendering: optimizeLegibility;
139
-webkit-font-smoothing: antialiased;
1410
-moz-osx-font-smoothing: grayscale;
1511
-webkit-text-size-adjust: 100%;
1612
}
13+
14+
html.dark {
15+
color-scheme: dark;
16+
color: rgba(255, 255, 255, 0.87);
17+
background-color: #242424;
18+
}

0 commit comments

Comments
 (0)