mirror of
https://github.com/zitadel/zitadel.git
synced 2025-05-06 23:26:46 +00:00

* feat: enable only specific themes in label policy * feat: enable only specific themes in label policy * feat: enable only specific themes in label policy * feat: enable only specific themes in label policy * add management in console * pass enabledTheme * render login ui based on enabled theme * add in branding / settings service and name consistently * update console to latest proto state * fix console linting * fix linting * cleanup * add translations --------- Co-authored-by: Livio Spring <livio.a@gmail.com> Co-authored-by: Tim Möhlmann <tim+github@zitadel.com>
52 lines
1.6 KiB
JavaScript
52 lines
1.6 KiB
JavaScript
if (isAutoMode()) {
|
|
const usesDarkTheme = hasDarkModeOverwriteCookie() || (!hasLightModeOverwriteCookie() && window.matchMedia('(prefers-color-scheme: dark)').matches);
|
|
if (usesDarkTheme) {
|
|
document.documentElement.classList.replace('lgn-light-theme', 'lgn-dark-theme');
|
|
writeModeCookie('dark');
|
|
} else {
|
|
document.documentElement.classList.replace('lgn-dark-theme', 'lgn-light-theme');
|
|
writeModeCookie('light');
|
|
}
|
|
}
|
|
|
|
function isAutoMode() {
|
|
return document.documentElement.dataset["themeMode"] === "0"
|
|
}
|
|
|
|
function hasDarkModeOverwriteCookie() {
|
|
return getCookie('mode') === 'dark';
|
|
}
|
|
|
|
function hasLightModeOverwriteCookie() {
|
|
return getCookie('mode') === 'light';
|
|
}
|
|
|
|
function writeModeCookie(mode) {
|
|
let cookieMode = getCookie('mode')
|
|
if (cookieMode === '' || cookieMode.startsWith('auto')) {
|
|
setCookie('mode', 'auto-' + mode, 365);
|
|
}
|
|
}
|
|
|
|
function getCookie(cname) {
|
|
let name = cname + '=';
|
|
let decodedCookie = decodeURIComponent(document.cookie);
|
|
let ca = decodedCookie.split(';');
|
|
for (let i = 0; i < ca.length; i++) {
|
|
let c = ca[i];
|
|
while (c.charAt(0) === ' ') {
|
|
c = c.substring(1);
|
|
}
|
|
if (c.indexOf(name) === 0) {
|
|
return c.substring(name.length, c.length);
|
|
}
|
|
}
|
|
return '';
|
|
}
|
|
|
|
function setCookie(name, value, exdays) {
|
|
let d = new Date();
|
|
d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000));
|
|
let expires = "expires=" + d.toUTCString();
|
|
document.cookie = name + "=" + value + ";" + expires + ";path=/";
|
|
} |