refactor(nodes!): Remove dimensions option, replace with width and height

* Can be used to set width, height (similar to style prop but with easier access)
This commit is contained in:
Braks
2022-04-11 11:30:10 +02:00
parent 4f026e841a
commit 8f2d94ae55
2 changed files with 26 additions and 19 deletions
+18 -1
View File
@@ -10,6 +10,10 @@ export type NodeHandleBounds = {
target?: HandleElement[]
}
type WidthHeight = number | `${`parent` | string}(${`+` | `-`}${number})`
type WidthFunc = <Data = ElementData>(node: GraphNode<Data>) => number | string | void
type HeightFunc = <Data = ElementData>(node: GraphNode<Data>) => number | string | void
export interface Node<Data = ElementData> extends Element<Data> {
/** node position x, y */
position: XYPosition
@@ -35,7 +39,20 @@ export interface Node<Data = ElementData> extends Element<Data> {
expandParent?: boolean
/** define node as a child node by setting a parent node id */
parentNode?: string
dimensions?: Partial<Dimensions>
/**
* Fixed width of node, applied as style
* You can pass a number which will be used in pixel values (width: 300 -> width: 300px)
* or pass a string with units (width: `10rem` -> width: 10rem)
*/
width?: number | string | WidthFunc
/**
* Fixed height of node, applied as style
* You can pass a number which will be used in pixel values (height: 300 -> height: 300px)
* or pass a string with units (height: `10rem` -> height: 10rem)
*/
height?: number | string | HeightFunc
}
export interface GraphNode<Data = ElementData> extends Node<Data> {