1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-01-25 00:07:47 +01:00
unleash.unleash/frontend/src/component/project/Project/ProjectInfo/MetaWidget.tsx

65 lines
2.1 KiB
TypeScript
Raw Normal View History

2023-01-27 13:00:23 +01:00
import { FC } from 'react';
2023-02-03 12:58:21 +01:00
import { styled, Typography } from '@mui/material';
2023-01-27 13:00:23 +01:00
import {
StyledProjectInfoWidgetContainer,
StyledWidgetTitle,
} from './ProjectInfo.styles';
import { ConditionallyRender } from 'component/common/ConditionallyRender/ConditionallyRender';
2023-02-03 12:58:21 +01:00
import { WidgetFooterLink } from './WidgetFooterLink';
2023-01-27 13:00:23 +01:00
interface IMetaWidgetProps {
id?: string;
description?: string;
}
const StyledIDContainer = styled('div')(({ theme }) => ({
textAlign: 'left',
borderRadius: `${theme.shape.borderRadius}px`,
backgroundColor: `${theme.palette.background.elevation2}`,
2023-01-27 13:00:23 +01:00
padding: theme.spacing(0.5, 2),
fontSize: theme.typography.body2.fontSize,
}));
export const MetaWidget: FC<IMetaWidgetProps> = ({ id, description }) => {
return (
<StyledProjectInfoWidgetContainer>
<StyledWidgetTitle data-loading>Project Meta</StyledWidgetTitle>
<StyledIDContainer data-loading>
2023-01-27 13:00:23 +01:00
<Typography
component='span'
variant='body2'
color='text.secondary'
2023-01-27 13:00:23 +01:00
>
ID:
</Typography>{' '}
<code data-loading>{id || '__________'}</code>
</StyledIDContainer>
2023-02-03 12:58:21 +01:00
<ConditionallyRender
condition={Boolean(description)}
show={
<Typography
data-loading
variant='body2'
2023-02-03 12:58:21 +01:00
sx={{
marginTop: (theme) => theme.spacing(1.5),
2023-02-03 12:58:21 +01:00
marginBottom: 0,
textAlign: 'left',
}}
>
{description}
</Typography>
}
/>
<ConditionallyRender
condition={!description}
2023-02-03 12:58:21 +01:00
show={
<WidgetFooterLink to={`/projects/${id}/settings`}>
2023-02-03 12:58:21 +01:00
Add description
</WidgetFooterLink>
}
/>
2023-01-27 13:00:23 +01:00
</StyledProjectInfoWidgetContainer>
);
};