Skip to content

Commit cf3950a

Browse files
Migrate Styled-Card
Signed-off-by: Rajesh-Nagarajan-11 <rajeshnagarajan36@gmail.com>
1 parent d919473 commit cf3950a

File tree

3 files changed

+129
-0
lines changed

3 files changed

+129
-0
lines changed
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
import React from 'react';
2+
import { SxProps, Theme } from '@mui/material';
3+
import { Box, Button, Card, CardActions, CardContent, Typography } from '../../base';
4+
5+
export interface StyledCardProps {
6+
title: string;
7+
icon?: React.ReactNode;
8+
children: React.ReactNode;
9+
sx?: SxProps<Theme>;
10+
btntitle?: string;
11+
onclick?: () => void;
12+
disabled?: boolean;
13+
}
14+
15+
function StyledCard({
16+
title,
17+
icon,
18+
children,
19+
sx = {},
20+
btntitle,
21+
onclick,
22+
disabled = false
23+
}: StyledCardProps): JSX.Element {
24+
return (
25+
<Card sx={{ height: '100%', ...sx }}>
26+
<CardContent>
27+
<div
28+
style={{
29+
display: 'flex',
30+
justifyContent: 'space-between'
31+
}}
32+
>
33+
<Box
34+
sx={{
35+
display: 'flex',
36+
mb: 1.5
37+
}}
38+
>
39+
{icon}
40+
<Typography variant="h6" fontWeight="700" component="div" sx={{ mx: 1 }}>
41+
{title}
42+
</Typography>
43+
</Box>
44+
{btntitle && (
45+
<CardActions>
46+
<Button variant="contained" size='large' onClick={onclick} disabled={disabled}>
47+
{btntitle}
48+
</Button>
49+
</CardActions>
50+
)}
51+
</div>
52+
53+
{children}
54+
</CardContent>
55+
</Card>
56+
);
57+
}
58+
59+
export default StyledCard;

src/custom/StyledCard/index.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import StyledCard from './StyledCard';
2+
3+
export { StyledCard };

src/custom/StyledCard/style.tsx

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
import { styled } from '@mui/material';
2+
import { Link, ListItem } from '../../base';
3+
4+
export const backgroundImg = styled('div')<{ backgroundImage?: string }>(
5+
({ backgroundImage }) => ({
6+
backgroundImage: backgroundImage ? `url(${backgroundImage})` : 'none',
7+
backgroundPosition: 'right bottom',
8+
backgroundSize: 'cover',
9+
backgroundRepeat: 'no-repeat'
10+
})
11+
);
12+
13+
export const CustomCode = styled('code')(() => ({
14+
backgroundColor: '#212121',
15+
color: '#fff',
16+
padding: '0.2rem 0.4rem',
17+
borderRadius: '0.2rem'
18+
}));
19+
20+
export const List = styled(ListItem)<{ iconSrc?: string }>(({ iconSrc }) => ({
21+
listStyleImage: iconSrc ? `url(${iconSrc})` : 'none',
22+
display: 'flex',
23+
alignItems: 'flex-start'
24+
}));
25+
26+
export const CustomLink = styled('a')(({ theme }) => ({
27+
color: theme.palette.text.secondary,
28+
textDecoration: 'none',
29+
'&:visited': {
30+
textDecoration: 'none'
31+
},
32+
'&:hover': {
33+
textDecoration: 'underline'
34+
},
35+
fontWeight: 'bold'
36+
}));
37+
38+
export const MUILink = styled(Link)(() => ({
39+
color: '#455a64',
40+
textDecoration: 'none',
41+
'&:visited': {
42+
textDecoration: 'none'
43+
},
44+
'&:hover': {
45+
textDecoration: 'none',
46+
cursor: 'pointer'
47+
},
48+
fontWeight: '600'
49+
}));
50+
51+
export const CustomLinkDiv = styled('div')(() => ({
52+
display: 'block',
53+
width: '10rem',
54+
whiteSpace: 'nowrap',
55+
overflow: 'hidden',
56+
textOverflow: 'ellipsis'
57+
}));
58+
59+
export const CustomDisabledLink = styled('a')(() => ({
60+
textDecoration: 'none',
61+
color: '#455a64',
62+
'&:visited': {
63+
textDecoration: 'none'
64+
},
65+
opacity: '0.5',
66+
cursor: 'not-allowed'
67+
}));

0 commit comments

Comments
 (0)