-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Iori Ichinose
committed
Jan 11, 2023
1 parent
ec0a6c4
commit 6cc4f43
Showing
2 changed files
with
53 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<script setup lang="ts"> | ||
import { NSwitch, useMessage } from 'naive-ui'; | ||
import { CSSProperties } from 'vue'; | ||
import { useStore } from '@/store'; | ||
const store = useStore(); | ||
const message = useMessage(); | ||
const onUpdate = (value: boolean) => { | ||
store.commit('setDarkMode', value); | ||
message.info(`Side of ${value ? 'Tairitsu' : 'Hikari'}`); | ||
}; | ||
function railStyle({ | ||
focused, | ||
checked | ||
}: { | ||
focused: boolean; | ||
checked: boolean; | ||
}) { | ||
const style: CSSProperties = {}; | ||
if (checked) { | ||
style.background = '#c0203d'; | ||
if (focused) { | ||
style.boxShadow = '0 0 0 2px #c0203d40'; | ||
} | ||
} else { | ||
style.background = '#138ff2'; | ||
if (focused) { | ||
style.boxShadow = '0 0 0 2px #138ff240'; | ||
} | ||
} | ||
return style; | ||
} | ||
</script> | ||
|
||
<template> | ||
<NSwitch | ||
:defaultValue="store.state.darkMode" | ||
:onUpdateValue="onUpdate" | ||
:railStyle="railStyle" | ||
style="margin: 6px" | ||
> | ||
<template #checked>Conflict</template> | ||
<template #unchecked>Light</template> | ||
</NSwitch> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters