From 85dd0b70f61383571d331f5a04963d4b970e5dfa Mon Sep 17 00:00:00 2001 From: MFA-X-AI Date: Tue, 9 Jul 2024 22:59:19 +0900 Subject: [PATCH 01/13] add custom node icons --- src/components/node/CustomNodeWidget.tsx | 42 +++++++++++++++++++++--- src/ui-components/icons.tsx | 8 ++++- style/icons/branch-component.svg | 1 + style/icons/component-library.svg | 7 +--- style/icons/start-finish-component.svg | 1 + style/icons/workflow-component.svg | 1 + 6 files changed, 49 insertions(+), 11 deletions(-) create mode 100644 style/icons/branch-component.svg create mode 100644 style/icons/start-finish-component.svg create mode 100644 style/icons/workflow-component.svg diff --git a/src/components/node/CustomNodeWidget.tsx b/src/components/node/CustomNodeWidget.tsx index 4b742212..e41c790d 100644 --- a/src/components/node/CustomNodeWidget.tsx +++ b/src/components/node/CustomNodeWidget.tsx @@ -10,13 +10,15 @@ import { Dialog } from '@jupyterlab/apputils'; import { formDialogWidget } from '../../dialog/formDialogwidget'; import { showFormDialog } from '../../dialog/FormDialog'; import { CommentDialog } from '../../dialog/CommentDialog'; -import ReactTooltip from "react-tooltip"; +import ReactTooltip from 'react-tooltip'; import { marked } from 'marked'; import Color from 'colorjs.io'; -import { commandIDs } from "../../commands/CommandIDs"; +import { commandIDs } from '../../commands/CommandIDs'; +import { componentLibIcon, branchComponentIcon, workflowComponentIcon, startFinishComponentIcon } from '../../ui-components/icons'; var S; (function (S) { + S.Node = styled.div<{ borderColor: string, background: string; selected: boolean; }>` background-color: ${(p) => { const color = new Color(p.background); @@ -43,7 +45,20 @@ var S; S.TitleName = styled.div` flex-grow: 1; - padding: 5px 5px; + padding: 5px 5px 5px 5px; + `; + + S.IconContainer = styled.div` + padding: 5px; + display: flex; + align-items: center; + justify-content: center; + width: 15px; + height: 15px; + svg { + width: 100%; + height: 100%; + } `; S.CommentContainer = styled.div<{ selected: boolean; }>` @@ -85,6 +100,7 @@ var S; margin-right: 0px; } `; + S.WorkflowNode = styled(S.Node)` outline: 2px solid rgba(255, 255, 255, 0.2); outline-offset: 8px; // Space between the main node and the outline @@ -102,6 +118,21 @@ export interface DefaultNodeProps { shell: ILabShell; } +const getNodeIcon = (type) => { + switch (type) { + case 'startFinish': + return ; + case 'workflow': + return ; + case 'branch': + return ; + case 'library_component': + return ; + default: + return null; + } +}; + const CommentNode = ({ node }) => { const [commentInput, setCommentInput] = React.useState(node['extras']['commentInput']); @@ -149,6 +180,7 @@ const ParameterNode = ({ node, engine, app }) => { onDoubleClick={handleEditParameter} > + {/* {getNodeIcon('parameter')} */} {node.getOptions().name} @@ -167,6 +199,7 @@ const StartFinishNode = ({ node, engine, handleDeletableNode }) => ( background={node.getOptions().color} > + {getNodeIcon('startFinish')} {node.getOptions().name}