Skip to content

Commit

Permalink
feat(Canvas): Use CustomNode for collapsed groups
Browse files Browse the repository at this point in the history
* hover over toolbar working
* centered toolbar for containers
* removed phantom-rect
* add disable icon within boundaries
* add exclamation mark before the label
* red-color the exclamation mark and the label
* decrease node width
* add label background to hide the edge
  • Loading branch information
lordrip committed Oct 25, 2024
1 parent 06793be commit 883a8d6
Show file tree
Hide file tree
Showing 18 changed files with 359 additions and 592 deletions.
2 changes: 1 addition & 1 deletion packages/ui/src/components/Visualization/Canvas/Canvas.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export const Canvas: FunctionComponent<PropsWithChildren<CanvasProps>> = ({ enti
},
};

controller.fromModel(model, true);
controller.fromModel(model, false);
setInitialized(true);
}, [controller, entities, visibleFlows]);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import {
BanIcon,
CheckIcon,
CodeBranchIcon,
CompressArrowsAltIcon,
ExpandArrowsAltIcon,
PlusIcon,
PowerOffIcon,
SyncAltIcon,
Expand All @@ -20,11 +22,20 @@ import { useReplaceStep } from '../../Custom/hooks/replace-step.hook';
import './StepToolbar.scss';

interface IStepToolbar extends IDataTestID {
className?: string;
vizNode: IVisualizationNode;
className?: string;
isCollapsed?: boolean;
/** Toggle node collapse / expand */
onCollapseToggle?: () => void;
}

export const StepToolbar: FunctionComponent<IStepToolbar> = ({ vizNode, className, 'data-testid': dataTestId }) => {
export const StepToolbar: FunctionComponent<IStepToolbar> = ({
vizNode,
className,
isCollapsed = false,
onCollapseToggle,
'data-testid': dataTestId,
}) => {
const { canHaveChildren, canHaveSpecialChildren, canBeDisabled, canReplaceStep, canRemoveStep, canRemoveFlow } =
vizNode.getNodeInteraction();
const { onInsertStep } = useInsertStep(vizNode);
Expand Down Expand Up @@ -78,15 +89,7 @@ export const StepToolbar: FunctionComponent<IStepToolbar> = ({ vizNode, classNam
event.stopPropagation();
}}
>
{isDisabled ? (
<>
<CheckIcon />
</>
) : (
<>
<BanIcon />
</>
)}
{isDisabled ? <CheckIcon /> : <BanIcon />}
</Button>
)}

Expand Down Expand Up @@ -120,6 +123,21 @@ export const StepToolbar: FunctionComponent<IStepToolbar> = ({ vizNode, classNam
</Button>
)}

{onCollapseToggle && (
<Button
className="step-toolbar__button"
data-testid="step-toolbar-button-collapse"
variant="secondary"
title={isCollapsed ? 'Expand step' : 'Collapse step'}
onClick={(event) => {
onCollapseToggle();
event.stopPropagation();
}}
>
{isCollapsed ? <ExpandArrowsAltIcon /> : <CompressArrowsAltIcon />}
</Button>
)}

{canRemoveStep && (
<Button
className="step-toolbar__button"
Expand Down
13 changes: 10 additions & 3 deletions packages/ui/src/components/Visualization/Canvas/canvas.defaults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,16 @@ import { LayoutType } from './canvas.models';

export class CanvasDefaults {
static readonly DEFAULT_LAYOUT = LayoutType.DagreVertical;
static readonly DEFAULT_SIDEBAR_WIDTH = 500;
static readonly DEFAULT_LABEL_WIDTH = 150;
static readonly DEFAULT_LABEL_HEIGHT = 32;

static readonly DEFAULT_NODE_SHAPE = NodeShape.rect;
static readonly DEFAULT_NODE_WIDTH = 150;
static readonly DEFAULT_NODE_WIDTH = 90;
static readonly DEFAULT_NODE_HEIGHT = 85;
static readonly DEFAULT_GROUP_PADDING = 65;
static readonly DEFAULT_SIDEBAR_WIDTH = 500;

static readonly DEFAULT_GROUP_PADDING = 40;

static readonly STEP_TOOLBAR_WIDTH = 350;
static readonly STEP_TOOLBAR_HEIGHT = 60;
}

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit 883a8d6

Please sign in to comment.