Skip to content

Commit

Permalink
default theme changes
Browse files Browse the repository at this point in the history
  • Loading branch information
oznu committed Aug 27, 2019
1 parent 53c01fb commit 52a814a
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 4 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Change Log

All notable changes to this project will be documented in this file. This project uses [Semantic Versioning](https://semver.org/).+
All notable changes to this project will be documented in this file. This project uses [Semantic Versioning](https://semver.org/).

## 4.6.1 (2019-08-24)

Expand Down
8 changes: 7 additions & 1 deletion config.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,14 @@
"theme": {
"title": "UI Theme",
"type": "string",
"default": "teal",
"default": "auto",
"oneOf": [
{
"title": "Default",
"enum": [
"auto"
]
},
{
"title": "Red",
"enum": [
Expand Down
2 changes: 1 addition & 1 deletion src/core/config/config.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ export class ConfigService {
instanceId: this.instanceId,
},
formAuth: Boolean(this.ui.auth !== 'none'),
theme: this.ui.theme || 'teal',
theme: this.ui.theme || 'auto',
serverTimestamp: new Date().toISOString(),
};
}
Expand Down
13 changes: 12 additions & 1 deletion ui/src/app/core/auth/auth.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,18 @@ export class AuthService {
}

setTheme(theme: string) {
if (this.theme) {
if (theme === 'auto') {
// select theme based on os dark mode preferences
try {
if (matchMedia('(prefers-color-scheme: dark)').matches) {
theme = 'dark-mode';
} else {
theme = 'teal';
}
} catch (e) {
theme = 'teal';
}
} else if (this.theme) {
window.document.querySelector('body').classList.remove(`config-ui-x-${this.theme}`);
}
this.theme = theme;
Expand Down

0 comments on commit 52a814a

Please sign in to comment.