mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-10-03 09:49:20 +02:00
Wait CSS variables to be ready
This commit is contained in:
parent
334ad174a9
commit
a496da3780
1 changed files with 22 additions and 1 deletions
|
@ -170,12 +170,33 @@ export class ThemeService {
|
|||
this.localStorageService.removeItem(UserLocalStorageKeys.LAST_ACTIVE_THEME, false)
|
||||
}
|
||||
|
||||
setTimeout(() => this.injectColorPalette(), 0)
|
||||
this.injectCoreColorPalette()
|
||||
|
||||
this.oldThemeName = currentTheme
|
||||
}
|
||||
|
||||
private injectCoreColorPalette (iteration = 0) {
|
||||
if (iteration > 10) {
|
||||
logger.error('Cannot inject core color palette: too many iterations')
|
||||
return
|
||||
}
|
||||
|
||||
if (!this.canInjectColorPalette()) {
|
||||
return setTimeout(() => this.injectCoreColorPalette(iteration + 1))
|
||||
}
|
||||
|
||||
return this.injectColorPalette()
|
||||
}
|
||||
|
||||
private canInjectColorPalette () {
|
||||
const computedStyle = getComputedStyle(document.body)
|
||||
|
||||
return !!computedStyle.getPropertyValue('--fg')
|
||||
}
|
||||
|
||||
private injectColorPalette () {
|
||||
debugLogger(`Injecting color palette`)
|
||||
|
||||
const rootStyle = document.body.style
|
||||
const computedStyle = getComputedStyle(document.body)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue