-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: make sidebar width with scalible and handle drag and drop
- Loading branch information
Showing
11 changed files
with
184 additions
and
117 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import React from "react" | ||
|
||
interface DividerProps { | ||
style?: React.CSSProperties | ||
} | ||
|
||
export const Divider: React.FC<DividerProps> = ({ style }) => { | ||
return ( | ||
<div | ||
style={{ | ||
height: "2px", | ||
width: "100%", | ||
backgroundColor: "#000", | ||
...style, | ||
}} | ||
/> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
export * from "./Text" | ||
export * from "./ThemedElements" | ||
export * from "./Sidebar" | ||
export * from "./Divider" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
/* eslint-disable @typescript-eslint/no-explicit-any */ | ||
import { ClassSVG, PackageSVG, ColorDescriptionSVG } from "@/svgs" | ||
import { generateUUID } from "@/utils" | ||
import { ClassType } from "@/types" | ||
import { DiagramNodeTypeKeys } from "@/nodes" | ||
|
||
export const transformScale = 0.8 | ||
const droppedElementWidth = 160 | ||
const droppedElementHeight = 110 | ||
|
||
export const dropElementConfig: { | ||
type: DiagramNodeTypeKeys | ||
name: string | ||
width: number | ||
height: number | ||
defaultData: Record<string, unknown> | ||
svg: React.FC<any> | ||
}[] = [ | ||
{ | ||
type: "package", | ||
name: "Package", | ||
width: droppedElementWidth, | ||
height: droppedElementHeight, | ||
defaultData: { name: "Package" }, | ||
svg: (props) => <PackageSVG {...props} />, | ||
}, | ||
{ | ||
type: "class", | ||
name: "Class", | ||
width: droppedElementWidth, | ||
height: droppedElementHeight, | ||
defaultData: { | ||
name: "Class", | ||
methods: [{ id: generateUUID(), name: "+ method()" }], | ||
attributes: [{ id: generateUUID(), name: "+ attribute: Type" }], | ||
}, | ||
svg: (props) => <ClassSVG {...props} />, | ||
}, | ||
{ | ||
type: "class", | ||
name: "Abstract", | ||
width: droppedElementWidth, | ||
height: droppedElementHeight, | ||
defaultData: { | ||
name: "Abstract", | ||
stereotype: ClassType.Abstract, | ||
methods: [{ id: generateUUID(), name: "+ method()" }], | ||
attributes: [{ id: generateUUID(), name: "+ attribute: Type" }], | ||
}, | ||
svg: (props) => <ClassSVG {...props} />, | ||
}, | ||
{ | ||
type: "class", | ||
name: "Enumeration", | ||
width: droppedElementWidth, | ||
height: droppedElementHeight, | ||
defaultData: { | ||
name: "Enumeration", | ||
stereotype: ClassType.Enumeration, | ||
methods: [{ id: generateUUID(), name: "+ method()" }], | ||
attributes: [{ id: generateUUID(), name: "+ attribute: Type" }], | ||
}, | ||
svg: (props) => <ClassSVG {...props} />, | ||
}, | ||
{ | ||
type: "class", | ||
name: "Interface", | ||
width: droppedElementWidth, | ||
height: droppedElementHeight, | ||
defaultData: { | ||
name: "Interface", | ||
stereotype: ClassType.Interface, | ||
methods: [{ id: generateUUID(), name: "+ method()" }], | ||
attributes: [{ id: generateUUID(), name: "+ attribute: Type" }], | ||
}, | ||
svg: (props) => <ClassSVG {...props} />, | ||
}, | ||
{ | ||
type: "colorDescription", | ||
name: "Color Description", | ||
width: droppedElementWidth, | ||
height: 48, | ||
defaultData: { description: "Color Description" }, | ||
svg: (props) => <ColorDescriptionSVG {...props} />, | ||
}, | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,10 @@ | ||
import { NodeTypes } from "@xyflow/react" | ||
import { NodeTypes } from "@xyflow/react" // Explicitly differentiate imported type | ||
import { Class, ColorDescription, Package } from "./classDiagram" | ||
|
||
export const nodeTypes: NodeTypes = { | ||
export const diagramNodeTypes = { | ||
package: Package, | ||
class: Class, | ||
colorDescription: ColorDescription, | ||
} | ||
} satisfies NodeTypes | ||
|
||
export type DiagramNodeTypeKeys = keyof typeof diagramNodeTypes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.