generated from arvinxx/npm-template
-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
jiangchu
committed
Nov 9, 2023
1 parent
670fbc5
commit 7f647b8
Showing
23 changed files
with
528 additions
and
96 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import { FlowView } from '@ant-design/pro-flow'; | ||
import { EdgeType } from '@ant-design/pro-flow/es/index'; | ||
import styled from 'styled-components'; | ||
|
||
const nodes = [ | ||
{ | ||
id: 'a1', | ||
data: { | ||
title: 'XXX_API_b3', | ||
logo: 'https://mdn.alipayobjects.com/huamei_ntgeqc/afts/img/A*kgyiRKi04eUAAAAAAAAAAAAADvuvAQ/original', | ||
describe: 'XXX_XXX_XXX_API', | ||
}, | ||
}, | ||
{ | ||
id: 'a2', | ||
data: { | ||
title: 'XXX_API_b4', | ||
logo: 'https://mdn.alipayobjects.com/huamei_ntgeqc/afts/img/A*kgyiRKi04eUAAAAAAAAAAAAADvuvAQ/original', | ||
describe: 'XXX_XXX_XXX_API', | ||
}, | ||
}, | ||
{ | ||
id: 'a3', | ||
data: { | ||
title: 'XXX_API_b4', | ||
logo: 'https://mdn.alipayobjects.com/huamei_ntgeqc/afts/img/A*kgyiRKi04eUAAAAAAAAAAAAADvuvAQ/original', | ||
describe: 'XXX_XXX_XXX_API', | ||
}, | ||
}, | ||
]; | ||
const edges = [ | ||
{ | ||
id: 'a1-a2', | ||
source: 'a1', | ||
target: 'a2', | ||
}, | ||
{ | ||
id: 'a1-a3', | ||
source: 'a1', | ||
target: 'a3', | ||
type: EdgeType.radius, | ||
}, | ||
]; | ||
|
||
function App() { | ||
return ( | ||
<Container> | ||
<FlowView nodes={nodes} edges={edges} /> | ||
</Container> | ||
); | ||
} | ||
|
||
export default App; | ||
|
||
const Container = styled.div` | ||
width: 800px; | ||
height: 500px; | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { FlowView } from '@ant-design/pro-flow'; | ||
import styled from 'styled-components'; | ||
|
||
function App() { | ||
return ( | ||
<Container> | ||
<FlowView nodes={[]} edges={[]} /> | ||
</Container> | ||
); | ||
} | ||
|
||
export default App; | ||
|
||
const Container = styled.div` | ||
width: 800px; | ||
height: 500px; | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import { FlowView } from '@ant-design/pro-flow'; | ||
import { EdgeType } from '@ant-design/pro-flow/es/index'; | ||
import styled from 'styled-components'; | ||
|
||
const nodes = [ | ||
{ | ||
id: 'a1', | ||
data: { | ||
title: 'XXX_API_b3', | ||
logo: 'https://mdn.alipayobjects.com/huamei_ntgeqc/afts/img/A*kgyiRKi04eUAAAAAAAAAAAAADvuvAQ/original', | ||
describe: 'XXX_XXX_XXX_API', | ||
}, | ||
position: { | ||
x: 0, | ||
y: 0, | ||
}, | ||
}, | ||
{ | ||
id: 'a2', | ||
data: { | ||
title: 'XXX_API_b4', | ||
logo: 'https://mdn.alipayobjects.com/huamei_ntgeqc/afts/img/A*kgyiRKi04eUAAAAAAAAAAAAADvuvAQ/original', | ||
describe: 'XXX_XXX_XXX_API', | ||
}, | ||
position: { | ||
x: 600, | ||
y: 200, | ||
}, | ||
}, | ||
{ | ||
id: 'a3', | ||
data: { | ||
title: 'XXX_API_b4', | ||
logo: 'https://mdn.alipayobjects.com/huamei_ntgeqc/afts/img/A*kgyiRKi04eUAAAAAAAAAAAAADvuvAQ/original', | ||
describe: 'XXX_XXX_XXX_API', | ||
}, | ||
position: { | ||
x: 600, | ||
y: 400, | ||
}, | ||
}, | ||
]; | ||
const edges = [ | ||
{ | ||
id: 'a1-a2', | ||
source: 'a1', | ||
target: 'a2', | ||
}, | ||
{ | ||
id: 'a1-a3', | ||
source: 'a1', | ||
target: 'a3', | ||
type: EdgeType.radius, | ||
}, | ||
]; | ||
|
||
function App() { | ||
return ( | ||
<Container> | ||
<FlowView nodes={nodes} edges={edges} miniMap={false} /> | ||
</Container> | ||
); | ||
} | ||
|
||
export default App; | ||
|
||
const Container = styled.div` | ||
width: 800px; | ||
height: 500px; | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
import { FlowView } from '@ant-design/pro-flow'; | ||
import { EdgeType, FlowViewEdge, FlowViewNode, SelectType } from '@ant-design/pro-flow/es/index'; | ||
import { useState } from 'react'; | ||
import styled from 'styled-components'; | ||
|
||
const initNodes = [ | ||
{ | ||
id: 'a1', | ||
data: { | ||
title: 'XXX_API_b3', | ||
logo: 'https://mdn.alipayobjects.com/huamei_ntgeqc/afts/img/A*kgyiRKi04eUAAAAAAAAAAAAADvuvAQ/original', | ||
describe: 'XXX_XXX_XXX_API', | ||
}, | ||
}, | ||
{ | ||
id: 'a2', | ||
data: { | ||
title: 'XXX_API_b4', | ||
logo: 'https://mdn.alipayobjects.com/huamei_ntgeqc/afts/img/A*kgyiRKi04eUAAAAAAAAAAAAADvuvAQ/original', | ||
describe: 'XXX_XXX_XXX_API', | ||
}, | ||
}, | ||
{ | ||
id: 'a3', | ||
data: { | ||
title: 'XXX_API_b4', | ||
logo: 'https://mdn.alipayobjects.com/huamei_ntgeqc/afts/img/A*kgyiRKi04eUAAAAAAAAAAAAADvuvAQ/original', | ||
describe: 'XXX_XXX_XXX_API', | ||
}, | ||
}, | ||
]; | ||
const initEdges = [ | ||
{ | ||
id: 'a1-a2', | ||
source: 'a1', | ||
target: 'a2', | ||
}, | ||
{ | ||
id: 'a1-a3', | ||
source: 'a1', | ||
target: 'a3', | ||
type: EdgeType.radius, | ||
}, | ||
]; | ||
|
||
function App() { | ||
const [nodes, setNodes] = useState<FlowViewNode>(initNodes); | ||
const [edges, setEdges] = useState<FlowViewEdge>(initEdges); | ||
|
||
const handlePaneClick = (e: any) => { | ||
setNodes( | ||
nodes.map((_node) => { | ||
_node.select = SelectType.DEFAULT; | ||
return _node; | ||
}), | ||
); | ||
setEdges( | ||
edges.map((edge) => { | ||
edge.select = SelectType.DEFAULT; | ||
return edge; | ||
}), | ||
); | ||
}; | ||
|
||
const handleNodeClick = (e: any, node) => { | ||
console.log(node); | ||
setNodes( | ||
nodes.map((_node) => { | ||
if (_node.id === node.id) { | ||
_node.select = SelectType.SELECT; | ||
} else { | ||
_node.select = SelectType.SUB_SELECT; | ||
} | ||
return _node; | ||
}), | ||
); | ||
setEdges( | ||
edges.map((edge) => { | ||
edge.select = SelectType.SUB_SELECT; | ||
return edge; | ||
}), | ||
); | ||
}; | ||
|
||
return ( | ||
<Container> | ||
<FlowView | ||
onPaneClick={handlePaneClick} | ||
onNodeClick={handleNodeClick} | ||
nodes={nodes} | ||
edges={edges} | ||
/> | ||
</Container> | ||
); | ||
} | ||
|
||
export default App; | ||
|
||
const Container = styled.div` | ||
width: 800px; | ||
height: 500px; | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,3 +6,5 @@ group: | |
title: 为什么选择 ReactFlow ? | ||
description: | ||
--- | ||
|
||
<code src='./demos/positionFlow.tsx' ></code> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { FlowEditor, FlowEditorProvider, useFlowEditor } from '@ant-design/pro-flow'; | ||
import { createStyles } from 'antd-style'; | ||
import { useEffect } from 'react'; | ||
|
||
const useStyles = createStyles(({ css }) => ({ | ||
container: css` | ||
width: 100%; | ||
height: 600px; | ||
.ant-progress-text { | ||
text-align: center !important; | ||
} | ||
`, | ||
})); | ||
|
||
const ProFlowDemo = () => { | ||
const editor = useFlowEditor(); | ||
const { styles } = useStyles(); | ||
console.log(editor); | ||
useEffect(() => { | ||
editor.addNode({ | ||
id: 'a1', | ||
position: { x: 0, y: 100 }, | ||
data: { | ||
children: <div>default node, 123123</div>, | ||
}, | ||
}); | ||
}, [editor]); | ||
|
||
return ( | ||
<div className={styles.container}> | ||
<FlowEditor /> | ||
</div> | ||
); | ||
}; | ||
|
||
const FlowDemo = () => { | ||
return ( | ||
<FlowEditorProvider> | ||
<ProFlowDemo /> | ||
</FlowEditorProvider> | ||
); | ||
}; | ||
|
||
export default FlowDemo; |
Oops, something went wrong.