From 3f366c112afda37815b1a29051dba1f387d78ab9 Mon Sep 17 00:00:00 2001 From: Atul Varma Date: Sun, 28 Mar 2021 06:39:06 -0400 Subject: [PATCH] Rename SvgTransforms to SvgTransform, allow it to take a single transform. --- lib/creature-symbol.tsx | 8 ++++---- lib/pages/creature-page.tsx | 6 +++--- lib/pages/debug-page.tsx | 6 +++--- lib/pages/mandala-page.tsx | 16 ++++++++-------- lib/svg-transform.tsx | 12 ++++++++---- 5 files changed, 26 insertions(+), 22 deletions(-) diff --git a/lib/creature-symbol.tsx b/lib/creature-symbol.tsx index b3c383b..cd4fc3f 100644 --- a/lib/creature-symbol.tsx +++ b/lib/creature-symbol.tsx @@ -15,7 +15,7 @@ import { svgRotate, svgScale, svgTransformOrigin, - SvgTransforms, + SvgTransform, svgTranslate, } from "./svg-transform"; @@ -118,8 +118,8 @@ type AttachmentTransformProps = { }; const AttachmentTransform: React.FC = (props) => ( - = (props) => ( ]} > {props.children} - + ); const AttachedCreatureSymbol: React.FC = ({ diff --git a/lib/pages/creature-page.tsx b/lib/pages/creature-page.tsx index e60d385..5f046b6 100644 --- a/lib/pages/creature-page.tsx +++ b/lib/pages/creature-page.tsx @@ -19,7 +19,7 @@ import { NestedCreatureSymbol, } from "../creature-symbol"; import { HoverDebugHelper } from "../hover-debug-helper"; -import { svgScale, SvgTransforms } from "../svg-transform"; +import { svgScale, SvgTransform } from "../svg-transform"; import { ColorWidget } from "../color-widget"; import { NumericSlider } from "../numeric-slider"; import { DEFAULT_BG_COLOR } from "../colors"; @@ -237,9 +237,9 @@ export const CreaturePage: React.FC<{}> = () => { - + - + diff --git a/lib/pages/debug-page.tsx b/lib/pages/debug-page.tsx index 974844b..4453088 100644 --- a/lib/pages/debug-page.tsx +++ b/lib/pages/debug-page.tsx @@ -4,7 +4,7 @@ import { CreatureContext, CreatureContextType } from "../creature-symbol"; import { createCreatureSymbolFactory } from "../creature-symbol-factory"; import { HoverDebugHelper } from "../hover-debug-helper"; import { createSvgSymbolContext } from "../svg-symbol"; -import { svgScale, SvgTransforms } from "../svg-transform"; +import { svgScale, SvgTransform } from "../svg-transform"; import { SvgVocabulary } from "../svg-vocabulary"; import { SymbolContextWidget } from "../symbol-context-widget"; @@ -66,9 +66,9 @@ export const DebugPage: React.FC<{}> = () => { - + {EYE_CREATURE} - + diff --git a/lib/pages/mandala-page.tsx b/lib/pages/mandala-page.tsx index 6c76dbc..b5c56b8 100644 --- a/lib/pages/mandala-page.tsx +++ b/lib/pages/mandala-page.tsx @@ -17,7 +17,7 @@ import { VocabularyWidget } from "../vocabulary-widget"; import { svgRotate, svgScale, - SvgTransforms, + SvgTransform, svgTranslate, } from "../svg-transform"; import { SvgVocabulary } from "../svg-vocabulary"; @@ -37,20 +37,20 @@ const MandalaCircle: React.FC< const center = getBoundingBoxCenter(props.data.bbox); const degreesPerItem = 360 / props.numSymbols; const symbol = ( - - + ); const symbols = range(props.numSymbols).map((i) => ( - )); @@ -122,14 +122,14 @@ export const MandalaPage: React.FC<{}> = () => { - + - + diff --git a/lib/svg-transform.tsx b/lib/svg-transform.tsx index 075b367..1d9956f 100644 --- a/lib/svg-transform.tsx +++ b/lib/svg-transform.tsx @@ -83,9 +83,13 @@ export function svgRotate(degrees: number): SvgTransform { * Like the SVG `transform` attribute, the transforms are applied in * the *reverse* order that they are specified. */ -export const SvgTransforms: React.FC<{ - transforms: SvgTransform[]; +export const SvgTransform: React.FC<{ + transform: SvgTransform[] | SvgTransform; children: any; -}> = ({ transforms, children }) => { - return {children}; +}> = ({ transform, children }) => { + if (!Array.isArray(transform)) { + transform = [transform]; + } + + return {children}; };