react-code-dataset / react-material-dashboard /src /components /dashboard /overview /total-customers.tsx
| import * as React from 'react'; | |
| import Avatar from '@mui/material/Avatar'; | |
| import Card from '@mui/material/Card'; | |
| import CardContent from '@mui/material/CardContent'; | |
| import Stack from '@mui/material/Stack'; | |
| import type { SxProps } from '@mui/material/styles'; | |
| import Typography from '@mui/material/Typography'; | |
| import { ArrowDownIcon } from '@phosphor-icons/react/dist/ssr/ArrowDown'; | |
| import { ArrowUpIcon } from '@phosphor-icons/react/dist/ssr/ArrowUp'; | |
| import { UsersIcon } from '@phosphor-icons/react/dist/ssr/Users'; | |
| export interface TotalCustomersProps { | |
| diff?: number; | |
| trend: 'up' | 'down'; | |
| sx?: SxProps; | |
| value: string; | |
| } | |
| export function TotalCustomers({ diff, trend, sx, value }: TotalCustomersProps): React.JSX.Element { | |
| const TrendIcon = trend === 'up' ? ArrowUpIcon : ArrowDownIcon; | |
| const trendColor = trend === 'up' ? 'var(--mui-palette-success-main)' : 'var(--mui-palette-error-main)'; | |
| return ( | |
| <Card sx={sx}> | |
| <CardContent> | |
| <Stack spacing={2}> | |
| <Stack direction="row" sx={{ alignItems: 'flex-start', justifyContent: 'space-between' }} spacing={3}> | |
| <Stack spacing={1}> | |
| <Typography color="text.secondary" variant="overline"> | |
| Total Customers | |
| </Typography> | |
| <Typography variant="h4">{value}</Typography> | |
| </Stack> | |
| <Avatar sx={{ backgroundColor: 'var(--mui-palette-success-main)', height: '56px', width: '56px' }}> | |
| <UsersIcon fontSize="var(--icon-fontSize-lg)" /> | |
| </Avatar> | |
| </Stack> | |
| {diff ? ( | |
| <Stack sx={{ alignItems: 'center' }} direction="row" spacing={2}> | |
| <Stack sx={{ alignItems: 'center' }} direction="row" spacing={0.5}> | |
| <TrendIcon color={trendColor} fontSize="var(--icon-fontSize-md)" /> | |
| <Typography color={trendColor} variant="body2"> | |
| {diff}% | |
| </Typography> | |
| </Stack> | |
| <Typography color="text.secondary" variant="caption"> | |
| Since last month | |
| </Typography> | |
| </Stack> | |
| ) : null} | |
| </Stack> | |
| </CardContent> | |
| </Card> | |
| ); | |
| } | |