From 85886afeb4abfed60c688a9a8f0d32aa31270f5a Mon Sep 17 00:00:00 2001 From: Red Adaya Date: Mon, 15 Apr 2024 20:03:07 +0800 Subject: [PATCH] fix validation --- src/app/common/elements/termstyleblock.tsx | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/src/app/common/elements/termstyleblock.tsx b/src/app/common/elements/termstyleblock.tsx index 2f7c73fd3..831282d5d 100644 --- a/src/app/common/elements/termstyleblock.tsx +++ b/src/app/common/elements/termstyleblock.tsx @@ -55,11 +55,6 @@ class TermStyleBlock extends React.Component<{ return element.style.color !== ""; } - isValidTermCSSVariable(key) { - const cssVarName = `--term-${key}`; - return VALID_CSS_VARIABLES.includes(cssVarName); - } - camelCaseToKebabCase(str) { return str.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase(); } @@ -75,10 +70,10 @@ class TermStyleBlock extends React.Component<{ return null; } const styleProperties = Object.entries(theme) - // .filter(([key, value]) => { - // const cssVarName = `--term-${this.camelCaseToKebabCase(key)}`; - // return this.isValidTermCSSVariable(cssVarName) && this.isValidCSSColor(value); - // }) + .filter(([key, value]) => { + const cssVarName = `--term-${this.camelCaseToKebabCase(key)}`; + return VALID_CSS_VARIABLES.includes(cssVarName) && this.isValidCSSColor(value); + }) .map(([key, value]) => `--term-${key}: ${value};`) .join(" "); @@ -90,8 +85,10 @@ class TermStyleBlock extends React.Component<{ render() { const styleRules = this.getStyleRules(); - - return styleRules ? : null; + if (!styleRules) { + return null; + } + return ; } }