-
Notifications
You must be signed in to change notification settings - Fork 111
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #482 from antvis/chore/tugraph
WIP:增加中台通用布局
- Loading branch information
Showing
39 changed files
with
1,410 additions
and
94 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
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
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
162 changes: 162 additions & 0 deletions
162
packages/gi-assets-basic/src/components/RichContainer/Component.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,162 @@ | ||
import { Icon, useContainer, useContext, utils } from '@antv/gi-sdk'; | ||
import { Select, Space } from 'antd'; | ||
import React from 'react'; | ||
import Toolbar from './Toolbar'; | ||
import './index.less'; | ||
const URL_SEARCH_KEY = 'ActiveAssetID'; | ||
const visibleStyle: React.CSSProperties = { | ||
visibility: 'visible', | ||
width: '100%', | ||
}; | ||
const hiddenStyle: React.CSSProperties = { | ||
visibility: 'hidden', | ||
position: 'absolute', | ||
bottom: '-800px', | ||
}; | ||
|
||
export interface RichContainerState { | ||
/** 当前激活的面板 */ | ||
activeKey: string; | ||
/** 当前的模式 */ | ||
viewMode: string; | ||
} | ||
const RichContainer = props => { | ||
const { children } = props; | ||
const context = useContext(); | ||
const { HAS_GRAPH } = context; | ||
const Containers = useContainer(context); | ||
const [state, setState] = React.useState<RichContainerState>({ | ||
activeKey: utils.searchParamOf(URL_SEARCH_KEY) || 'FilterPanel', | ||
viewMode: 'GISDK_CANVAS', | ||
}); | ||
const { activeKey, viewMode } = state; | ||
|
||
const [NavbarLeftArea, NavbarRightArea, ViewArea, DataArea, StylingArea, CanvasArea, AnalysisArea] = Containers; | ||
|
||
const handleChange = id => { | ||
const { searchParams, path } = utils.getSearchParams(window.location); | ||
searchParams.set(URL_SEARCH_KEY, id); | ||
window.location.hash = `${path}?${searchParams.toString()}`; | ||
|
||
setState(preState => { | ||
return { | ||
...preState, | ||
activeKey: id, | ||
}; | ||
}); | ||
}; | ||
|
||
const handleChangeViewMode = id => { | ||
setState(preState => { | ||
return { | ||
...preState, | ||
viewMode: id, | ||
}; | ||
}); | ||
}; | ||
|
||
const ViewModeOptions = [ | ||
{ | ||
value: 'GISDK_CANVAS', | ||
label: ( | ||
<Space> | ||
<Icon type="icon-deploymentunit1"></Icon> | ||
图谱视图 | ||
</Space> | ||
), | ||
}, | ||
...ViewArea.components.map(item => { | ||
const { icon, title } = item.props.GIAC_CONTENT; | ||
return { | ||
value: item.id, | ||
label: ( | ||
<Space> | ||
<Icon type={icon}></Icon> | ||
{title} | ||
</Space> | ||
), | ||
}; | ||
}), | ||
]; | ||
|
||
console.log('render.....', Containers, HAS_GRAPH, ViewModeOptions, viewMode); | ||
|
||
return ( | ||
<div className="gi-rich-container"> | ||
<div className="gi-rich-container-navbar"> | ||
<div className="navbar-back"> | ||
{NavbarLeftArea.components.map(item => { | ||
return <item.component key={item.id} {...item.props} />; | ||
})} | ||
</div> | ||
<div className="navbar-setting"> | ||
{NavbarRightArea.components.map(item => { | ||
return <item.component key={item.id} {...item.props} />; | ||
})} | ||
</div> | ||
</div> | ||
<div className="gi-rich-container-toolbar"> | ||
<div className="toolbar-item"> | ||
<Select | ||
bordered={false} | ||
defaultValue="GISDK_CANVAS" | ||
style={{ width: 120 }} | ||
onChange={handleChangeViewMode} | ||
options={ViewModeOptions} | ||
/> | ||
</div> | ||
<Toolbar | ||
value={activeKey} | ||
onChange={handleChange} | ||
title="查询过滤" | ||
displayText | ||
options={DataArea.components} | ||
HAS_GRAPH={HAS_GRAPH} | ||
/> | ||
<Toolbar | ||
value={activeKey} | ||
onChange={handleChange} | ||
title="布局样式" | ||
options={StylingArea.components} | ||
HAS_GRAPH={HAS_GRAPH} | ||
/> | ||
<Toolbar | ||
value={activeKey} | ||
onChange={handleChange} | ||
title="画布操作" | ||
options={CanvasArea.components} | ||
HAS_GRAPH={HAS_GRAPH} | ||
/> | ||
<div className="toolbar-item"></div> | ||
<div className="toolbar-item"></div> | ||
</div> | ||
|
||
<div className="gi-rich-container-content"> | ||
<div style={viewMode === 'GISDK_CANVAS' ? visibleStyle : hiddenStyle}> | ||
<div className="gi-rich-container-side"> | ||
{[...DataArea.components, ...StylingArea.components].map(item => { | ||
const isActive = activeKey === item.id; | ||
return ( | ||
<div key={item.id} style={{ display: isActive ? 'block' : 'none' }}> | ||
<item.component key={item.id} {...item.props} /> | ||
</div> | ||
); | ||
})} | ||
</div> | ||
<div className="gi-rich-container-canvas">{children}</div> | ||
</div> | ||
{ViewArea.components.map(item => { | ||
const isActive = item.id === viewMode; | ||
const viewStyle = isActive ? visibleStyle : hiddenStyle; | ||
return ( | ||
<div key={item.id} style={{ ...viewStyle, background: 'var(--background-color)' }}> | ||
{HAS_GRAPH && <item.component key={item.id} {...item.props} />} | ||
</div> | ||
); | ||
})} | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default RichContainer; |
55 changes: 55 additions & 0 deletions
55
packages/gi-assets-basic/src/components/RichContainer/Toolbar.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import { Icon } from '@antv/gi-sdk'; | ||
import { Button, Divider } from 'antd'; | ||
import React from 'react'; | ||
export interface ToolbarProps { | ||
/** 分类的标题 */ | ||
title: string; | ||
/** 分类信息 */ | ||
options: any; | ||
/** 当前激活的值 */ | ||
value: string; | ||
/** 触发函数 */ | ||
onChange: (id: string) => void; | ||
/** 是否展示文本 */ | ||
displayText?: boolean; | ||
/** Context.HAS_GRAPH */ | ||
HAS_GRAPH: boolean; | ||
} | ||
const Toolbar = (props: ToolbarProps) => { | ||
const { title, options, value, onChange, displayText, HAS_GRAPH } = props; | ||
return ( | ||
<div style={{ display: 'flex', justifyContent: 'center', alignItems: 'center' }}> | ||
<Divider type="vertical" /> | ||
<span style={{ padding: '0px 16px 0px 8px' }}>{title}</span> | ||
{options.map(item => { | ||
const isActive = value === item.id; | ||
const { id, props: itemProps, component: ItemComponent } = item; | ||
const { GIAC_CONTENT } = itemProps; | ||
const title = GIAC_CONTENT ? GIAC_CONTENT.title : 'EMPTY'; | ||
const buttonType = isActive ? 'primary' : 'text'; | ||
if (!HAS_GRAPH) { | ||
return null; | ||
} | ||
if (!GIAC_CONTENT) { | ||
return <ItemComponent {...itemProps} />; | ||
} | ||
const { icon } = GIAC_CONTENT || {}; | ||
return ( | ||
<Button | ||
type={buttonType} | ||
icon={<Icon type={icon} />} | ||
key={id} | ||
style={{ display: 'flex', justifyContent: 'center', alignItems: 'center' }} | ||
onClick={() => { | ||
onChange(id); | ||
}} | ||
> | ||
{displayText ? title : null} | ||
</Button> | ||
); | ||
})} | ||
</div> | ||
); | ||
}; | ||
|
||
export default Toolbar; |
Empty file.
63 changes: 63 additions & 0 deletions
63
packages/gi-assets-basic/src/components/RichContainer/index.less
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,63 @@ | ||
@side-width: 320px; | ||
.gi-rich-container { | ||
position: absolute; | ||
top: 0px; | ||
right: 0px; | ||
bottom: 0px; | ||
left: 0px; | ||
display: block; | ||
|
||
.gi-rich-container-navbar { | ||
padding: 0px 20px; | ||
position: relative; | ||
height: 54px; | ||
width: 100%; | ||
background: var(--background-color); | ||
display: flex; | ||
justify-content: space-between; | ||
.navbar-back { | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
} | ||
.navbar-setting { | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
} | ||
} | ||
.gi-rich-container-toolbar { | ||
position: relative; | ||
height: 44px; | ||
width: 100%; | ||
background: #f3f5f9; | ||
border-bottom: 1px solid #ddd; | ||
display: flex; | ||
padding: 0px 12px; | ||
.toolbar-item { | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
} | ||
} | ||
.gi-rich-container-content { | ||
position: absolute; | ||
bottom: 0px; | ||
top: 98px; | ||
left: 0px; | ||
right: 0px; | ||
display: flex; | ||
.gi-rich-container-side { | ||
width: @side-width; | ||
height: 100%; | ||
background: #f3f5f9; | ||
} | ||
.gi-rich-container-canvas { | ||
position: absolute; | ||
top: 0px; | ||
bottom: 0px; | ||
left: @side-width; | ||
right: 0px; | ||
} | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
packages/gi-assets-basic/src/components/RichContainer/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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import Component from './Component'; | ||
import info from './info'; | ||
import registerMeta from './registerMeta'; | ||
|
||
export default { info, component: Component, registerMeta }; |
10 changes: 10 additions & 0 deletions
10
packages/gi-assets-basic/src/components/RichContainer/info.ts
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,10 @@ | ||
const info = { | ||
id: 'RichContainer', | ||
name: '中台布局', | ||
desc: '中台布局', | ||
cover: 'http://xxx.jpg', | ||
category: 'system-interaction', | ||
icon: 'icon-home', | ||
type: 'GICC_LAYOUT', | ||
}; | ||
export default info; |
Oops, something went wrong.