mirror of
https://github.com/vbenjs/vben-admin-thin-next.git
synced 2025-01-24 02:00:22 +08:00
fix(theme): css filter breaking fixed position (#125)
Add css filters to `html` instead of `body`
This commit is contained in:
parent
d023fb1374
commit
c911af4aca
@ -15,11 +15,11 @@ export function setCssVar(prop: string, val: any, dom = document.documentElement
|
||||
dom.style.setProperty(prop, val);
|
||||
}
|
||||
|
||||
function toggleClass(flag: boolean, clsName: string) {
|
||||
const body = document.body;
|
||||
let { className } = body;
|
||||
function toggleClass(flag: boolean, clsName: string, target?: HTMLElement) {
|
||||
const targetEl = target || document.body;
|
||||
let { className } = targetEl;
|
||||
className = className.replace(clsName, '');
|
||||
document.body.className = flag ? `${className} ${clsName} ` : className;
|
||||
targetEl.className = flag ? `${className} ${clsName} ` : className;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -27,7 +27,7 @@ function toggleClass(flag: boolean, clsName: string) {
|
||||
* @param gray
|
||||
*/
|
||||
export const updateColorWeak = (colorWeak: boolean) => {
|
||||
toggleClass(colorWeak, 'color-weak');
|
||||
toggleClass(colorWeak, 'color-weak', document.documentElement);
|
||||
};
|
||||
|
||||
/**
|
||||
@ -35,7 +35,7 @@ export const updateColorWeak = (colorWeak: boolean) => {
|
||||
* @param gray
|
||||
*/
|
||||
export const updateGrayMode = (gray: boolean) => {
|
||||
toggleClass(gray, 'gray-mode');
|
||||
toggleClass(gray, 'gray-mode', document.documentElement);
|
||||
};
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user