Skip to content

Commit

Permalink
Minor modification.
Browse files Browse the repository at this point in the history
  • Loading branch information
kovacsv committed Jun 17, 2024
1 parent 28b6e4c commit e73167e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 2 additions & 2 deletions source/website/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { NavigationMode, ProjectionMode } from '../engine/viewer/camera.js';
import { RGBAColor, RGBColor } from '../engine/model/color.js';
import { EdgeSettings } from '../engine/viewer/viewermodel.js';
import { CookieGetBoolVal, CookieGetRGBColorVal, CookieGetIntVal, CookieGetStringVal, CookieSetBoolVal, CookieSetRGBColorVal, CookieSetIntVal, CookieSetStringVal, CookieSetRGBAColorVal, CookieGetRGBAColorVal } from './cookiehandler.js';
import { GetPreferredColorScheme } from './utils.js';

export const Theme =
{
Expand Down Expand Up @@ -30,8 +31,7 @@ export class Settings

LoadFromCookies ()
{
const preferredColorScheme = window.matchMedia ('(prefers-color-scheme: dark)').matches ? Theme.Dark : Theme.Light;
this.themeId = CookieGetIntVal ('ov_theme_id', preferredColorScheme);
this.themeId = CookieGetIntVal ('ov_theme_id', GetPreferredColorScheme ());
this.environmentMapName = CookieGetStringVal ('ov_environment_map', 'fishermans_bastion');
this.backgroundIsEnvMap = CookieGetBoolVal ('ov_background_is_envmap', false);
this.backgroundColor = CookieGetRGBAColorVal ('ov_background_color', new RGBAColor (255, 255, 255, 255));
Expand Down
6 changes: 6 additions & 0 deletions source/website/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { RGBColor, RGBColorToHexString } from '../engine/model/color.js';
import { CreateObjectUrl } from '../engine/io/bufferutils.js';
import { AddDiv, CreateDiv, AddDomElement } from '../engine/viewer/domutils.js';
import { Loc } from '../engine/core/localization.js';
import { Theme } from './settings.js';

export function GetNameOrDefault (originalName, defaultName)
{
Expand All @@ -27,6 +28,11 @@ export function GetMaterialName (originalName)
return GetNameOrDefault (originalName, Loc ('No Name'));
}

export function GetPreferredColorScheme ()
{
return window.matchMedia ('(prefers-color-scheme: dark)').matches ? Theme.Dark : Theme.Light;
}

export function IsHoverEnabled ()
{
return window.matchMedia ('(hover: hover)').matches;
Expand Down

0 comments on commit e73167e

Please sign in to comment.