Merge dfa52d1736
into e1739ac4fc
This commit is contained in:
commit
f8f66b88e3
4 changed files with 54 additions and 1 deletions
|
@ -1,13 +1,24 @@
|
|||
<script lang="ts">
|
||||
import { onMount } from 'svelte';
|
||||
import { browser } from '$app/environment';
|
||||
import { colorTheme } from '$lib/stores/preferences.store';
|
||||
import IconButton from '../elements/buttons/icon-button.svelte';
|
||||
|
||||
import { appearanceSettings } from '../../stores/preferences.store';
|
||||
|
||||
const toggleTheme = () => {
|
||||
$colorTheme = $colorTheme === 'dark' ? 'light' : 'dark';
|
||||
};
|
||||
|
||||
$: {
|
||||
function checkSystemTheme() {
|
||||
if($appearanceSettings.autoTheme) {
|
||||
const darkModeMediaQuery = window.matchMedia('(prefers-color-scheme: dark)');
|
||||
$colorTheme = darkModeMediaQuery.matches ? 'dark' : 'light';
|
||||
changeTheme()
|
||||
}
|
||||
};
|
||||
|
||||
function changeTheme() {
|
||||
if (browser) {
|
||||
if ($colorTheme === 'light') {
|
||||
document.documentElement.classList.remove('dark');
|
||||
|
@ -15,7 +26,21 @@
|
|||
document.documentElement.classList.add('dark');
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
$: {
|
||||
const theme = $colorTheme;
|
||||
changeTheme();
|
||||
}
|
||||
|
||||
$: {
|
||||
const autoTheme = $appearanceSettings.autoTheme;
|
||||
checkSystemTheme();
|
||||
}
|
||||
|
||||
onMount(() => {
|
||||
window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', checkSystemTheme);
|
||||
});
|
||||
</script>
|
||||
|
||||
<IconButton on:click={toggleTheme} title="Toggle theme">
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
<script lang="ts">
|
||||
import { fade } from 'svelte/transition';
|
||||
import { appearanceSettings } from '../../stores/preferences.store';
|
||||
import SettingSwitch from '../admin-page/settings/setting-switch.svelte';
|
||||
</script>
|
||||
|
||||
<section class="my-4">
|
||||
<div in:fade={{ duration: 500 }}>
|
||||
<div class="ml-4 mt-4 flex flex-col gap-4">
|
||||
<div class="ml-4">
|
||||
<SettingSwitch title="Theme selection" subtitle="Automatically set the theme to light or dark based on your browser's system preference." bind:checked={$appearanceSettings.autoTheme} />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
|
@ -11,6 +11,7 @@
|
|||
import OAuthSettings from './oauth-settings.svelte';
|
||||
import PartnerSettings from './partner-settings.svelte';
|
||||
import SidebarSettings from './sidebar-settings.svelte';
|
||||
import AppearanceSettings from './appearance-settings.svelte';
|
||||
import UserAPIKeyList from './user-api-key-list.svelte';
|
||||
import UserProfileSettings from './user-profile-settings.svelte';
|
||||
|
||||
|
@ -33,6 +34,10 @@
|
|||
<UserAPIKeyList bind:keys />
|
||||
</SettingAccordion>
|
||||
|
||||
<SettingAccordion title="Appearance" subtitle="Manage the appearance of Immich">
|
||||
<AppearanceSettings />
|
||||
</SettingAccordion>
|
||||
|
||||
<SettingAccordion title="Authorized Devices" subtitle="Manage your logged-in devices">
|
||||
<DeviceList bind:devices />
|
||||
</SettingAccordion>
|
||||
|
|
|
@ -57,6 +57,14 @@ export const sidebarSettings = persisted<SidebarSettings>('sidebar-settings-1',
|
|||
sharing: true,
|
||||
});
|
||||
|
||||
export interface AppearanceSettings {
|
||||
autoTheme: boolean;
|
||||
}
|
||||
|
||||
export const appearanceSettings = persisted<AppearanceSettings>('appearance-settings-1', {
|
||||
autoTheme: false,
|
||||
});
|
||||
|
||||
export enum AlbumViewMode {
|
||||
Cover = 'Cover',
|
||||
List = 'List',
|
||||
|
|
Loading…
Add table
Reference in a new issue