Skip to content

Commit 5e90231

Browse files
committed
feat: add DashboardWidgets module with various components and utilities for enhanced dashboard
Signed-off-by: amitamrutiya <amitamrutiya2210@gmail.com>
1 parent 4e8f1fe commit 5e90231

6 files changed

Lines changed: 614 additions & 0 deletions

File tree

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
import { Box, Card, CardContent, Link, Typography } from '../../base';
2+
import { OpenInNewIcon } from '../../icons';
3+
import { styled } from '../../theme';
4+
5+
const StyledCard = styled(Card)(({ theme }) => ({
6+
minWidth: 275,
7+
height: '100%',
8+
backgroundColor:
9+
theme.palette.mode === 'dark' ? theme.palette.background.card : theme.palette.common.white
10+
}));
11+
12+
const StyledTitleBox = styled(Box)({
13+
display: 'flex',
14+
alignItems: 'center',
15+
gap: '0.5rem'
16+
});
17+
18+
const StyledContentBox = styled(Box)({
19+
display: 'flex',
20+
flexDirection: 'column'
21+
});
22+
23+
const StyledResourceList = styled('ul')({
24+
paddingLeft: '1rem'
25+
});
26+
27+
const ResourceListItem = styled('li')({
28+
listStyleType: 'none',
29+
display: 'flex',
30+
flexDirection: 'row',
31+
alignItems: 'center'
32+
});
33+
34+
const StyledResourceIcon = styled('img')({
35+
width: '12px',
36+
height: '12px',
37+
marginRight: '.25rem'
38+
});
39+
40+
const StyledResourceLink = styled(Link)({
41+
fontSize: '1rem',
42+
fontWeight: '400',
43+
marginRight: '0.25rem',
44+
textDecoration: 'none'
45+
});
46+
47+
interface Resource {
48+
name: string;
49+
link: string;
50+
icon?: string;
51+
external?: boolean;
52+
}
53+
54+
interface PlainCardProps {
55+
title: string;
56+
icon: React.ReactNode;
57+
resources: Resource[];
58+
}
59+
60+
export const PlainCard = ({ title, icon, resources }: PlainCardProps): JSX.Element => {
61+
return (
62+
<>
63+
<StyledCard>
64+
<CardContent>
65+
<StyledTitleBox>
66+
{icon}
67+
<Typography variant="h6" fontWeight="700">
68+
{title}
69+
</Typography>
70+
</StyledTitleBox>
71+
<StyledContentBox>
72+
<StyledResourceList>
73+
{resources.map((item) => (
74+
<ResourceListItem key={item.link}>
75+
{item.icon && (
76+
<StyledResourceIcon src={item.icon} alt={`Icon for ${item.name}`} />
77+
)}
78+
<StyledResourceLink
79+
href={item.link}
80+
target={item.external ? '_blank' : '_self'}
81+
rel={item.external ? 'noopener noreferrer' : ''}
82+
>
83+
{item.name}
84+
</StyledResourceLink>
85+
86+
{item.external && (
87+
<sup>
88+
<OpenInNewIcon width="12px" height="12px" fill={'white'} />
89+
</sup>
90+
)}
91+
</ResourceListItem>
92+
))}
93+
</StyledResourceList>
94+
</StyledContentBox>
95+
</CardContent>
96+
</StyledCard>
97+
</>
98+
);
99+
};

0 commit comments

Comments
 (0)