diff --git a/src/apps/settings-modal/settings-ui/SettingUIComplexity.tsx b/src/apps/settings-modal/settings-ui/SettingUIComplexity.tsx index c86a778c8..38bbcca8f 100644 --- a/src/apps/settings-modal/settings-ui/SettingUIComplexity.tsx +++ b/src/apps/settings-modal/settings-ui/SettingUIComplexity.tsx @@ -1,8 +1,9 @@ import * as React from 'react'; import { useShallow } from 'zustand/react/shallow'; +import type { UIComplexityMode } from '~/common/app.theme'; import { FormSelectControl, FormSelectOption } from '~/common/components/forms/FormSelectControl'; -import { UIComplexityMode, useUIPreferencesStore } from '~/common/state/store-ui'; +import { useUIPreferencesStore } from '~/common/state/store-ui'; const AppearanceOptions: FormSelectOption[] = [ diff --git a/src/common/app.theme.ts b/src/common/app.theme.ts index 12e7e2cf2..6f46b27a9 100644 --- a/src/common/app.theme.ts +++ b/src/common/app.theme.ts @@ -4,6 +4,11 @@ import { Inter, JetBrains_Mono } from 'next/font/google'; import { extendTheme } from '@mui/joy'; +// Definitions +export type UIComplexityMode = 'minimal' | 'pro' | 'extra'; +export type ContentScaling = 'xs' | 'sm' | 'md'; + + // CSS utils export const hideOnMobile = { display: { xs: 'none', md: 'flex' } }; @@ -27,7 +32,7 @@ const jetBrainsMono = JetBrains_Mono({ export const themeCodeFontFamilyCss = jetBrainsMono.style.fontFamily; -export const appTheme = extendTheme({ +export const createAppTheme = (uiComplexityMinimal: boolean) => extendTheme({ fontFamily: { body: themeFontFamilyCss, display: themeFontFamilyCss, @@ -111,14 +116,14 @@ export const appTheme = extendTheme({ // }, // }, - // JoyModal: { - // styleOverrides: { - // backdrop: { - // // backdropFilter: 'blur(2px)', - // backdropFilter: 'none', - // }, - // }, - // }, + JoyModal: !uiComplexityMinimal ? undefined : { + styleOverrides: { + backdrop: { + backdropFilter: 'none', + // backdropFilter: 'blur(2px)', + }, + }, + }, /** * Switch: increase the size of the thumb, to a default iconButton @@ -152,8 +157,7 @@ export const themeZIndexDesktopNav = 27; export const themeZIndexOverMobileDrawer = 1301; -// Dyanmic UI Sizing -export type ContentScaling = 'xs' | 'sm' | 'md'; +// Dynamic UI Sizing export function adjustContentScaling(scaling: ContentScaling, offset?: number) { if (!offset) return scaling; diff --git a/src/common/providers/ProviderTheming.tsx b/src/common/providers/ProviderTheming.tsx index 4f3c0c3f5..70e9dfb97 100644 --- a/src/common/providers/ProviderTheming.tsx +++ b/src/common/providers/ProviderTheming.tsx @@ -3,7 +3,8 @@ import * as React from 'react'; import { CacheProvider, EmotionCache } from '@emotion/react'; import { CssBaseline, CssVarsProvider } from '@mui/joy'; -import { appTheme, createEmotionCache } from '~/common/app.theme'; +import { createAppTheme, createEmotionCache } from '~/common/app.theme'; +import { useUIComplexityIsMinimal } from '~/common/state/store-ui'; // Client-side cache, shared for the whole session of the user in the browser. @@ -48,11 +49,21 @@ const _GlobalSVGFiltersMemo = React.memo(function GlobalSVGFilters() { }); -export const ProviderTheming = (props: { emotionCache?: EmotionCache, children: React.ReactNode }) => - - - - <_GlobalSVGFiltersMemo /> - {props.children} - - ; \ No newline at end of file +export const ProviderTheming = (props: { emotionCache?: EmotionCache, children: React.ReactNode }) => { + + // external state + const zenMode = useUIComplexityIsMinimal(); + + // recreate the theme only to apply zen touches + const theme = React.useMemo(() => createAppTheme(zenMode), [zenMode]); + + return ( + + + + <_GlobalSVGFiltersMemo /> + {props.children} + + + ); +}; \ No newline at end of file diff --git a/src/common/state/store-ui.ts b/src/common/state/store-ui.ts index 240c8556b..633ea75ec 100644 --- a/src/common/state/store-ui.ts +++ b/src/common/state/store-ui.ts @@ -2,14 +2,12 @@ import * as React from 'react'; import { create } from 'zustand'; import { persist } from 'zustand/middleware'; -import type { ContentScaling } from '~/common/app.theme'; +import type { ContentScaling, UIComplexityMode } from '~/common/app.theme'; import { browserLangOrUS } from '~/common/util/pwaUtils'; // UI Preferences -export type UIComplexityMode = 'minimal' | 'pro' | 'extra'; - interface UIPreferencesStore { // UI Features