Simplify stroke/fill logic.

pull/1/head
Atul Varma 2021-02-06 10:57:41 -05:00
rodzic 026b02ef7f
commit ea1f42d810
1 zmienionych plików z 8 dodań i 12 usunięć

Wyświetl plik

@ -10,8 +10,8 @@ const appEl = document.getElementById(APP_ID);
const SvgVocabulary: SvgSymbolData[] = _SvgVocabulary as any; const SvgVocabulary: SvgSymbolData[] = _SvgVocabulary as any;
const BLACK = "#000000"; const STROKE_REPLACEMENT_COLOR = "#000000";
const WHITE = "#ffffff"; const FILL_REPLACEMENT_COLOR = "#ffffff";
if (!appEl) { if (!appEl) {
throw new Error(`Unable to find #${APP_ID}!`); throw new Error(`Unable to find #${APP_ID}!`);
@ -35,18 +35,14 @@ function reactifySvgSymbolElement(
key: number key: number
): JSX.Element { ): JSX.Element {
let { fill, stroke } = el.props; 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. // The fill represents a "shadow" area, so use our stroke color here.
fill = ctx.stroke; fill = ctx.stroke;
} else { } else if (fill === FILL_REPLACEMENT_COLOR) {
// Replace the hard-coded fill color with our fill color. fill = ctx.fill;
if (fill && fill !== "none") { }
fill = ctx.fill; if (stroke === STROKE_REPLACEMENT_COLOR) {
} stroke = ctx.stroke;
// Replace the hard-coded stroke color with our stroke color.
if (stroke && stroke !== "none") {
stroke = ctx.stroke;
}
} }
return React.createElement( return React.createElement(
el.tagName, el.tagName,