Skip to content

Commit

Permalink
feat(Flow): allow overriding default edge options (#3732)
Browse files Browse the repository at this point in the history
  • Loading branch information
plagoa committed Oct 13, 2023
1 parent a800d0a commit 3d7aa5f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 7 deletions.
18 changes: 11 additions & 7 deletions packages/lab/src/components/Flow/DroppableFlow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ export const HvDroppableFlow = ({
onConnect: onConnectProp,
onNodesChange: onNodesChangeProp,
onEdgesChange: onEdgesChangeProp,
defaultEdgeOptions: defaultEdgeOptionsProp,
...others
}: HvDroppableFlowProps) => {
const { classes, cx } = useClasses(classesProp);
Expand Down Expand Up @@ -235,6 +236,15 @@ export const HvDroppableFlow = ({

const validEdges = validateEdges(edges, nodes, nodeTypes);

const defaultEdgeOptions = {
markerEnd: {
type: MarkerType.ArrowClosed,
height: 20,
width: 20,
},
...defaultEdgeOptionsProp,
};

return (
<div
id={elementId}
Expand All @@ -249,13 +259,7 @@ export const HvDroppableFlow = ({
onEdgesChange={handleEdgesChange}
onConnect={handleConnect}
isValidConnection={isValidConnection}
defaultEdgeOptions={{
markerEnd: {
type: MarkerType.ArrowClosed,
height: 20,
width: 20,
},
}}
defaultEdgeOptions={defaultEdgeOptions}
{...others}
>
{children}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import {
LineChart as LineChartIcon,
Heart,
Transformation,
Delete,
Duplicate,
} from "@hitachivantara/uikit-react-icons";
import { theme } from "@hitachivantara/uikit-styles";
import { useState } from "react";
Expand All @@ -16,6 +18,12 @@ import { JsonInput } from "./JsonInput";
import { LineChart } from "./LineChart";
import { BarChart } from "./BarChart";
import { Filter } from "./Filter";
import { HvFlowDefaultActions } from "../../types";

const defaultActions: HvFlowDefaultActions[] = [
{ id: "delete", label: "Delete", icon: <Delete /> },
{ id: "duplicate", label: "Duplicate", icon: <Duplicate /> },
];

export const Visualizations = () => {
const [open, setOpen] = useState(false);
Expand Down Expand Up @@ -180,11 +188,13 @@ export const Visualizations = () => {
edges={edges}
nodeTypes={nodeTypes}
nodeGroups={nodeGroups}
defaultActions={defaultActions}
defaultViewport={{
zoom: 0.7,
x: 0,
y: 0,
}}
defaultEdgeOptions={{ animated: true }}
sidebar={
<HvFlowSidebar
title="Add Node"
Expand Down

0 comments on commit 3d7aa5f

Please sign in to comment.