Proyectos de Subversion LeadersLinked - SPA

Rev

Rev 2364 | Rev 2380 | Ir a la última revisión | | Comparar con el anterior | Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
2276 stevensc 1
import React from 'react'
2261 stevensc 2
import {
3
  Avatar,
4
  Card,
5
  CardActions,
6
  CardContent,
7
  CardHeader,
8
  CardMedia,
9
  styled
10
} from '@mui/material'
11
 
12
const WidgetContainer = styled(Card)(({ theme }) => ({
13
  backgroundColor: theme.palette.background.default,
2275 stevensc 14
  borderRadius: 0,
2261 stevensc 15
  boxShadow: theme.shadows[1],
16
  height: 'fit-content',
17
  position: 'relative',
18
  width: '100%',
19
  [theme.breakpoints.up('sm')]: {
20
    borderRadius: theme.shape.borderRadius
21
  }
22
}))
23
 
2268 stevensc 24
export function Widget({ children, styles, ...props }) {
25
  return (
26
    <WidgetContainer sx={styles} {...props}>
27
      {children}
28
    </WidgetContainer>
29
  )
2261 stevensc 30
}
31
 
32
export function WidgetHeader({
33
  title = '',
34
  subheader = '',
35
  avatar = '',
2276 stevensc 36
  renderAction = () => null,
2366 stevensc 37
  styles = {},
2261 stevensc 38
  ...props
39
}) {
40
  return (
41
    <CardHeader
2364 stevensc 42
      avatar={avatar ? <Avatar alt={title} src={avatar} /> : null}
2276 stevensc 43
      action={renderAction()}
2261 stevensc 44
      title={title}
45
      subheader={subheader}
2262 stevensc 46
      titleTypographyProps={{
2263 stevensc 47
        sx: { fontSize: '16px', fontWeight: 600, color: 'var(--title-color)' }
2262 stevensc 48
      }}
49
      subheaderTypographyProps={{
2263 stevensc 50
        sx: { fontSize: '14px', color: 'var(--subtitle-color)' }
2262 stevensc 51
      }}
2275 stevensc 52
      sx={{ padding: 1, paddingBottom: 0, ...styles }}
2261 stevensc 53
      {...props}
54
    />
55
  )
56
}
57
 
2366 stevensc 58
export function WidgetBody({ children, styles = {}, ...props }) {
2270 stevensc 59
  return (
2276 stevensc 60
    <CardContent
61
      sx={{ padding: 1, '&:last-child': { paddingBottom: 1 }, ...styles }}
62
      {...props}
63
    >
2270 stevensc 64
      {children}
65
    </CardContent>
66
  )
2261 stevensc 67
}
68
 
2366 stevensc 69
export function WidgetActions({ children, styles = {}, ...props }) {
2261 stevensc 70
  return (
2275 stevensc 71
    <CardActions
72
      sx={{ padding: 1, paddingTop: 0, ...styles }}
73
      disableSpacing
74
      {...props}
75
    >
2261 stevensc 76
      {children}
77
    </CardActions>
78
  )
79
}
80
 
81
export function WidgetMedia({
82
  src = '',
83
  height = 200,
84
  width = 200,
85
  alt = '',
86
  component = 'img',
2366 stevensc 87
  styles = {},
2261 stevensc 88
  ...props
89
}) {
90
  return (
91
    <CardMedia
92
      alt={alt}
93
      component={component}
94
      height={height}
95
      image={src}
96
      width={width}
2270 stevensc 97
      sx={styles}
2261 stevensc 98
      {...props}
99
    />
100
  )
101
}
102
 
103
Widget.Header = WidgetHeader
104
Widget.Body = WidgetBody
105
Widget.Actions = WidgetActions
106
Widget.Media = WidgetMedia
107
 
108
export default Widget