1
1
import Box from "@material-ui/core/Box"
2
- import Button , { ButtonProps } from "@material-ui/core/Button"
3
2
import { makeStyles } from "@material-ui/core/styles"
4
3
import Typography from "@material-ui/core/Typography"
5
4
import React from "react"
@@ -8,8 +7,8 @@ export interface EmptyStateProps {
8
7
/** Text Message to display, placed inside Typography component */
9
8
message : string
10
9
/** Longer optional description to display below the message */
11
- description ?: React . ReactNode
12
- button ?: ButtonProps
10
+ description ?: string
11
+ cta ?: React . ReactNode
13
12
}
14
13
15
14
/**
@@ -21,17 +20,22 @@ export interface EmptyStateProps {
21
20
* that you can directly pass props through to to customize the shape and layout of it.
22
21
*/
23
22
export const EmptyState : React . FC < EmptyStateProps > = ( props ) => {
24
- const { message, description, button , ...boxProps } = props
23
+ const { message, description, cta , ...boxProps } = props
25
24
const styles = useStyles ( )
26
- const buttonClassName = `${ styles . button } ${ button && button . className ? button . className : "" } `
27
25
28
26
return (
29
27
< Box className = { styles . root } { ...boxProps } >
30
- < Typography variant = "h5" color = "textSecondary" className = { styles . header } >
31
- { message }
32
- </ Typography >
33
- { description && < div className = { styles . description } > { description } </ div > }
34
- { button && < Button variant = "contained" color = "primary" { ...button } className = { buttonClassName } /> }
28
+ < div className = { styles . header } >
29
+ < Typography variant = "h5" className = { styles . title } >
30
+ { message }
31
+ </ Typography >
32
+ { description && (
33
+ < Typography variant = "body2" color = "textSecondary" className = { styles . description } >
34
+ { description }
35
+ </ Typography >
36
+ ) }
37
+ </ div >
38
+ { cta }
35
39
</ Box >
36
40
)
37
41
}
@@ -48,22 +52,13 @@ const useStyles = makeStyles(
48
52
padding : theme . spacing ( 3 ) ,
49
53
} ,
50
54
header : {
55
+ marginBottom : theme . spacing ( 3 ) ,
56
+ } ,
57
+ title : {
51
58
fontWeight : 400 ,
52
59
} ,
53
60
description : {
54
- marginTop : theme . spacing ( 2 ) ,
55
- marginBottom : theme . spacing ( 1 ) ,
56
- color : theme . palette . text . secondary ,
57
- fontSize : theme . typography . body2 . fontSize ,
58
- } ,
59
- button : {
60
- marginTop : theme . spacing ( 2 ) ,
61
- } ,
62
- icon : {
63
- fontSize : theme . typography . h2 . fontSize ,
64
- color : theme . palette . text . secondary ,
65
- marginBottom : theme . spacing ( 1 ) ,
66
- opacity : 0.5 ,
61
+ marginTop : theme . spacing ( 1 ) ,
67
62
} ,
68
63
} ) ,
69
64
{ name : "EmptyState" } ,
0 commit comments