aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/menu/menu.component.ts
diff options
context:
space:
mode:
authorRigel Kent <sendmemail@rigelk.eu>2018-09-04 01:28:04 +0200
committerRigel Kent <par@rigelk.eu>2018-09-04 23:24:34 +0200
commit9a0fc8409c7a783348ec212fa9f38d0a98413467 (patch)
tree8b17264ef915e339d067abe6717c1574f1a2f36b /client/src/app/menu/menu.component.ts
parent3b766e181c59ce148fde73e507276c9fbaf37eb1 (diff)
downloadPeerTube-9a0fc8409c7a783348ec212fa9f38d0a98413467.tar.gz
PeerTube-9a0fc8409c7a783348ec212fa9f38d0a98413467.tar.zst
PeerTube-9a0fc8409c7a783348ec212fa9f38d0a98413467.zip
add theming via css custom properties
and a bonus dark color theme toggle
Diffstat (limited to 'client/src/app/menu/menu.component.ts')
-rw-r--r--client/src/app/menu/menu.component.ts24
1 files changed, 24 insertions, 0 deletions
diff --git a/client/src/app/menu/menu.component.ts b/client/src/app/menu/menu.component.ts
index dded6b4d5..3de4a78af 100644
--- a/client/src/app/menu/menu.component.ts
+++ b/client/src/app/menu/menu.component.ts
@@ -22,6 +22,8 @@ export class MenuComponent implements OnInit {
22 [UserRight.MANAGE_VIDEO_ABUSES]: '/admin/video-abuses', 22 [UserRight.MANAGE_VIDEO_ABUSES]: '/admin/video-abuses',
23 [UserRight.MANAGE_VIDEO_BLACKLIST]: '/admin/video-blacklist' 23 [UserRight.MANAGE_VIDEO_BLACKLIST]: '/admin/video-blacklist'
24 } 24 }
25 private theme = document.querySelector('body')
26 private previousTheme = { }
25 27
26 constructor ( 28 constructor (
27 private authService: AuthService, 29 private authService: AuthService,
@@ -51,6 +53,13 @@ export class MenuComponent implements OnInit {
51 } 53 }
52 } 54 }
53 ) 55 )
56
57 // initialise the alternative theme with dark theme colors
58 this.previousTheme['mainBackgroundColor'] = '#111111'
59 this.previousTheme['mainForegroundColor'] = '#fff'
60 this.previousTheme['submenuColor'] = 'rgb(32,32,32)'
61 this.previousTheme['inputColor'] = 'gray'
62 this.previousTheme['inputPlaceholderColor'] = '#fff'
54 } 63 }
55 64
56 isRegistrationAllowed () { 65 isRegistrationAllowed () {
@@ -96,6 +105,21 @@ export class MenuComponent implements OnInit {
96 this.languageChooserModal.show() 105 this.languageChooserModal.show()
97 } 106 }
98 107
108 toggleDarkTheme () {
109 // switch properties
110 this.switchProperty('mainBackgroundColor')
111 this.switchProperty('mainForegroundColor')
112 this.switchProperty('submenuColor')
113 this.switchProperty('inputColor')
114 this.switchProperty('inputPlaceholderColor')
115 }
116
117 private switchProperty (property, newValue?) {
118 const propertyOldvalue = window.getComputedStyle(this.theme).getPropertyValue('--' + property)
119 this.theme.style.setProperty('--' + property, (newValue) ? newValue : this.previousTheme[property])
120 this.previousTheme[property] = propertyOldvalue
121 }
122
99 private computeIsUserHasAdminAccess () { 123 private computeIsUserHasAdminAccess () {
100 const right = this.getFirstAdminRightAvailable() 124 const right = this.getFirstAdminRightAvailable()
101 125