Show checked theme in color scheme menu (#4184)
This PR accounts (in the UI) for a default case where the `colorScheme` value is undefined. ### Change type - [x] `bugfix` ### Test plan 1. Open the editor an incognito tab 2. The Menu > Preferences > Color scheme should have a ticked selection ### Release notes - Fixed a bug where the user's color scheme was not shown in the menu by default.
This commit is contained in:
parent
bc20b2a418
commit
593c51065f
4 changed files with 4 additions and 1 deletions
|
@ -711,6 +711,7 @@ export const defaultTldrawOptions: {
|
||||||
export const defaultUserPreferences: Readonly<{
|
export const defaultUserPreferences: Readonly<{
|
||||||
animationSpeed: 0 | 1;
|
animationSpeed: 0 | 1;
|
||||||
color: "#02B1CC" | "#11B3A3" | "#39B178" | "#55B467" | "#7B66DC" | "#9D5BD2" | "#BD54C6" | "#E34BA9" | "#EC5E41" | "#F04F88" | "#F2555A" | "#FF802B";
|
color: "#02B1CC" | "#11B3A3" | "#39B178" | "#55B467" | "#7B66DC" | "#9D5BD2" | "#BD54C6" | "#E34BA9" | "#EC5E41" | "#F04F88" | "#F2555A" | "#FF802B";
|
||||||
|
colorScheme: "system";
|
||||||
edgeScrollSpeed: 1;
|
edgeScrollSpeed: 1;
|
||||||
isDynamicSizeMode: false;
|
isDynamicSizeMode: false;
|
||||||
isPasteAtCursorMode: false;
|
isPasteAtCursorMode: false;
|
||||||
|
|
|
@ -138,6 +138,7 @@ export const defaultUserPreferences = Object.freeze({
|
||||||
isWrapMode: false,
|
isWrapMode: false,
|
||||||
isDynamicSizeMode: false,
|
isDynamicSizeMode: false,
|
||||||
isPasteAtCursorMode: false,
|
isPasteAtCursorMode: false,
|
||||||
|
colorScheme: 'system',
|
||||||
}) satisfies Readonly<Omit<TLUserPreferences, 'id'>>
|
}) satisfies Readonly<Omit<TLUserPreferences, 'id'>>
|
||||||
|
|
||||||
/** @public */
|
/** @public */
|
||||||
|
|
|
@ -44,6 +44,7 @@ export class UserPreferencesManager {
|
||||||
isDynamicResizeMode: this.getIsDynamicResizeMode(),
|
isDynamicResizeMode: this.getIsDynamicResizeMode(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@computed getIsDarkMode() {
|
@computed getIsDarkMode() {
|
||||||
switch (this.user.userPreferences.get().colorScheme) {
|
switch (this.user.userPreferences.get().colorScheme) {
|
||||||
case 'dark':
|
case 'dark':
|
||||||
|
|
|
@ -16,7 +16,7 @@ export function ColorSchemeMenu() {
|
||||||
const trackEvent = useUiEvents()
|
const trackEvent = useUiEvents()
|
||||||
const currentColorScheme = useValue(
|
const currentColorScheme = useValue(
|
||||||
'colorScheme',
|
'colorScheme',
|
||||||
() => editor.user.getUserPreferences().colorScheme,
|
() => editor.user.getUserPreferences().colorScheme ?? 'system',
|
||||||
[editor]
|
[editor]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue