From ea1f42d810e4eaddb78dfe0cc5f205417f5853dd Mon Sep 17 00:00:00 2001 From: Atul Varma Date: Sat, 6 Feb 2021 10:57:41 -0500 Subject: [PATCH] Simplify stroke/fill logic. --- lib/browser-main.tsx | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/lib/browser-main.tsx b/lib/browser-main.tsx index b4f1290..9b61784 100644 --- a/lib/browser-main.tsx +++ b/lib/browser-main.tsx @@ -10,8 +10,8 @@ const appEl = document.getElementById(APP_ID); const SvgVocabulary: SvgSymbolData[] = _SvgVocabulary as any; -const BLACK = "#000000"; -const WHITE = "#ffffff"; +const STROKE_REPLACEMENT_COLOR = "#000000"; +const FILL_REPLACEMENT_COLOR = "#ffffff"; if (!appEl) { throw new Error(`Unable to find #${APP_ID}!`); @@ -35,18 +35,14 @@ function reactifySvgSymbolElement( key: number ): JSX.Element { let { fill, stroke } = el.props; - if (fill === BLACK && stroke === "none") { + if (fill === STROKE_REPLACEMENT_COLOR) { // The fill represents a "shadow" area, so use our stroke color here. fill = ctx.stroke; - } else { - // Replace the hard-coded fill color with our fill color. - if (fill && fill !== "none") { - fill = ctx.fill; - } - // Replace the hard-coded stroke color with our stroke color. - if (stroke && stroke !== "none") { - stroke = ctx.stroke; - } + } else if (fill === FILL_REPLACEMENT_COLOR) { + fill = ctx.fill; + } + if (stroke === STROKE_REPLACEMENT_COLOR) { + stroke = ctx.stroke; } return React.createElement( el.tagName,