aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/core
diff options
context:
space:
mode:
authorRigel Kent <sendmemail@rigelk.eu>2018-09-11 11:41:10 +0200
committerRigel Kent <sendmemail@rigelk.eu>2018-09-11 11:41:18 +0200
commite3f7f600e87a19079abd79e9d04d9a150484557c (patch)
tree336f932841f7f172375a01a02ffac2d6d89c2bc4 /client/src/app/core
parente78980ebd116be1ea901387c126876af902191e6 (diff)
downloadPeerTube-e3f7f600e87a19079abd79e9d04d9a150484557c.tar.gz
PeerTube-e3f7f600e87a19079abd79e9d04d9a150484557c.tar.zst
PeerTube-e3f7f600e87a19079abd79e9d04d9a150484557c.zip
remember theme in localStorage
Diffstat (limited to 'client/src/app/core')
-rw-r--r--client/src/app/core/theme/theme.service.ts13
1 files changed, 12 insertions, 1 deletions
diff --git a/client/src/app/core/theme/theme.service.ts b/client/src/app/core/theme/theme.service.ts
index d8e02e2e5..17d33b4e5 100644
--- a/client/src/app/core/theme/theme.service.ts
+++ b/client/src/app/core/theme/theme.service.ts
@@ -1,8 +1,10 @@
1import { Injectable } from '@angular/core' 1import { Injectable } from '@angular/core'
2import { peertubeLocalStorage } from '@app/shared/misc/peertube-local-storage'
2 3
3@Injectable() 4@Injectable()
4export class ThemeService { 5export class ThemeService {
5 private theme = document.querySelector('body') 6 private theme = document.querySelector('body')
7 private darkTheme = false
6 private previousTheme = {} 8 private previousTheme = {}
7 9
8 constructor () { 10 constructor () {
@@ -12,15 +14,24 @@ export class ThemeService {
12 this.previousTheme['submenuColor'] = 'rgb(32,32,32)' 14 this.previousTheme['submenuColor'] = 'rgb(32,32,32)'
13 this.previousTheme['inputColor'] = 'gray' 15 this.previousTheme['inputColor'] = 'gray'
14 this.previousTheme['inputPlaceholderColor'] = '#fff' 16 this.previousTheme['inputPlaceholderColor'] = '#fff'
17
18 this.darkTheme = (peertubeLocalStorage.getItem('theme') === 'dark')
19 console.log(this.darkTheme)
20 if (this.darkTheme) this.toggleDarkTheme(false)
15 } 21 }
16 22
17 toggleDarkTheme () { 23 toggleDarkTheme (setLocalStorage = true) {
18 // switch properties 24 // switch properties
19 this.switchProperty('mainBackgroundColor') 25 this.switchProperty('mainBackgroundColor')
20 this.switchProperty('mainForegroundColor') 26 this.switchProperty('mainForegroundColor')
21 this.switchProperty('submenuColor') 27 this.switchProperty('submenuColor')
22 this.switchProperty('inputColor') 28 this.switchProperty('inputColor')
23 this.switchProperty('inputPlaceholderColor') 29 this.switchProperty('inputPlaceholderColor')
30
31 if (setLocalStorage) {
32 this.darkTheme = !this.darkTheme
33 peertubeLocalStorage.setItem('theme', (this.darkTheme) ? 'dark' : 'default')
34 }
24 } 35 }
25 36
26 private switchProperty (property, newValue?) { 37 private switchProperty (property, newValue?) {