mirror of
https://github.com/muerwre/muerwre.github.io.git
synced 2025-04-25 10:56:40 +07:00
initial
This commit is contained in:
commit
5104c2518b
34 changed files with 6844 additions and 0 deletions
52
components/layout/LayoutThemeToggle.vue
Normal file
52
components/layout/LayoutThemeToggle.vue
Normal file
|
@ -0,0 +1,52 @@
|
|||
<template>
|
||||
<button
|
||||
@click="toggleTheme"
|
||||
:class="[$attrs.class, $style.button, { [$style.visible]: visible }]"
|
||||
>
|
||||
<ClientOnly>
|
||||
<IconsMoon fill="currentColor" width="32" height="32" v-if="isDark" />
|
||||
<IconsSun fill="currentColor" width="32" height="32" v-if="!isDark" />
|
||||
</ClientOnly>
|
||||
</button>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
const visible = ref(false);
|
||||
|
||||
onMounted(() => {
|
||||
visible.value = true;
|
||||
});
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
export default defineComponent({
|
||||
methods: {
|
||||
toggleTheme() {
|
||||
this.$colorMode.preference =
|
||||
this.$colorMode.preference === "dark" ? "light" : "dark";
|
||||
},
|
||||
},
|
||||
computed: {
|
||||
isDark() {
|
||||
return this.$colorMode.preference === "dark";
|
||||
},
|
||||
},
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss" module>
|
||||
.button {
|
||||
color: var(--color-text-secondary);
|
||||
cursor: pointer;
|
||||
transform: scale(0) rotate(180deg);
|
||||
transition: all 0.25s ease-out;
|
||||
|
||||
&.visible {
|
||||
transform: scale(1) rotate(0);
|
||||
}
|
||||
|
||||
&:hover {
|
||||
color: var(--color-text);
|
||||
}
|
||||
}
|
||||
</style>
|
Loading…
Add table
Add a link
Reference in a new issue