generated from arvinxx/monorepo-template
-
Notifications
You must be signed in to change notification settings - Fork 1
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
Showing
20 changed files
with
318 additions
and
60 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
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 |
---|---|---|
|
@@ -5,7 +5,9 @@ group: | |
title: 业务组件 | ||
--- | ||
|
||
## Mindflow | ||
# Mindflow | ||
|
||
## 基础节点 | ||
|
||
<code src='./examples/Mindflow/index.tsx' /> | ||
|
||
|
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 was deleted.
Oops, something went wrong.
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,18 @@ | ||
import type { Options } from '@antv/x6/lib/graph/options'; | ||
import { minimapOpts } from './minimapOpts'; | ||
|
||
/** | ||
* 生成图的配置项 | ||
* @param container | ||
* @param minimapCtn | ||
*/ | ||
export const graphOpts = (container, minimapCtn): Partial<Options.Manual> => ({ | ||
container, | ||
background: { | ||
color: '#fafafa', | ||
}, | ||
panning: true, | ||
mousewheel: true, | ||
scroller: true, | ||
minimap: minimapOpts(minimapCtn), | ||
}); |
This file was deleted.
Oops, something went wrong.
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,23 @@ | ||
import { MinimaNode } from './shapes'; | ||
|
||
export const minimapOpts = (container) => ({ | ||
container, | ||
enabled: true, | ||
maxScale: 1, | ||
scalable: false, | ||
graphOptions: { | ||
async: true, | ||
// 用指定的 View 替换节点默认的 View | ||
getCellView(cell) { | ||
if (cell.isNode()) { | ||
return MinimaNode; | ||
} | ||
}, | ||
// 在小地图中不渲染边 | ||
createCellView(cell) { | ||
if (cell.isEdge()) { | ||
return null; | ||
} | ||
}, | ||
}, | ||
}); |
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,20 @@ | ||
import { NodeView } from '@antv/x6'; | ||
|
||
export class MinimaNode extends NodeView { | ||
protected renderMarkup() { | ||
return this.renderJSONMarkup({ | ||
tagName: 'rect', | ||
selector: 'body', | ||
}); | ||
} | ||
|
||
update() { | ||
super.update({ | ||
body: { | ||
refWidth: '100%', | ||
refHeight: '100%', | ||
fill: '#1890ff', | ||
}, | ||
}); | ||
} | ||
} |
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,36 @@ | ||
.mind-node { | ||
&-container { | ||
position: relative; | ||
padding: 8px; | ||
border: 1px solid transparent; | ||
border-left-width: 4px; | ||
border-radius: 4px; | ||
} | ||
|
||
&-title { | ||
display: -webkit-box; | ||
overflow: hidden; | ||
text-overflow: ellipsis; | ||
-webkit-box-orient: vertical; | ||
-webkit-line-clamp: 2; // 以此类推,3行4行直接该数字就好啦 | ||
} | ||
|
||
&-collapse { | ||
position: absolute; | ||
top: 50%; | ||
right: -10px; | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
width: 20px; | ||
height: 20px; | ||
background: white; | ||
border: 1px solid transparent; | ||
border-radius: 20px; | ||
transform: translateY(-50%); | ||
|
||
&-icon { | ||
font-size: 13px; | ||
} | ||
} | ||
} |
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,53 @@ | ||
import type { FC } from 'react'; | ||
import React from 'react'; | ||
import { PlusOutlined, MinusOutlined } from '@ant-design/icons'; | ||
|
||
import type { ReactShape } from '@antv/x6-react-shape'; | ||
import { mapColorToHex, mapTypeToColor } from '../../utils'; | ||
import chorma from 'chroma-js'; | ||
|
||
import type { MindflowData } from '../../types'; | ||
|
||
import './Node.less'; | ||
|
||
interface BaseNodeProps { | ||
node?: ReactShape; | ||
} | ||
|
||
export const Node: FC<BaseNodeProps> = ({ node }) => { | ||
const data = node.getData<MindflowData>(); | ||
const { type, collapsed, hasChildren = true } = data; | ||
const baseColor = chorma(mapColorToHex(mapTypeToColor(type))); | ||
|
||
return ( | ||
<div | ||
className="mind-node-container" | ||
style={{ | ||
background: baseColor.alpha(0.1).hex(), | ||
borderColor: baseColor.alpha(0.3).hex(), | ||
borderLeftColor: baseColor.hex(), | ||
}} | ||
> | ||
<div className="mind-node-title">{data.text}</div> | ||
|
||
{hasChildren ? ( | ||
<div | ||
className="mind-node-collapse" | ||
style={{ borderColor: baseColor.hex() }} | ||
> | ||
{collapsed ? ( | ||
<PlusOutlined | ||
className="mind-node-collapse-icon" | ||
style={{ color: baseColor.hex() }} | ||
/> | ||
) : ( | ||
<MinusOutlined | ||
className="mind-node-collapse-icon" | ||
style={{ color: baseColor.hex() }} | ||
/> | ||
)} | ||
</div> | ||
) : null} | ||
</div> | ||
); | ||
}; |
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,2 @@ | ||
export * from './Node'; | ||
export * from './MinimaNode'; |
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,15 +1,15 @@ | ||
import '@antv/x6-react-shape'; | ||
import React from 'react'; | ||
import { Graph } from '@antv/x6'; | ||
import { Shape } from '../definition'; | ||
import { Node } from '../definition/shapes'; | ||
import { useEffect } from 'react'; | ||
|
||
export const useGraphRegister = () => { | ||
useEffect(() => { | ||
// 注册返回 React 组件的函数 | ||
Graph.registerReactComponent('test-shape', <Shape />); | ||
Graph.registerReactComponent('mind-node', <Node />); | ||
return () => { | ||
Graph.unregisterReactComponent('test-shape'); | ||
Graph.unregisterReactComponent('mind-node'); | ||
}; | ||
}, []); | ||
}; |
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,24 @@ | ||
const baseGreen = '#52c41a'; | ||
const baseYellow = '#faad14'; | ||
const baseRed = '#ff4d4f'; | ||
const baseBlue = '#69c0ff'; | ||
const baseCyan = '#5cdbd3'; | ||
const basePurple = '#b37feb'; | ||
const baseGray = '#8f8f8f'; | ||
|
||
const black009 = 'rgba(0,0,0,0.09)'; | ||
const black002 = 'rgba(0,0,0,0.02)'; | ||
|
||
export const mindFlowColors = { | ||
white: '#ffffff', | ||
blue: baseBlue, | ||
cyan: baseCyan, | ||
green: baseGreen, | ||
yellow: baseYellow, | ||
red: baseRed, | ||
purple: basePurple, | ||
gray: baseGray, | ||
black009, | ||
shadowColor: black009, | ||
menuHoverBg: black002, | ||
}; |
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
Oops, something went wrong.
74eaa6e
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs: