Skip to content

Commit eeba496

Browse files
feat: system preference color mode
1 parent cb1aac9 commit eeba496

File tree

4 files changed

+26
-5
lines changed

4 files changed

+26
-5
lines changed

app/components/cd.vue

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
1+
<script setup lang="ts">
2+
const route = useRoute()
3+
const toPath = computed(() => route.path.split('/').slice(0, -1).join('/') || '/')
4+
</script>
5+
16
<template>
2-
<nuxt-link v-if="$route.path !== '/'" :to="$route.path.split('/').slice(0, -1).join('/') || '/'">
7+
<nuxt-link v-if="$route.path !== '/'" :to="toPath">
38
cd ..
49
</nuxt-link>
510
</template>

app/components/theme-toggle.vue

+17-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,23 @@
1+
<script setup lang="ts">
2+
const colorMode = useColorMode()
3+
4+
function changePreference() {
5+
if (colorMode.preference === 'light') {
6+
colorMode.preference = 'dark'
7+
} else if (colorMode.preference === 'dark') {
8+
colorMode.preference = 'system'
9+
} else {
10+
colorMode.preference = 'light'
11+
}
12+
}
13+
</script>
14+
115
<template>
216
<color-scheme>
317
<button
4-
class="i-mdi-weather-sunny dark:i-mdi-weather-night font-size-[24px]"
5-
@click="$colorMode.preference = $colorMode.preference === 'dark' ? 'light' : 'dark'"
18+
class="font-size-[24px]"
19+
:class="[$colorMode.preference === 'system' ? 'i-mdi-monitor' : 'i-mdi-weather-sunny dark:i-mdi-weather-night']"
20+
@click="changePreference"
621
/>
722
<template #placeholder>
823
<div class="i-mdi-weather-sunny font-size-[24px]" />

app/layouts/default.vue

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<style lang="scss" module>
1515
.dashed_link {
1616
a {
17-
--at-apply: "underline-dashed hover:underline-solid"
18-
}
17+
--at-apply: "underline-dashed hover:underline-solid"
18+
}
1919
}
2020
</style>

eslint.config.mjs

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export default withNuxt(antfu({
1212
'curly': ['error', 'all'],
1313
'no-console': 'warn',
1414

15+
'style/brace-style': ['error', '1tbs'],
1516
'style/max-len': ['error', { code: 120 }],
1617

1718
'vue/component-name-in-template-casing': ['error', 'kebab-case'],

0 commit comments

Comments
 (0)