FourSides
import { FourSides } from "cx-diagrams"The FourSides component is used to lay out diagram components into four directions. This is commonly used in combination with Rotate to assemble the parts into a single structure.
import { FourSides } from "cx-diagrams"The FourSides component is used to lay out diagram components into four directions. This is commonly used in combination with Rotate to assemble the parts into a single structure.
interface Model {
order: number;
}
const m = createModel<Model>();
const setups: Slot[][] = [
['center', 'right', 'down', 'left', 'up'],
['center', 'down', 'left', 'up', 'right'],
['center', 'left', 'up', 'right', 'down'],
['center', 'up', 'right', 'down', 'left'],
];
<Diagram center showGrid>
<FourSides
slots={computable(m.order, (order) => setups[order])}
>
<Cell width={2} height={2}>
<Shape text="center" fill="lightgreen" />
</Cell>
<Flow gap={0.5} p={0.5} align="center">
<Rectangle stroke="red" />
<Cell>
<Shape fill="lightgray" text="1" />
</Cell>
<Cell>
<Shape fill="lightgray" text="2" />
</Cell>
<Cell w={2} h={2}>
<Shape fill="lightgray" text="3" />
</Cell>
</Flow>
<Flow direction="down" gap={0.5} p={0.5} align="center">
<Rectangle stroke="red" />
<Cell>
<Shape fill="lightgray" text="1" />
</Cell>
<Cell>
<Shape fill="lightgray" text="2" />
</Cell>
<Cell w={2} h={2}>
<Shape fill="lightgray" text="3" />
</Cell>
</Flow>
<Flow direction="left" gap={0.5} p={0.5} align="center">
<Rectangle stroke="red" />
<Cell>
<Shape fill="lightgray" text="1" />
</Cell>
<Cell>
<Shape fill="lightgray" text="2" />
</Cell>
<Cell w={2} h={2}>
<Shape fill="lightgray" text="3" />
</Cell>
</Flow>
<Flow direction="up" gap={0.5} p={0.5} align="center">
<Rectangle stroke="red" />
<Cell>
<Shape fill="lightgray" text="1" />
</Cell>
<Cell>
<Shape fill="lightgray" text="2" />
</Cell>
<Cell w={2} h={2}>
<Shape fill="lightgray" text="3" />
</Cell>
</Flow>
</FourSides>
</Diagram> | Property | Description | Type |
|---|---|---|
gap | Inner distance between the elements. | number |
slots | Order of slots. Default is | array |
grow | If set, the element will grow to fill available space in the flow direction. | boolean |
margin | Margin around the cell. | number |
mb | Bottom margin. | number |
me | End margin in the direction of the flow. | number |
meAuto | If set, the end margin will be automatically calculated to fill available space. | boolean |
ml | Left margin. | number |
mr | Right margin. | number |
ms | Start margin in the direction of the flow. | number |
msAuto | If set, the start margin will be automatically calculated to fill available space. | boolean |
mt | Top margin. | number |
mx | Horizontal margin. | number |
my | Vertical margin. | number |