diff --git a/src/components/workspace/elements/index.tsx b/src/components/workspace/elements/index.tsx index 4dca21c..e214590 100644 --- a/src/components/workspace/elements/index.tsx +++ b/src/components/workspace/elements/index.tsx @@ -1,11 +1,11 @@ -import { memo, useEffect, useRef } from "react"; +import { memo, useEffect, useMemo, useRef } from "react"; import * as d3 from "d3"; import { isEqual } from "lodash"; import { twMerge } from "tailwind-merge"; import { dataAttributes } from "@/constants"; import { store } from "@/store"; import { clearAndSelectElements, deselectElement, selectElement } from "@/store/reducers/editor"; -import { STKMode } from "@/types"; +import { ISTKProps, STKMode } from "@/types"; import { Tool } from "../../toolbar/data"; import { ElementType, @@ -24,6 +24,8 @@ export const Element = ({ type = ElementType.Seat, id, x = 250, y = 250, isSelec const Element = elements[type] as any; + const styles = (consumer as ISTKProps).styles?.elements; + useEffect(() => { if (!ref.current || consumer.mode !== STKMode.Designer) return; const node = d3.select(ref.current); @@ -58,6 +60,17 @@ export const Element = ({ type = ElementType.Seat, id, x = 250, y = 250, isSelec } }; + const stylemap = useMemo( + () => ({ + [ElementType.Text]: styles?.text, + [ElementType.Shape]: styles?.shape, + [ElementType.Polyline]: styles?.shape, + [ElementType.Image]: styles?.image, + [ElementType.Seat]: styles?.seat + }), + [styles] + ); + return ( = (props) => { ); return ( -
+
{seats.map((e) => ( diff --git a/src/types/styles.ts b/src/types/styles.ts index af9fc97..c4fea01 100644 --- a/src/types/styles.ts +++ b/src/types/styles.ts @@ -29,11 +29,19 @@ export interface IStyles { meta?: IStyle; }; elements?: { - all?: { + booth?: { selected?: IStyle; unselected?: IStyle; }; - seats?: { + seat?: { + selected?: IStyle; + unselected?: IStyle; + }; + shape?: { + selected?: IStyle; + unselected?: IStyle; + }; + image?: { selected?: IStyle; unselected?: IStyle; };