Newer
Older
import React, { ReactNode } from 'react'
import CardActionArea, {
CardActionAreaProps,
} from '@material-ui/core/CardActionArea'
import CardContent from '@material-ui/core/CardContent'
import { withStyles } from '@material-ui/core/styles'
import { FluidType } from 'enum/fluid.enum'
const CardBase = withStyles({
root: {
background: 'linear-gradient(180deg, #323339 0%, #25262B 100%)',
boxSizing: 'border-box',
borderRadius: '4px',
margin: '10px 0px 20px 0px',
},
})(CardActionArea)
const CardElec = withStyles({
root: {
},
})(CardBase)
const CardWater = withStyles({
root: {
},
})(CardBase)
const CardGas = withStyles({
root: {
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
},
})(CardBase)
const CardContentBase = withStyles({
root: {
color: 'white',
},
})(CardContent)
interface StyledCardProps extends CardActionAreaProps {
fluidType?: FluidType
}
const GenerateContentCard = (
fluidType: FluidType,
children: ReactNode
): React.ReactFragment => {
return <CardContentBase>{children}</CardContentBase>
}
const StyledCard: React.ComponentType<StyledCardProps> = ({
fluidType,
...props
}: StyledCardProps) => {
switch (fluidType) {
case FluidType.ELECTRICITY:
return (
<CardElec {...props}>
{GenerateContentCard(fluidType, props.children)}
</CardElec>
)
case FluidType.WATER:
return (
<CardWater {...props}>
{GenerateContentCard(fluidType, props.children)}
</CardWater>
)
case FluidType.GAS:
return (
<CardGas {...props}>
{GenerateContentCard(fluidType, props.children)}
</CardGas>
)
default:
return (
<CardBase {...props}>
<CardContentBase>{props.children}</CardContentBase>
</CardBase>
)
}
}
export default StyledCard