-
Notifications
You must be signed in to change notification settings - Fork 73
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
18 changed files
with
1,008 additions
and
12 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 |
---|---|---|
@@ -0,0 +1,123 @@ | ||
import Flex from './Flex'; | ||
import ResourceGroupSelect from './ResourceGroupSelect'; | ||
import ResourceUnit, { ResourceUnitProps } from './ResourceUnit'; | ||
import { SyncOutlined } from '@ant-design/icons'; | ||
import { | ||
Button, | ||
Card, | ||
CardProps, | ||
ConfigProvider, | ||
Divider, | ||
Switch, | ||
theme, | ||
Typography, | ||
} from 'antd'; | ||
import _ from 'lodash'; | ||
import React from 'react'; | ||
import { useTranslation } from 'react-i18next'; | ||
|
||
interface AllocatedResourcesCardProps extends CardProps {} | ||
|
||
const AllocatedResourcesCard: React.FC<AllocatedResourcesCardProps> = ({ | ||
...cardProps | ||
}) => { | ||
const { token } = theme.useToken(); | ||
const { t } = useTranslation(); | ||
|
||
const resourceUnitMockData: Array<ResourceUnitProps> = [ | ||
{ | ||
name: 'CPU', | ||
displayUnit: 'Core', | ||
value: 12, | ||
percentage: (4 / 12) * 100, | ||
}, | ||
{ | ||
name: 'RAM', | ||
displayUnit: 'GiB', | ||
value: 256, | ||
percentage: (8 / 12) * 100, | ||
}, | ||
{ | ||
name: 'FGPU', | ||
displayUnit: 'GiB', | ||
value: 3.5, | ||
percentage: (4 / 12) * 100, | ||
}, | ||
{ | ||
name: 'ATOM', | ||
displayUnit: 'Unit', | ||
value: 2, | ||
percentage: (2 / 12) * 100, | ||
}, | ||
]; | ||
return ( | ||
<ConfigProvider | ||
theme={{ | ||
components: { | ||
Button: { | ||
onlyIconSizeLG: 20, | ||
}, | ||
}, | ||
}} | ||
> | ||
<Card | ||
{...cardProps} | ||
style={{ | ||
width: '100%', | ||
height: 240, | ||
// width: 936, | ||
// height: 192, | ||
}} | ||
> | ||
<Flex justify="between" style={{ marginBottom: 26 }}> | ||
<Flex gap={10}> | ||
<Typography.Title | ||
level={4} | ||
style={{ | ||
margin: 0, | ||
}} | ||
> | ||
Allocated Resources | ||
</Typography.Title> | ||
<Switch defaultChecked /> | ||
</Flex> | ||
<Flex> | ||
<ResourceGroupSelect | ||
placeholder={t('session.ResourceGroup')} | ||
variant="borderless" | ||
style={{ minWidth: 151, fontSize: token.fontSizeLG, padding: 0 }} | ||
dropdownStyle={{ color: '#999999' }} | ||
/> | ||
<Button | ||
type="link" | ||
size="large" | ||
icon={<SyncOutlined />} | ||
style={{ padding: 0, color: '#5DD2AD' }} | ||
/> | ||
</Flex> | ||
</Flex> | ||
<Flex justify="between" style={{ maxWidth: 630 }}> | ||
{_.map( | ||
resourceUnitMockData, | ||
(resourceUnit: ResourceUnitProps, index) => ( | ||
<> | ||
<ResourceUnit | ||
key={index} | ||
name={resourceUnit.name} | ||
displayUnit={resourceUnit.displayUnit} | ||
value={resourceUnit.value} | ||
percentage={resourceUnit.percentage} | ||
/> | ||
{index < resourceUnitMockData.length - 1 && ( | ||
<Divider type="vertical" style={{ height: 70 }} /> | ||
)} | ||
</> | ||
), | ||
)} | ||
</Flex> | ||
</Card> | ||
</ConfigProvider> | ||
); | ||
}; | ||
|
||
export default AllocatedResourcesCard; |
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,127 @@ | ||
import Flex from './Flex'; | ||
import { | ||
Button, | ||
ButtonProps, | ||
Card, | ||
CardProps, | ||
ConfigProvider, | ||
Divider, | ||
theme, | ||
Typography, | ||
} from 'antd'; | ||
|
||
export interface BAIStartBasicCardProps extends CardProps { | ||
icon: React.ReactNode; | ||
title: React.ReactNode; | ||
footerButtonProps: ButtonProps; | ||
description?: string; | ||
secondary?: Boolean; | ||
} | ||
|
||
const BAIStartBasicCard: React.FC<BAIStartBasicCardProps> = ({ | ||
icon, | ||
title, | ||
footerButtonProps, | ||
description, | ||
secondary, | ||
...cardProps | ||
}) => { | ||
const { token } = theme.useToken(); | ||
|
||
return ( | ||
<ConfigProvider | ||
theme={{ | ||
components: { | ||
Button: { | ||
defaultBorderColor: 'none', | ||
defaultColor: secondary ? '#E8FAF6' : '#FFF6E8', | ||
defaultBg: secondary ? '#00BD9B' : token.colorPrimary, | ||
defaultHoverColor: secondary ? '#00BD9B' : token.colorPrimary, | ||
defaultHoverBorderColor: secondary ? '#00BD9B' : token.colorPrimary, | ||
}, | ||
}, | ||
}} | ||
> | ||
<Card | ||
{...cardProps} | ||
styles={{ | ||
body: { | ||
paddingTop: token.paddingSM, | ||
paddingBottom: token.paddingSM, | ||
paddingLeft: token.paddingMD, | ||
paddingRight: token.paddingMD, | ||
width: 210, | ||
height: 308, | ||
}, | ||
}} | ||
> | ||
<Flex | ||
direction="column" | ||
justify="between" | ||
align="stretch" | ||
style={{ height: '100%' }} | ||
> | ||
<Flex | ||
align="center" | ||
direction="column" | ||
gap={16} | ||
style={{ | ||
minHeight: 202, | ||
}} | ||
> | ||
<Flex | ||
align="center" | ||
justify="center" | ||
style={{ | ||
width: 50, | ||
height: 50, | ||
padding: 0, | ||
border: 0, | ||
color: secondary ? '#00BD9B' : '#FF7A00', | ||
background: secondary ? '#E8FAF6' : '#FFF6E8', | ||
fontSize: token.sizeLG, | ||
borderRadius: '50%', | ||
}} | ||
> | ||
{icon} | ||
</Flex> | ||
<Typography.Text | ||
strong | ||
style={{ | ||
fontSize: token.fontSizeLG, | ||
color: secondary ? '#00BD9B' : token.colorLink, | ||
textAlign: 'center', | ||
}} | ||
> | ||
{title} | ||
</Typography.Text> | ||
{description && ( | ||
<Typography.Paragraph | ||
style={{ | ||
color: token.colorTextDescription, | ||
fontSize: token.fontSize - 4, | ||
textAlign: 'center', | ||
}} | ||
> | ||
{description} | ||
</Typography.Paragraph> | ||
)} | ||
</Flex> | ||
<Flex direction="column"> | ||
<Divider style={{ margin: 0, marginBottom: token.margin }} /> | ||
<Button | ||
{...footerButtonProps} | ||
size="large" | ||
block | ||
style={{ | ||
borderRadius: token.borderRadiusLG, | ||
}} | ||
/> | ||
</Flex> | ||
</Flex> | ||
</Card> | ||
</ConfigProvider> | ||
); | ||
}; | ||
|
||
export default BAIStartBasicCard; |
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,111 @@ | ||
import Flex from './Flex'; | ||
import { | ||
Button, | ||
ButtonProps, | ||
Card, | ||
CardProps, | ||
ConfigProvider, | ||
theme, | ||
Typography, | ||
} from 'antd'; | ||
|
||
export interface BAIStartSimpleCardProps extends CardProps { | ||
icon: React.ReactNode; | ||
title: React.ReactNode; | ||
footerButtonProps: ButtonProps; | ||
description?: string; | ||
secondary?: Boolean; | ||
} | ||
|
||
const BAIStartSimpleCard: React.FC<BAIStartSimpleCardProps> = ({ | ||
icon, | ||
title, | ||
footerButtonProps, | ||
description, | ||
secondary, | ||
...cardProps | ||
}) => { | ||
const { token } = theme.useToken(); | ||
|
||
return ( | ||
<ConfigProvider | ||
theme={{ | ||
components: { | ||
Button: { | ||
defaultBorderColor: 'none', | ||
defaultColor: secondary ? '#E8FAF6' : '#FFF6E8', | ||
defaultBg: secondary ? '#00BD9B' : token.colorPrimary, | ||
defaultHoverColor: secondary ? '#00BD9B' : token.colorPrimary, | ||
defaultHoverBorderColor: secondary ? '#00BD9B' : token.colorPrimary, | ||
}, | ||
}, | ||
}} | ||
> | ||
<Card | ||
styles={{ | ||
body: { | ||
width: 194, | ||
height: 192, | ||
}, | ||
}} | ||
{...cardProps} | ||
> | ||
<Flex | ||
direction="column" | ||
justify="center" | ||
align="stretch" | ||
style={{ height: '100%' }} | ||
> | ||
<Flex align="center" direction="column" gap={16}> | ||
<Flex | ||
align="center" | ||
justify="center" | ||
style={{ | ||
width: 50, | ||
height: 50, | ||
padding: 0, | ||
border: 0, | ||
color: secondary ? '#00BD9B' : '#FF7A00', | ||
background: secondary ? '#E8FAF6' : '#FFF6E8', | ||
fontSize: token.sizeLG, | ||
borderRadius: '50%', | ||
}} | ||
> | ||
{icon} | ||
</Flex> | ||
<Typography.Text | ||
strong | ||
style={{ | ||
fontSize: token.fontSizeSM, | ||
color: '#333333', | ||
textAlign: 'center', | ||
}} | ||
> | ||
{title} | ||
</Typography.Text> | ||
{description && ( | ||
<Typography.Paragraph | ||
style={{ | ||
color: token.colorTextDescription, | ||
fontSize: token.fontSize - 4, | ||
textAlign: 'center', | ||
}} | ||
> | ||
{description} | ||
</Typography.Paragraph> | ||
)} | ||
<Button | ||
{...footerButtonProps} | ||
block | ||
style={{ | ||
borderRadius: token.borderRadiusLG, | ||
}} | ||
/> | ||
</Flex> | ||
</Flex> | ||
</Card> | ||
</ConfigProvider> | ||
); | ||
}; | ||
|
||
export default BAIStartSimpleCard; |
Oops, something went wrong.