diff --git a/workbench/components/EditorialCard/EditorialCard.jsx b/workbench/components/EditorialCard/EditorialCard.jsx index 4a997bb13..b826a6512 100644 --- a/workbench/components/EditorialCard/EditorialCard.jsx +++ b/workbench/components/EditorialCard/EditorialCard.jsx @@ -18,11 +18,18 @@ const EditorialCardLink = ({ href, title, dataContentParent, children }) => { return children; }; -const EditorialCard = ({ title, label, href, children, dataContentParent, isHorizontal }) => { +const isValidCSSVar = (variable) => { + return /^--[a-zA-Z0-9-]+$/.test(variable); +}; + +const EditorialCard = ({ title, label, href, color, + children, dataContentParent, isHorizontal }) => { const classes = classNames('coop-c-editorialcard', [ isHorizontal ? 'coop-c-editorialcard--horizontal' : null, ]); + const backgroundColor = isValidCSSVar(color) ? `var(${color})` : 'transparent'; + return (
@@ -45,7 +52,7 @@ const EditorialCard = ({ title, label, href, children, dataContentParent, isHori /> -
+
{label ?

{label}

: null}

{title}

diff --git a/workbench/pages/components/editorial-card/index.jsx b/workbench/pages/components/editorial-card/index.jsx index 39adae185..ed8e47a22 100644 --- a/workbench/pages/components/editorial-card/index.jsx +++ b/workbench/pages/components/editorial-card/index.jsx @@ -16,6 +16,7 @@ const config = [ type: 'text', }, { name: 'href', value: '#', type: 'text' }, + { name: 'color', value: '--color-white', type: 'text' }, { name: 'isHorizontal', value: false, type: 'checkbox' }, ];