Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
import { type Node, type NodeProps } from "@xyflow/react";
import { useEffect } from "react";

import { InfoBox } from "@/components/shared/InfoBox";
import { Paragraph } from "@/components/ui/typography";
import { cn } from "@/lib/utils";
import { useContextPanel } from "@/providers/ContextPanelProvider";

import { StickyNoteEditor } from "./StickyNoteEditor";
import { FlexNodeEditor } from "./FlexNodeEditor";
import type { FlexNodeData } from "./types";

type FlexNodeProps = NodeProps<Node<FlexNodeData>>;

const FlexNode = ({ data, id, selected }: FlexNodeProps) => {
const { properties, readOnly, type } = data;
const { properties, readOnly } = data;
const { color, zIndex } = properties;

const {
Expand All @@ -23,19 +22,7 @@ const FlexNode = ({ data, id, selected }: FlexNodeProps) => {

useEffect(() => {
if (selected) {
switch (type) {
case "sticky-note":
setContent(
<StickyNoteEditor stickyNote={data} readOnly={readOnly} />,
);
break;
default:
setContent(
<InfoBox title="Context Panel Error" variant="error">
Unknown node type: <span className="font-mono">{type}</span>
</InfoBox>,
);
}
setContent(<FlexNodeEditor flexNode={data} readOnly={readOnly} />);
setContextPanelOpen(true);
}

Expand All @@ -44,7 +31,7 @@ const FlexNode = ({ data, id, selected }: FlexNodeProps) => {
clearContent();
}
};
}, [selected]);
}, [data, readOnly, selected]);

return (
<div
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@ import { Paragraph, Text } from "@/components/ui/typography";

import type { FlexNodeData } from "./types";

interface StickyNoteEditorProps {
stickyNote: FlexNodeData;
interface FlexNodeEditorProps {
flexNode: FlexNodeData;
readOnly?: boolean;
}

export const StickyNoteEditor = ({
stickyNote,
export const FlexNodeEditor = ({
flexNode,
readOnly = false,
}: StickyNoteEditorProps) => {
const { properties, size, position } = stickyNote;
}: FlexNodeEditorProps) => {
const { properties, size, position } = flexNode;

return (
<BlockStack gap="4" className="h-full px-2">
Expand Down