feat(desktop): reorganize theme settings and filter system theme choices by MicoinSmith · Pull Request #5737 · marktext/marktext · GitHub
Skip to content
Merged
Show file tree
Hide file tree
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
87 changes: 56 additions & 31 deletions packages/desktop/src/renderer/src/prefComponents/theme/index.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,41 @@
<template>
<div class="pref-theme">
<h4>{{ t('preferences.theme.title') }}</h4>
<Bool
class="follow-system-theme"
:description="t('preferences.theme.followSystemTheme')"
:bool="followSystemTheme"
:on-change="(value) => onSelectChange('followSystemTheme', value)"
/>

<div
v-if="followSystemTheme"
class="notes"
>
<!-- The marker is punctuation, not prose, so it stays out of the locale files. -->
<span aria-hidden="true">*</span> {{ t('preferences.theme.followSystemNote') }}
</div>

<div
v-if="followSystemTheme"
class="mode-themes-row"
>
<cur-select
:description="t('preferences.theme.lightModeTheme')"
:value="lightModeTheme"
:options="lightThemeOptions"
:on-change="(value) => onSelectChange('lightModeTheme', value)"
/>
<cur-select
:description="t('preferences.theme.darkModeTheme')"
:value="darkModeTheme"
:options="darkThemeOptions"
:on-change="(value) => onSelectChange('darkModeTheme', value)"
/>
</div>

<separator />

<section class="offcial-themes">
<div
v-for="themeItem of themes"
Expand All @@ -19,36 +54,6 @@
<div v-html="themeItem.html" />
</div>
</section>
<separator />

<Bool
:description="t('preferences.theme.followSystemTheme')"
:bool="followSystemTheme"
:on-change="(value) => onSelectChange('followSystemTheme', value)"
/>

<compound v-if="followSystemTheme">
<template #head>
<h6 class="title">
{{ t('preferences.theme.modeThemes') }}
</h6>
</template>
<template #children>
<cur-select
:description="t('preferences.theme.lightModeTheme')"
:value="lightModeTheme"
:options="themeOptions"
:on-change="(value) => onSelectChange('lightModeTheme', value)"
/>

<cur-select
:description="t('preferences.theme.darkModeTheme')"
:value="darkModeTheme"
:options="themeOptions"
:on-change="(value) => onSelectChange('darkModeTheme', value)"
/>
</template>
</compound>

<div class="custom-css">
<div class="description">
Expand Down Expand Up @@ -91,14 +96,14 @@ import { ref, onMounted } from 'vue'
import { usePreferencesStore } from '@/store/preferences'
import type { PreferencesState } from '@/store/preferences'
import { storeToRefs } from 'pinia'
import { isDarkThemeId } from 'common/theme'
import { useI18n } from 'vue-i18n'
import themeMd from './theme.md?raw'
import { themes as configThemes } from './config'
import markdownToHtml from '@/util/markdownToHtml'
import Bool from '../common/bool/index.vue'
import CurSelect from '../common/select/index.vue'
import Separator from '../common/separator/index.vue'
import Compound from '../common/compound/index.vue'
import type { PrefSelectOption } from '../common/types'

interface ThemePreview {
Expand All @@ -123,6 +128,9 @@ const themeOptions: PrefSelectOption<string>[] = configThemes.map((theme) => ({
value: theme.name
}))

const lightThemeOptions = themeOptions.filter((option) => !isDarkThemeId(option.value))
const darkThemeOptions = themeOptions.filter((option) => isDarkThemeId(option.value))

onMounted(async () => {
const newThemes: ThemePreview[] = []
for (const theme of configThemes) {
Expand All @@ -141,6 +149,23 @@ const onSelectChange = (type: keyof PreferencesState, value: unknown): void => {
</script>

<style>
/* The toggle leads the panel now, so give its label a little more weight — this
instance only; `Bool` is shared by every preferences panel. */
.pref-theme .follow-system-theme .description > span {
font-weight: 600;
}

/* The light/dark mode pickers sit on one row under the "follow system" toggle. */
.pref-theme .mode-themes-row {
display: flex;
align-items: flex-start;
gap: 16px;
}
.pref-theme .mode-themes-row > * {
flex: 1;
min-width: 0;
}

.offcial-themes {
margin-top: 12px;
display: grid;
Expand Down
1 change: 1 addition & 0 deletions packages/desktop/static/locales/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -713,6 +713,7 @@
"theme": {
"title": "Design",
"followSystemTheme": "Systemdesign folgen",
"followSystemNote": "Wenn Sie dem Systemthema folgen, ist die Themenliste unten gesperrt. Deaktivieren Sie dies, um Themen frei zu wechseln.",
"modeThemes": "Design-Auswahl",
"lightModeTheme": "Helles Modus-Design",
"darkModeTheme": "Dunkles Modus-Design",
Expand Down
1 change: 1 addition & 0 deletions packages/desktop/static/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -713,6 +713,7 @@
"theme": {
"title": "Theme",
"followSystemTheme": "Follow System Theme",
"followSystemNote": "Following the system locks the theme list below. Turn this off to switch themes freely.",
"modeThemes": "Theme Selection",
"lightModeTheme": "Light mode theme",
"darkModeTheme": "Dark mode theme",
Expand Down
1 change: 1 addition & 0 deletions packages/desktop/static/locales/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -713,6 +713,7 @@
"theme": {
"title": "Tema",
"followSystemTheme": "Seguir tema del sistema",
"followSystemNote": "Seguir el tema del sistema bloquea la lista de temas de abajo. Desactívalo para cambiar de tema libremente.",
"modeThemes": "Selección de Tema",
"lightModeTheme": "Tema de modo claro",
"darkModeTheme": "Tema de modo oscuro",
Expand Down
1 change: 1 addition & 0 deletions packages/desktop/static/locales/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -713,6 +713,7 @@
"theme": {
"title": "Thème",
"followSystemTheme": "Suivre le thème du système",
"followSystemNote": "Suivre le thème du système verrouille la liste des thèmes ci-dessous. Désactivez cette option pour changer librement de thème.",
"modeThemes": "Sélection du thème",
"lightModeTheme": "Thème en mode clair",
"darkModeTheme": "Thème en mode sombre",
Expand Down
1 change: 1 addition & 0 deletions packages/desktop/static/locales/ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -713,6 +713,7 @@
"theme": {
"title": "テーマ",
"followSystemTheme": "システムのテーマに従う",
"followSystemNote": "システムテーマに従っている間は、下のテーマ一覧を切り替えられません。オフにすると自由に切り替えられます。",
"modeThemes": "テーマの選択",
"lightModeTheme": "ライトモードのテーマ",
"darkModeTheme": "ダークモードのテーマ",
Expand Down
1 change: 1 addition & 0 deletions packages/desktop/static/locales/ko.json
Original file line number Diff line number Diff line change
Expand Up @@ -713,6 +713,7 @@
"theme": {
"title": "테마",
"followSystemTheme": "시스템 테마 따르기",
"followSystemNote": "시스템 테마를 따르는 동안에는 아래 테마 목록을 전환할 수 없습니다. 끄면 자유롭게 전환할 수 있습니다.",
"modeThemes": "테마 선택",
"lightModeTheme": "라이트 모드 테마",
"darkModeTheme": "다크 모드 테마",
Expand Down
1 change: 1 addition & 0 deletions packages/desktop/static/locales/nl.json
Original file line number Diff line number Diff line change
Expand Up @@ -713,6 +713,7 @@
"theme": {
"title": "Thema",
"followSystemTheme": "Systeemthema volgen",
"followSystemNote": "Het systeemthema volgen vergrendelt de themalijst hieronder. Schakel dit uit om vrij van thema te wisselen.",
"modeThemes": "Themaselectie",
"lightModeTheme": "Thema lichte modus",
"darkModeTheme": "Thema donkere modus",
Expand Down
1 change: 1 addition & 0 deletions packages/desktop/static/locales/pt.json
Original file line number Diff line number Diff line change
Expand Up @@ -713,6 +713,7 @@
"theme": {
"title": "Tema",
"followSystemTheme": "Seguir tema do sistema",
"followSystemNote": "Seguir o tema do sistema bloqueia a lista de temas abaixo. Desative esta opção para trocar de tema livremente.",
"modeThemes": "Seleção de Tema",
"lightModeTheme": "Tema do modo claro",
"darkModeTheme": "Tema do modo escuro",
Expand Down
1 change: 1 addition & 0 deletions packages/desktop/static/locales/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -713,6 +713,7 @@
"theme": {
"title": "Тема",
"followSystemTheme": "Следовать системной теме",
"followSystemNote": "Следование системной теме блокирует список тем ниже. Отключите это, чтобы свободно менять тему.",
"modeThemes": "Выбор темы",
"lightModeTheme": "Тема светлого режима",
"darkModeTheme": "Тема тёмного режима",
Expand Down
1 change: 1 addition & 0 deletions packages/desktop/static/locales/tr.json
Original file line number Diff line number Diff line change
Expand Up @@ -713,6 +713,7 @@
"theme": {
"title": "Tema",
"followSystemTheme": "Sistem Temasını Takip Et",
"followSystemNote": "Sistem temasını izlemek aşağıdaki tema listesini kilitler. Serbestçe tema değiştirmek için bunu kapatın.",
"modeThemes": "Tema Seçimi",
"lightModeTheme": "Açık mod teması",
"darkModeTheme": "Koyu mod teması",
Expand Down
1 change: 1 addition & 0 deletions packages/desktop/static/locales/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -713,6 +713,7 @@
"theme": {
"title": "主题",
"followSystemTheme": "跟随系统主题",
"followSystemNote": "跟随系统主题时,下方主题列表不可切换。关闭后即可自由切换。",
"modeThemes": "主题选择",
"lightModeTheme": "浅色模式主题",
"darkModeTheme": "深色模式主题",
Expand Down
1 change: 1 addition & 0 deletions packages/desktop/static/locales/zh-TW.json
Loading