Skip to content
Open
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
4 changes: 4 additions & 0 deletions _locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,10 @@
"message": "Theme",
"description": "Theme"
},
"theme_system": {
"message": "System",
"description": "Theme that follows the system light/dark setting"
},
"theme_light": {
"message": "Light",
"description": "Light theme"
Expand Down
41 changes: 31 additions & 10 deletions src/components/Popup.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@
v-cloak
v-bind:class="{
'theme-normal':
theme !== 'accessibility' &&
theme !== 'dark' &&
theme !== 'simple' &&
theme !== 'compact' &&
theme !== 'flat',
'theme-accessibility': theme === 'accessibility',
'theme-dark': theme === 'dark',
'theme-simple': theme === 'simple',
'theme-compact': theme === 'compact',
'theme-flat': theme === 'flat',
effectiveTheme !== 'accessibility' &&
effectiveTheme !== 'dark' &&
effectiveTheme !== 'simple' &&
effectiveTheme !== 'compact' &&
effectiveTheme !== 'flat',
'theme-accessibility': effectiveTheme === 'accessibility',
'theme-dark': effectiveTheme === 'dark',
'theme-simple': effectiveTheme === 'simple',
'theme-compact': effectiveTheme === 'compact',
'theme-flat': effectiveTheme === 'flat',
hideoutline,
}"
v-on:mousedown="hideoutline = true"
Expand Down Expand Up @@ -88,14 +88,35 @@ for (const module of computedPrototype) {
Object.assign(computed, module);
}

Object.assign(computed, {
effectiveTheme(this: { theme: string; systemDark: boolean }) {
if (this.theme === "system") {
return this.systemDark ? "dark" : "normal";
}
return this.theme;
},
});

const darkQuery = window.matchMedia("(prefers-color-scheme: dark)");

export default Vue.extend({
data: function () {
return {
hideoutline: true,
systemDark: darkQuery.matches,
};
},
computed,
created() {
darkQuery.addEventListener("change", this.onSystemThemeChange);
},
beforeDestroy() {
darkQuery.removeEventListener("change", this.onSystemThemeChange);
},
methods: {
onSystemThemeChange(event: MediaQueryListEvent) {
this.systemDark = event.matches;
},
hideQr() {
this.$store.commit("style/hideQr");
},
Expand Down
1 change: 1 addition & 0 deletions src/components/Popup/PreferencesPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
v-model="theme"
style="margin-left: 10px"
>
<option value="system">{{ i18n.theme_system }}</option>
<option value="normal">{{ i18n.theme_light }}</option>
<option value="dark">{{ i18n.theme_dark }}</option>
<option value="simple">{{ i18n.theme_simple }}</option>
Expand Down
2 changes: 1 addition & 1 deletion src/store/Menu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export class Menu implements Module {
useAutofill: UserSettings.items.autofill === true,
smartFilter: UserSettings.items.smartFilter === true,
enableContextMenu: UserSettings.items.enableContextMenu === true,
theme: UserSettings.items.theme || (isSafari ? "flat" : "normal"),
theme: UserSettings.items.theme || (isSafari ? "flat" : "system"),
autolock: Number(UserSettings.items.autolock) || 30,
backupDisabled: await ManagedStorage.get("disableBackup", false),
exportDisabled: await ManagedStorage.get("disableExport", false),
Expand Down