diff --git a/apps/api/src/app/user/update-user-setting.dto.ts b/apps/api/src/app/user/update-user-setting.dto.ts index ea2e784ab..6c0d614e5 100644 --- a/apps/api/src/app/user/update-user-setting.dto.ts +++ b/apps/api/src/app/user/update-user-setting.dto.ts @@ -1,4 +1,4 @@ -import type { DateRange, ViewMode } from '@ghostfolio/common/types'; +import type { Appearance, DateRange, ViewMode } from '@ghostfolio/common/types'; import { IsBoolean, IsIn, @@ -47,4 +47,8 @@ export class UpdateUserSettingDto { @IsIn(['DEFAULT', 'ZEN']) @IsOptional() viewMode?: ViewMode; + + @IsIn(['DARK', 'LIGHT']) + @IsOptional() + appearance?: Appearance; } diff --git a/apps/client/src/app/app.component.ts b/apps/client/src/app/app.component.ts index 7f6774f52..ed3897230 100644 --- a/apps/client/src/app/app.component.ts +++ b/apps/client/src/app/app.component.ts @@ -13,6 +13,7 @@ import { } from '@ghostfolio/common/config'; import { InfoItem, User } from '@ghostfolio/common/interfaces'; import { hasPermission, permissions } from '@ghostfolio/common/permissions'; +import { Appearance } from '@ghostfolio/common/types'; import { MaterialCssVarsService } from 'angular-material-css-vars'; import { DeviceDetectorService } from 'ngx-device-detector'; import { Subject } from 'rxjs'; @@ -77,6 +78,8 @@ export class AppComponent implements OnDestroy, OnInit { permissions.createUserAccount ); + this.initializeTheme(this.user?.settings.appearance); + this.changeDetectorRef.markForCheck(); }); } @@ -97,10 +100,12 @@ export class AppComponent implements OnDestroy, OnInit { this.unsubscribeSubject.complete(); } - private initializeTheme() { - this.materialCssVarsService.setDarkTheme( - window.matchMedia('(prefers-color-scheme: dark)').matches - ); + private initializeTheme(userPreferredAppearance?: Appearance) { + const isDarkTheme = userPreferredAppearance + ? userPreferredAppearance === 'DARK' + : window.matchMedia('(prefers-color-scheme: dark)').matches; + + this.materialCssVarsService.setDarkTheme(isDarkTheme); window.matchMedia('(prefers-color-scheme: dark)').addListener((event) => { this.materialCssVarsService.setDarkTheme(event.matches); diff --git a/apps/client/src/app/pages/account/account-page.html b/apps/client/src/app/pages/account/account-page.html index e3c446f57..b40141d27 100644 --- a/apps/client/src/app/pages/account/account-page.html +++ b/apps/client/src/app/pages/account/account-page.html @@ -167,7 +167,7 @@ -
+
View Mode
@@ -190,6 +190,30 @@
+
+
+ Appearance +
+
+ + + AUTO + LIGHT + DARK + + +
+
diff --git a/apps/client/src/styles.scss b/apps/client/src/styles.scss index ae0ef8c40..2e6fe722a 100644 --- a/apps/client/src/styles.scss +++ b/apps/client/src/styles.scss @@ -97,6 +97,12 @@ body { color: rgba(var(--light-primary-text)); } } + + .with-placeholder-as-option { + .mat-select-placeholder { + color: rgba(var(--light-primary-text)); + } + } } } @@ -228,3 +234,9 @@ ngx-skeleton-loader { .with-info-message { height: calc(100vh - 5rem - 3.5rem) !important; } + +.with-placeholder-as-option { + .mat-select-placeholder { + color: rgba(var(--dark-primary-text)); + } +} diff --git a/libs/common/src/lib/interfaces/user-settings.interface.ts b/libs/common/src/lib/interfaces/user-settings.interface.ts index 1237696a4..9651cef60 100644 --- a/libs/common/src/lib/interfaces/user-settings.interface.ts +++ b/libs/common/src/lib/interfaces/user-settings.interface.ts @@ -1,6 +1,7 @@ -import { DateRange, ViewMode } from '@ghostfolio/common/types'; +import { DateRange, ViewMode, Appearance } from '@ghostfolio/common/types'; export interface UserSettings { + appearance?: Appearance; baseCurrency?: string; benchmark?: string; dateRange?: DateRange; diff --git a/libs/common/src/lib/types/appearance.type.ts b/libs/common/src/lib/types/appearance.type.ts new file mode 100644 index 000000000..dd944df33 --- /dev/null +++ b/libs/common/src/lib/types/appearance.type.ts @@ -0,0 +1 @@ +export type Appearance = 'LIGHT' | 'DARK'; diff --git a/libs/common/src/lib/types/index.ts b/libs/common/src/lib/types/index.ts index 54ef29ef4..7e7559459 100644 --- a/libs/common/src/lib/types/index.ts +++ b/libs/common/src/lib/types/index.ts @@ -9,6 +9,7 @@ import type { OrderWithAccount } from './order-with-account.type'; import type { RequestWithUser } from './request-with-user.type'; import { ToggleOption } from './toggle-option.type'; import type { ViewMode } from './view-mode.type'; +import type { Appearance } from './appearance.type'; export type { AccessWithGranteeUser, @@ -21,5 +22,6 @@ export type { OrderWithAccount, RequestWithUser, ToggleOption, - ViewMode + ViewMode, + Appearance };