mirror of
https://github.com/danog/telegram-tt.git
synced 2025-01-22 05:11:55 +01:00
Dark Theme: Support browser UI coloring (#1027)
This commit is contained in:
parent
81c3d26a0f
commit
0b59ebd7b0
@ -27,16 +27,21 @@ const colors = (Object.keys(themeColors) as Array<keyof typeof themeColors>).map
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
export default (theme: ISettings['theme'], withAnimation: boolean) => {
|
export default (theme: ISettings['theme'], withAnimation: boolean) => {
|
||||||
|
const isDarkTheme = theme === 'dark';
|
||||||
const shouldAnimate = isInitialized && withAnimation;
|
const shouldAnimate = isInitialized && withAnimation;
|
||||||
const startIndex = theme === 'dark' ? 0 : 1;
|
const startIndex = isDarkTheme ? 0 : 1;
|
||||||
const endIndex = theme === 'dark' ? 1 : 0;
|
const endIndex = isDarkTheme ? 1 : 0;
|
||||||
const startAt = Date.now();
|
const startAt = Date.now();
|
||||||
|
const themeColorTag = document.querySelector('meta[name="theme-color"]');
|
||||||
|
|
||||||
document.documentElement.classList.remove(`theme-${theme === 'dark' ? 'light' : 'dark'}`);
|
document.documentElement.classList.remove(`theme-${isDarkTheme ? 'light' : 'dark'}`);
|
||||||
if (isInitialized) {
|
if (isInitialized) {
|
||||||
document.documentElement.classList.add('disable-animations');
|
document.documentElement.classList.add('disable-animations');
|
||||||
}
|
}
|
||||||
document.documentElement.classList.add(`theme-${theme}`);
|
document.documentElement.classList.add(`theme-${theme}`);
|
||||||
|
if (themeColorTag) {
|
||||||
|
themeColorTag.setAttribute('content', isDarkTheme ? '#212121' : '#fff');
|
||||||
|
}
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
document.documentElement.classList.remove('disable-animations');
|
document.documentElement.classList.remove('disable-animations');
|
||||||
|
Loading…
x
Reference in New Issue
Block a user