From cf366cd0e93bb0c0643369a032985f2a80f8ceda Mon Sep 17 00:00:00 2001 From: jiangchu Date: Fri, 3 Jan 2025 14:46:16 +0800 Subject: [PATCH] :sparkles: feat: add swim lane --- src/Background/components/SwimBg.tsx | 71 ++++++++++++++++++++++++++++ src/Background/demos/swim.tsx | 67 ++++++++++++++++++++++++++ src/Background/index.zh-CN.md | 36 +++++++------- 3 files changed, 158 insertions(+), 16 deletions(-) create mode 100644 src/Background/components/SwimBg.tsx create mode 100644 src/Background/demos/swim.tsx diff --git a/src/Background/components/SwimBg.tsx b/src/Background/components/SwimBg.tsx new file mode 100644 index 0000000..bc7b2ce --- /dev/null +++ b/src/Background/components/SwimBg.tsx @@ -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 ( +
+ {lanes.map((lane) => ( +
+
+ {lane.label} +
+
+ ))} +
+ ); +}; + +export default SwimlaneBackground; diff --git a/src/Background/demos/swim.tsx b/src/Background/demos/swim.tsx new file mode 100644 index 0000000..f74900c --- /dev/null +++ b/src/Background/demos/swim.tsx @@ -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 ( +
+ + + +
+ ); +}); + +export default BackgroundDemo; diff --git a/src/Background/index.zh-CN.md b/src/Background/index.zh-CN.md index d6077b0..fb0f134 100644 --- a/src/Background/index.zh-CN.md +++ b/src/Background/index.zh-CN.md @@ -14,28 +14,32 @@ description: +## Swim Background + + + ## Double Background ## APIs -| 属性名 | 类型 | 描述 | 默认值 | 必选 | -| --------- | --------------------------- | --------------------------------------- | --- | -- | -| id | `string` | 如果要显示多个背景,则需要 | - | - | -| className | `string` | 自定义类名 | - | - | -| variant | `BackgroundVariant` | 背景图案类型 | - | - | -| gap | `number \|[number, number]` | 模式之间的差距。您可以传递一个包含两个数字的数组来指定 x 间隙和 y 间隙。 | - | - | -| size | `number` | ” 点 “的半径或” 十字 “的尺寸 | - | - | -| lineWidth | `number` | ” 线 “或” 十字 “的宽度 | - | - | -| offset | `number` | 图案偏移 | - | - | -| color | `string` | 图案颜色 | - | - | -| style | `CSSProperties` | 样式属性 | - | - | +| 属性名 | 类型 | 描述 | 默认值 | 必选 | +| --------- | --------------------------- | ------------------------------------------------------------------------ | ------ | ---- | +| id | `string` | 如果要显示多个背景,则需要 | - | - | +| className | `string` | 自定义类名 | - | - | +| variant | `BackgroundVariant` | 背景图案类型 | - | - | +| gap | `number \|[number, number]` | 模式之间的差距。您可以传递一个包含两个数字的数组来指定 x 间隙和 y 间隙。 | - | - | +| size | `number` | ” 点 “的半径或” 十字 “的尺寸 | - | - | +| lineWidth | `number` | ” 线 “或” 十字 “的宽度 | - | - | +| offset | `number` | 图案偏移 | - | - | +| color | `string` | 图案颜色 | - | - | +| style | `CSSProperties` | 样式属性 | - | - | ### BackgroundVariant -| 属性名 | 类型 | 描述 | 默认值 | 必选 | -| ----- | -------- | -- | --- | -- | -| lines | `string` | 线 | - | - | -| dots | `string` | 点 | - | - | -| cross | `string` | 十字 | - | - | +| 属性名 | 类型 | 描述 | 默认值 | 必选 | +| ------ | -------- | ---- | ------ | ---- | +| lines | `string` | 线 | - | - | +| dots | `string` | 点 | - | - | +| cross | `string` | 十字 | - | - |