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

Merged
merged 6 commits into from
Oct 26, 2024
Merged
Changes from 1 commit
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
17 changes: 17 additions & 0 deletions src/views/Settings/ThemeTab.vue
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,16 @@
@change-theme="changeTheme"
/>
</div>
<button
nokhnaton marked this conversation as resolved.
Show resolved Hide resolved
v-if="state.type === 'custom'"
:class="$style.form"
Copy link
Contributor

Choose a reason for hiding this comment

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

このクラスは2つのボタンの間を開けるために付けてると思います。ここに間を開けるのはわかりやすくなりますし、使いやすくもなるのでめちゃくちゃいい工夫だと思います!
こういうときはボタンをdivなどで囲んであげて、display: flex; gap: 1remみたいなstyleを付けてあげるのがよくある方法でより分かりやすい書き方だと思います!
イメージとしてはこんな感じです

<div :class="resetButtonContainer >
    <form-button />
    <form-button />
</div>

<style module>
.resetButtonContainer {
    display: flex;
    gap: 1rem;
}
</style>

参考(完全に理解する必要はないです):
https://developer.mozilla.org/ja/docs/Web/CSS/gap#%E3%83%95%E3%83%AC%E3%83%83%E3%82%AF%E3%82%B9%E3%83%AC%E3%82%A4%E3%82%A2%E3%82%A6%E3%83%88

@click="resetToLight"
>
ライトにリセット
</button>
<button v-if="state.type === 'custom'" @click="resetToDark">
ダークにリセット
</button>
<div>
<template v-if="state.type === 'custom'">
<div :class="$style.setting">
Expand Down Expand Up @@ -83,6 +93,13 @@ const state = reactive(useThemeSettings())
const changeTheme = (theme: Theme) => {
state.custom = theme
}

const resetToLight = () => {
changeTheme(structuredClone(window.defaultLightTheme))
nokhnaton marked this conversation as resolved.
Show resolved Hide resolved
}
const resetToDark = () => {
changeTheme(structuredClone(window.defaultDarkTheme))
}
</script>

<style lang="scss" module>
Expand Down
Loading