未验证 提交 c911af4a 编写于 作者: Z ZhaoBin 提交者: GitHub

fix(theme): css filter breaking fixed position (#125)

Add css filters to `html` instead of `body`
上级 d023fb13
......@@ -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);
};
/**
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册