Skip to content

Commit

Permalink
Merge pull request #4342 from traPtitech/CustomTheme.vue
Browse files Browse the repository at this point in the history
ダークカスタムテーマを作りました。
  • Loading branch information
nokhnaton authored Oct 26, 2024
2 parents ddbed0b + 9868136 commit c0731fa
Showing 1 changed file with 51 additions and 28 deletions.
79 changes: 51 additions & 28 deletions src/views/Settings/ThemeTab.vue
Original file line number Diff line number Diff line change
Expand Up @@ -37,42 +37,54 @@
@change-theme="changeTheme"
/>
</div>
<div>
<template v-if="state.type === 'custom'">
<div :class="$style.setting">
<div
v-for="(val, category) in state.custom.basic"
:key="category"
:class="$style.category"
>
<h4 class>{{ category }}</h4>
<div
v-for="(color, name) in val"
:key="name"
:class="$style.color"
>
<p :class="$style.name">{{ name }}</p>
<!-- eslint-disable vue/valid-v-model -->
<!-- TODO: 自動適用じゃなくてバリデーションしてから適用するようにする -->
<form-input
v-model="(val[name as keyof typeof val] as string)"
use-change-event
on-secondary
:class="$style.input"
/>
<!-- eslint-enable vue/valid-v-model -->
</div>
</div>

<div>
<template v-if="state.type === 'custom'">
<div :class="$style.setting">
<div
v-for="(val, category) in state.custom.basic"
:key="category"
:class="$style.category"
>
<h4 class>{{ category }}</h4>
<div v-for="(color, name) in val" :key="name" :class="$style.color">
<p :class="$style.name">{{ name }}</p>
<!-- eslint-disable vue/valid-v-model -->
<!-- TODO: 自動適用じゃなくてバリデーションしてから適用するようにする -->
<form-input
v-model="(val[name as keyof typeof val] as string)"
use-change-event
on-secondary
:class="$style.input"
/>
<!-- eslint-enable vue/valid-v-model --->
</div>
</div>
</template>
<p v-else>カスタムテーマが選択されていません</p>
</div>
</div>
</template>
<p v-else>カスタムテーマが選択されていません</p>
</div>
<div :class="$style.resetButtonContainer">
<form-button
v-if="state.type === 'custom'"
type="tertiary"
label="ライトにリセット"
@click="resetToLight"
/>
<form-button
v-if="state.type === 'custom'"
type="tertiary"
label="ダークにリセット"
@click="resetToDark"
/>
</div>
</section>
</template>
<script lang="ts" setup>
import EditTheme from '/@/components/Settings/ThemeTab/EditTheme.vue'
import FormButton from '/@/components/UI/FormButton.vue'
import FormRadio from '/@/components/UI/FormRadio.vue'
import FormInput from '/@/components/UI/FormInput.vue'
import { reactive } from 'vue'
Expand All @@ -83,6 +95,13 @@ const state = reactive(useThemeSettings())
const changeTheme = (theme: Theme) => {
state.custom = theme
}
const resetToLight = () => {
changeTheme(structuredClone(window.defaultLightTheme))
}
const resetToDark = () => {
changeTheme(structuredClone(window.defaultDarkTheme))
}
</script>
<style lang="scss" module>
Expand Down Expand Up @@ -126,4 +145,8 @@ const changeTheme = (theme: Theme) => {
margin-left: auto;
}
}
.resetButtonContainer {
display: flex;
gap: 1rem;
}
</style>

0 comments on commit c0731fa

Please sign in to comment.