Skip to content

Commit

Permalink
✨ feat: 新增edge的sub select类型
Browse files Browse the repository at this point in the history
  • Loading branch information
jiangchu committed Oct 23, 2023
1 parent a8bb725 commit ad13b27
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 6 deletions.
8 changes: 6 additions & 2 deletions src/ProFlow/constants.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,12 @@ export const NODE_SUB_DANGER = 'nodeSubDanger';
export const NODE_WARNING = 'nodeWarning';
export const NODE_SUB_WARNING = 'nodeSubWarning';

export const INIT_NODE = 'initialNode';
export const NODE_WRAP = 'nodeWrap';
export const EDGE_SELECT = 'edgeSelected';
export const EDGE_SUB_SELECT = 'edgeSubSelected';
export const EDGE_DANGER = 'edgeDanger';
export const EDGE_SUB_DANGER = 'edgeSubDanger';
export const EDGE_WARNING = 'edgeWarning';
export const EDGE_SUB_WARNING = 'edgeSubWarning';

export const INIT_NODE = 'initialNode';
export const NODE_WRAP = 'nodeWrap';
6 changes: 3 additions & 3 deletions src/ProFlow/demos/ProFlowDemo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -205,21 +205,21 @@ const edges = [
{
id: 'a1-b2',
source: 'a1',
select: NodeSelect.WARNING,
select: NodeSelect.SUB_WARNING,
target: 'b2',
type: EdgeType.default,
},
{
id: 'a1-b3',
source: 'a1',
select: NodeSelect.WARNING,
select: NodeSelect.SUB_DANGER,
target: 'b3',
type: EdgeType.default,
},
{
id: 'a1-b4',
source: 'a1',
select: NodeSelect.WARNING,
select: NodeSelect.SUB_SELECT,
target: 'b4',
type: EdgeType.default,
},
Expand Down
9 changes: 9 additions & 0 deletions src/ProFlow/helper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ import { Edge, Node, Position } from 'reactflow';
import {
EDGE_DANGER,
EDGE_SELECT,
EDGE_SUB_DANGER,
EDGE_SUB_SELECT,
EDGE_SUB_WARNING,
EDGE_WARNING,
INIT_NODE,
InitialNode,
Expand Down Expand Up @@ -97,10 +100,16 @@ function getEdgeClsFromNodeSelect(select: NodeSelect) {
switch (select) {
case NodeSelect.SELECT:
return EDGE_SELECT;
case NodeSelect.SUB_SELECT:
return EDGE_SUB_SELECT;
case NodeSelect.DANGER:
return EDGE_DANGER;
case NodeSelect.SUB_DANGER:
return EDGE_SUB_DANGER;
case NodeSelect.WARNING:
return EDGE_WARNING;
case NodeSelect.SUB_WARNING:
return EDGE_SUB_WARNING;
default:
return 'edgeDefault';
}
Expand Down
28 changes: 27 additions & 1 deletion src/ProFlow/styles.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
import { createStyles } from 'antd-style';
import { EDGE_DANGER, EDGE_SELECT, EDGE_WARNING, INIT_NODE } from './constants';
import {
EDGE_DANGER,
EDGE_SELECT,
EDGE_SUB_DANGER,
EDGE_SUB_SELECT,
EDGE_SUB_WARNING,
EDGE_WARNING,
INIT_NODE,
} from './constants';

export const useStyles = createStyles(({ css }) => ({
container: css`
Expand Down Expand Up @@ -28,18 +36,36 @@ export const useStyles = createStyles(({ css }) => ({
z-index: 100;
}
.${EDGE_SUB_SELECT} path {
stroke: #1677ff;
stroke-width: 1;
z-index: 100;
}
.${EDGE_DANGER} path {
stroke: #f7636e;
stroke-width: 2;
z-index: 100;
}
.${EDGE_SUB_DANGER} path {
stroke: #f7636e;
stroke-width: 1;
z-index: 100;
}
.${EDGE_WARNING} path {
stroke: #ef9d3b;
stroke-width: 2;
z-index: 100;
}
.${EDGE_SUB_WARNING} path {
stroke: #ef9d3b;
stroke-width: 1;
z-index: 100;
}
.selectable:focus {
box-shadow: none !important;
}
Expand Down

0 comments on commit ad13b27

Please sign in to comment.