Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 fix: update tech demo #34

Merged
merged 3 commits into from
Nov 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/useDocs/demos/autoLayoutDemo3.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { FlowView } from '@ant-design/pro-flow';
import styled from 'styled-components';
import { FlowView } from '../../../src/index';

const Container = styled.div`
width: 800px;
Expand Down
4 changes: 2 additions & 2 deletions docs/useDocs/demos/selectFlow.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import styled from 'styled-components';
import {
EdgeType,
FlowView,
FlowViewProvider,
SelectType,
useFlowViewer,
} from '../../../src/index';
} from '@ant-design/pro-flow';
import styled from 'styled-components';

const initNodes = [
{
Expand Down
336 changes: 336 additions & 0 deletions docs/useDocs/demos/techPipeline.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,336 @@
/**
* compact: true
*/
import {
Background,
FlowView,
FlowViewProvider,
Handle,
Position,
useFlowViewer,
} from '@ant-design/pro-flow';
import { FC, useCallback } from 'react';
import './index.less';

interface PipeNodeChild {
title: string;
logo?: string;
id: string;
}

interface PipeNode {
title: string;
logo: string;
des?: string;
children?: PipeNodeChild[];
}

const nodeWidth = 250;
const nodeHeight = 150;
const edgeType = 'bezier';

const PipeNode: FC<{
data: PipeNode;
}> = ({ data }) => {
const { title, des, logo, children = [] } = data;

return (
<div className={'techUIpipeNodeWrap'}>
<div className="pipeNode">
<div className="mainBox">
<div className="logo">
<img src={logo} alt="" />
</div>
<div className="title">{title}</div>
<div className="subLogo">
<img
src={
'https://mdn.alipayobjects.com/huamei_d2ejos/afts/img/A*KS0vRrmHia8AAAAAAAAAAAAADvl6AQ/original'
}
alt=""
/>
</div>
</div>

{children.length > 0 && (
<div className="children">
{children.map((item, index) => (
<>
<div className="childrenBox" key={index}>
<Handle
id={`${item.id}-target`}
type="target"
position={Position.Left}
style={{
opacity: 0,
}}
/>
{item.logo && (
<div className="logo">
<img src={item.logo} alt="" />
</div>
)}
<div className="wrap">
<div className="title">{item.title}</div>
<div className="des">{item.des}</div>
</div>
<Handle
id={`${item.id}-source`}
type="source"
position={Position.Right}
style={{
opacity: 0,
}}
/>
</div>
</>
))}
</div>
)}

{des && <div className="des">{des}</div>}
</div>
</div>
);
};

const nodeTypes = { pipeNode: PipeNode };

const nodes = [
{
id: 'a1',
type: 'pipeNode',
width: nodeWidth,
height: nodeHeight,
data: {
title: '数据信息',
logo: 'https://mdn.alipayobjects.com/huamei_d2ejos/afts/img/A*wq7DR7D72DwAAAAAAAAAAAAADvl6AQ/original',
children: [
{
id: 'a1-1',
title: 'xxxx 数据源',
},
],
},
},
{
id: 'a2',
type: 'pipeNode',
width: nodeWidth,
height: nodeHeight,
data: {
title: '项目名称1',
logo: 'https://mdn.alipayobjects.com/huamei_d2ejos/afts/img/A*DR-gSJlc3J4AAAAAAAAAAAAADvl6AQ/original',
des: '累计 10 个任务',
children: [
{
id: 'a2-1',
title: '实验-xxxx',
logo: 'https://mdn.alipayobjects.com/huamei_d2ejos/afts/img/A*AuYvRabu9iAAAAAAAAAAAAAADvl6AQ/original',
},
{
id: 'a2-2',
title: '实验-xxxx',
logo: 'https://mdn.alipayobjects.com/huamei_d2ejos/afts/img/A*AuYvRabu9iAAAAAAAAAAAAAADvl6AQ/original',
},
{
id: 'a2-3',
title: '服务-xxxx',
logo: 'https://mdn.alipayobjects.com/huamei_d2ejos/afts/img/A*AuYvRabu9iAAAAAAAAAAAAAADvl6AQ/original',
},
],
},
},
{
id: 'a3',
type: 'pipeNode',
width: nodeWidth,
height: nodeHeight,
data: {
title: '项目名称2',
logo: 'https://mdn.alipayobjects.com/huamei_d2ejos/afts/img/A*DR-gSJlc3J4AAAAAAAAAAAAADvl6AQ/original',
des: '累计 3 个任务',
children: [
{
id: 'a3-1',
title: '实验-xxxx',
logo: 'https://mdn.alipayobjects.com/huamei_d2ejos/afts/img/A*AuYvRabu9iAAAAAAAAAAAAAADvl6AQ/original',
},
{
id: 'a3-2',
title: '实验-xxxx',
logo: 'https://mdn.alipayobjects.com/huamei_d2ejos/afts/img/A*AuYvRabu9iAAAAAAAAAAAAAADvl6AQ/original',
},
{
id: 'a3-3',
title: '服务-xxxx',
logo: 'https://mdn.alipayobjects.com/huamei_d2ejos/afts/img/A*AuYvRabu9iAAAAAAAAAAAAAADvl6AQ/original',
},
],
},
},
{
id: 'a4',
type: 'pipeNode',
width: nodeWidth,
height: nodeHeight,
data: {
title: '项目参与机构',
logo: 'https://mdn.alipayobjects.com/huamei_d2ejos/afts/img/A*80wQTLLZQUIAAAAAAAAAAAAADvl6AQ/original',
des: '累计 3 个机构',
children: [
{
id: 'a4-1',
title: '项目申请机构1',
},
{
id: 'a4-2',
title: '项目申请机构2',
},
{
id: 'a4-3',
title: '项目申请机构3',
},
],
},
},
];

const edges = [
{
id: 'edge-1',
source: 'a1',
target: 'a2',
type: edgeType,
sourceHandle: 'a1-1-source',
targetHandle: 'a2-1-target',
},
{
id: 'edge-2',
source: 'a1',
target: 'a2',
type: edgeType,
sourceHandle: 'a1-1-source',
targetHandle: 'a2-2-target',
},
{
id: 'edge-3',
source: 'a1',
target: 'a2',
type: edgeType,
sourceHandle: 'a1-1-source',
targetHandle: 'a2-3-target',
},
{
id: 'edge-4',
source: 'a1',
target: 'a3',
type: edgeType,
sourceHandle: 'a1-1-source',
targetHandle: 'a3-1-target',
},
{
id: 'edge-5',
source: 'a1',
target: 'a3',
type: edgeType,
sourceHandle: 'a1-1-source',
targetHandle: 'a3-2-target',
},
{
id: 'edge-6',
source: 'a1',
target: 'a3',
type: edgeType,
sourceHandle: 'a1-1-source',
targetHandle: 'a3-3-target',
},
{
id: 'edge-7',
source: 'a2',
target: 'a4',
type: edgeType,
sourceHandle: 'a2-1-source',
targetHandle: 'a4-1-target',
},
{
id: 'edge-8',
source: 'a2',
target: 'a4',
type: edgeType,
sourceHandle: 'a2-1-source',
targetHandle: 'a4-2-target',
},
{
id: 'edge-9',
source: 'a2',
target: 'a4',
type: edgeType,
sourceHandle: 'a2-1-source',
targetHandle: 'a4-3-target',
},
{
id: 'edge-10',
source: 'a2',
target: 'a4',
type: edgeType,
sourceHandle: 'a2-2-source',
targetHandle: 'a4-2-target',
},
{
id: 'edge-11',
source: 'a3',
target: 'a4',
type: edgeType,
sourceHandle: 'a3-2-source',
targetHandle: 'a4-1-target',
},
{
id: 'edge-12',
source: 'a3',
target: 'a4',
type: edgeType,
sourceHandle: 'a3-3-source',
targetHandle: 'a4-2-target',
},
];

function App() {
const flowViewer = useFlowViewer();

const handleClick = useCallback(
(e, n) => {
flowViewer?.zoomToNode(n.id, 1000);
},
[flowViewer],
);

const handlePaneClick = useCallback(() => {
// flowViewer?.zoomToNode(n.id, 1000);
}, [flowViewer]);

return (
<div className="container">
<FlowView
onNodeClick={handleClick}
onPaneClick={handlePaneClick}
nodes={nodes}
edges={edges}
nodeTypes={nodeTypes}
background={false}
>
<Background color="#F6F8FB" variant="none" style={{ background: '#F6F8FB' }} />
</FlowView>
</div>
);
}

function ProApp() {
return (
<FlowViewProvider>
<App />
</FlowViewProvider>
);
}

export default ProApp;
10 changes: 10 additions & 0 deletions docs/useDocs/techPileline.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
nav: 使用文档
group:
title: 案例展示
order: 10
title: TechUI PipeLine
description:
---

<code src="./demos/techuiPipeline.tsx" ></code>