diff --git a/apps/canvas/widget/canvas/core.jsx b/apps/canvas/widget/canvas/core.jsx index 8ad9b860..c1402072 100644 --- a/apps/canvas/widget/canvas/core.jsx +++ b/apps/canvas/widget/canvas/core.jsx @@ -2,9 +2,28 @@ const { initialShapes, hideUi } = props; const [hide, setHide] = useState(false); +const [trigger, setTrigger] = useState(false); +const [canvasData, setCanvasData] = useState(null); + +const getDataFromChild = () => { + setTrigger(true); // Triggers the effect in the child +}; + +const handleGetData = (data) => { + setCanvasData(data); + setTrigger(false); // Reset the trigger +}; + return ( <> - - + + {canvasData &&

Data from child: {canvasData}

} + ); diff --git a/apps/canvas/widget/canvas/view.jsx b/apps/canvas/widget/canvas/view.jsx index be0ad806..6ae3ef7f 100644 --- a/apps/canvas/widget/canvas/view.jsx +++ b/apps/canvas/widget/canvas/view.jsx @@ -1,37 +1,42 @@ const { value } = props; -const indices = Social.index( - "post", - { - // thing - type: "thing", - path: "efiz.near/thing/draw", // this is the page?? - }, - { - order: "desc", - limit: 100, // this needs to adjust based on slider - // accountId: props.accounts, // undefined - } -); +const indices = Social.index("post", "main", { + order: "desc", + limit: 100, // this needs to adjust based on slider + // accountId: props.accounts, // undefined +}); if (!indices) { return

Loading...

; } -const drawings = indices - .map((it) => { - const path = `${it.accountId}/post/main`; - const blockHeight = it.blockHeight; +const offsetX = 100; // Horizontal offset for each text shape +const offsetY = 100; // Vertical offset for each text shape +let x = 0; // Initial X position +let y = 0; // Initial Y position + +const drawings = indices.map((it, index) => { + const path = `${it.accountId}/post/main`; + const blockHeight = it.blockHeight; + + x += offsetX; + y += offsetY; - const val = JSON.parse(Social.get(path, blockHeight) || "null"); - return val.content.shapes ? val.content.shapes : []; - }) - .flat(); + const val = JSON.parse(Social.get(path, blockHeight) || "null"); + return { + id: `shape:${path}${blockHeight}`, + type: "text", + x, + y, + props: { text: val.text, align: "start", size: "s" }, + }; +}); if (drawings.length === 0) { return

No drawings yet!

; } +// return

{JSON.stringify(drawings)}

return (
- - - Build DAO + + + Canvas