generated from arvinxx/npm-template
-
Notifications
You must be signed in to change notification settings - Fork 19
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
Jan 3, 2025
1 parent
518f2e4
commit cf366cd
Showing
3 changed files
with
158 additions
and
16 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,71 @@ | ||
import { createStyles } from 'antd-style'; | ||
|
||
const useStyles = createStyles(({ css }) => ({ | ||
container: css` | ||
width: 100%; | ||
height: 100%; | ||
display: flex; | ||
/* flex-direction: column; */ | ||
`, | ||
label: css` | ||
text-align: center; | ||
line-height: 40px; | ||
height: 40px; | ||
border-bottom: 1px solid #cbcdce; | ||
color: '#A8AAAE'; | ||
`, | ||
})); | ||
|
||
export interface SwimlaneBackgroundProps { | ||
lanes: SwimLaneProps[]; | ||
className?: string; | ||
style?: React.CSSProperties; | ||
} | ||
|
||
export interface SwimLaneProps { | ||
id: string; | ||
label: string; | ||
labelColor?: string; | ||
backgroundColor?: string; | ||
width?: string; | ||
style?: React.CSSProperties; | ||
} | ||
|
||
const SwimlaneBackground = (props: SwimlaneBackgroundProps) => { | ||
const { lanes, className: clm, style } = props; | ||
const { styles } = useStyles(); | ||
|
||
return ( | ||
<div | ||
className={`${styles.container} ${clm}`} | ||
style={{ | ||
...style, | ||
}} | ||
> | ||
{lanes.map((lane) => ( | ||
<div | ||
key={lane.id} | ||
style={{ | ||
top: 0, | ||
height: '100%', | ||
width: lane.width || '100%', | ||
backgroundColor: lane.backgroundColor || '#FAFAFA', | ||
border: '1px solid #cbcdce', | ||
...lane.style, | ||
}} | ||
> | ||
<div | ||
className={styles.label} | ||
style={{ | ||
backgroundColor: lane.labelColor || '#f6f8fc', | ||
}} | ||
> | ||
{lane.label} | ||
</div> | ||
</div> | ||
))} | ||
</div> | ||
); | ||
}; | ||
|
||
export default SwimlaneBackground; |
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,67 @@ | ||
/** | ||
* compact: true | ||
*/ | ||
import { FlowView } from '@ant-design/pro-flow'; | ||
import { createStyles } from 'antd-style'; | ||
import { memo } from 'react'; | ||
import SwimlaneBackground from '../components/SwimBg'; | ||
|
||
const useStyles = createStyles(({ css }) => ({ | ||
container: css` | ||
width: 100%; | ||
height: 600px; | ||
`, | ||
})); | ||
|
||
const BackgroundDemo = memo(() => { | ||
const { styles } = useStyles(); | ||
|
||
return ( | ||
<div className={styles.container}> | ||
<FlowView nodes={[]} edges={[]} miniMap={false} background={false}> | ||
<SwimlaneBackground | ||
lanes={[ | ||
{ | ||
id: '1', | ||
label: 'Swimlane 1', | ||
labelColor: '#FECCCB', | ||
}, | ||
{ | ||
id: '2', | ||
label: 'Swimlane 2', | ||
labelColor: '#FDCDE6', | ||
}, | ||
{ | ||
id: '3', | ||
label: 'Swimlane 3', | ||
labelColor: '#CEFFE7', | ||
}, | ||
{ | ||
id: '4', | ||
|
||
label: 'Swimlane 4', | ||
labelColor: '#CDFECE', | ||
}, | ||
{ | ||
id: '5', | ||
label: 'Swimlane 5', | ||
labelColor: '#E7FFCC', | ||
}, | ||
{ | ||
id: '6', | ||
label: 'Swimlane 6', | ||
labelColor: '#CEFFE7', | ||
}, | ||
{ | ||
id: '7', | ||
label: 'Swimlane 7', | ||
labelColor: '#CBE5FF', | ||
}, | ||
]} | ||
></SwimlaneBackground> | ||
</FlowView> | ||
</div> | ||
); | ||
}); | ||
|
||
export default BackgroundDemo; |
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