Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ダークカスタムテーマを作りました。 #4342

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
85 changes: 52 additions & 33 deletions src/views/Settings/ThemeTab.vue
Original file line number Diff line number Diff line change
Expand Up @@ -37,52 +37,67 @@
@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 FormRadio from '/@/components/UI/FormRadio.vue'
import FormInput from '/@/components/UI/FormInput.vue'
import { reactive } from 'vue'
import type { Theme } from '/@/lib/theme/schema'
import { useThemeSettings } from '/@/store/app/themeSettings'
import FormButton from '/@/components/UI/FormButton.vue'

Check failure on line 87 in src/views/Settings/ThemeTab.vue

View workflow job for this annotation

GitHub Actions / run type-check

Duplicate identifier 'FormButton'.
import FormButton from '/@/components/UI/FormButton.vue'

Check failure on line 88 in src/views/Settings/ThemeTab.vue

View workflow job for this annotation

GitHub Actions / run type-check

Duplicate identifier 'FormButton'.

const state = reactive(useThemeSettings())

Check failure on line 90 in src/views/Settings/ThemeTab.vue

View workflow job for this annotation

GitHub Actions / run type-check

Cannot find name 'reactive'.

Check failure on line 90 in src/views/Settings/ThemeTab.vue

View workflow job for this annotation

GitHub Actions / run type-check

Cannot find name 'useThemeSettings'.
const changeTheme = (theme: Theme) => {

Check failure on line 91 in src/views/Settings/ThemeTab.vue

View workflow job for this annotation

GitHub Actions / run type-check

Cannot find name 'Theme'.
state.custom = theme
}

const resetToLight = () => {
changeTheme(structuredClone(window.defaultLightTheme))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ここきちんとstructuredClone使ってリセットされるようになっててめちゃくちゃいいと思います!

}
const resetToDark = () => {
changeTheme(structuredClone(window.defaultDarkTheme))
}
</script>

<style lang="scss" module>
Expand Down Expand Up @@ -126,4 +141,8 @@
margin-left: auto;
}
}
.resetButtonContainer {
display: flex;
gap: 1rem;
}
</style>
Loading