-
Notifications
You must be signed in to change notification settings - Fork 74
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
1 parent
f4d19c9
commit 53bdf55
Showing
43 changed files
with
926 additions
and
555 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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 |
---|---|---|
@@ -0,0 +1,108 @@ | ||
import Flex from './Flex'; | ||
import useResizeObserver from '@react-hook/resize-observer'; | ||
import { Button, Divider, Typography, theme } from 'antd'; | ||
import { useRef, useState } from 'react'; | ||
|
||
interface StartItemContentProps { | ||
title: string; | ||
description?: string; | ||
icon?: React.ReactNode; | ||
buttonText: string; | ||
onClick?: () => void; | ||
themeColor?: string; | ||
iconBgColor?: string; | ||
} | ||
|
||
const ActionItemContent: React.FC<StartItemContentProps> = ({ | ||
title, | ||
description, | ||
icon, | ||
buttonText, | ||
onClick, | ||
themeColor, | ||
iconBgColor, | ||
}) => { | ||
const { token } = theme.useToken(); | ||
const [needScroll, setNeedScroll] = useState<boolean>(false); | ||
const containerRef = useRef<HTMLDivElement>(null); | ||
|
||
useResizeObserver(containerRef, (entry) => { | ||
entry.contentRect.width <= 220 ? setNeedScroll(true) : setNeedScroll(false); | ||
}); | ||
|
||
return ( | ||
<Flex | ||
ref={containerRef} | ||
align="center" | ||
justify="between" | ||
direction="column" | ||
style={{ | ||
height: '100%', | ||
textAlign: 'center', | ||
overflowY: 'auto', | ||
//TODO: This is a temporary fix for the padding issue. It should be served from BAIBoard. | ||
paddingTop: token.marginMD, | ||
}} | ||
> | ||
<Flex direction="column" gap={token.marginSM}> | ||
<Flex | ||
align="center" | ||
justify="center" | ||
style={{ | ||
borderRadius: 25, | ||
width: 50, | ||
height: 50, | ||
//TODO: This is a temporary default background color for the icon. It should be served as a token. | ||
backgroundColor: iconBgColor ? iconBgColor : token['green-1'], | ||
}} | ||
> | ||
{icon} | ||
</Flex> | ||
<Flex style={{ minHeight: 60 }}> | ||
<Typography.Text | ||
strong | ||
style={{ | ||
fontSize: token.fontSizeHeading4, | ||
color: themeColor ? themeColor : token.colorPrimary, | ||
}} | ||
> | ||
{title} | ||
</Typography.Text> | ||
</Flex> | ||
<Typography.Text | ||
type="secondary" | ||
style={{ fontSize: token.fontSizeSM }} | ||
> | ||
{!needScroll && description} | ||
</Typography.Text> | ||
</Flex> | ||
<Flex direction="column" style={{ width: '100%' }}> | ||
{description && ( | ||
<Divider style={{ margin: token.marginSM, borderWidth: 2 }} /> | ||
)} | ||
<Flex style={{ width: '100%', padding: `0 ${token.paddingMD}px` }}> | ||
<Button | ||
type="primary" | ||
style={{ | ||
width: '100%', | ||
height: 40, | ||
backgroundColor: themeColor ? themeColor : token.colorPrimary, | ||
}} | ||
onClick={onClick} | ||
> | ||
<Typography.Text | ||
style={{ | ||
fontSize: token.fontSizeHeading5, | ||
color: token.colorWhite, | ||
}} | ||
> | ||
{buttonText} | ||
</Typography.Text> | ||
</Button> | ||
</Flex> | ||
</Flex> | ||
</Flex> | ||
); | ||
}; | ||
|
||
export default ActionItemContent; |
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
Oops, something went wrong.