|
9 | 9 | ********************************************************************************/ |
10 | 10 |
|
11 | 11 | import React, { FunctionComponent, PropsWithChildren } from 'react'; |
12 | | -import { Box, Paper, Card, Grid, Button, Divider, CardActions, CardContent, Hidden, Collapse } from '@mui/material'; |
| 12 | +import { Paper, Grid, Button, Collapse } from '@mui/material'; |
13 | 13 |
|
14 | 14 | export const Banner: FunctionComponent<PropsWithChildren<BannerProps>> = props => { |
15 | | - const renderButtons = <> |
16 | | - <Box sx={{ flexGrow: 1 }} component='span'/> |
17 | | - <Grid item sx={{ whiteSpace: 'nowrap', alignSelf: 'flex-end', paddingLeft: '90px !important' }}> |
18 | | - <Button |
19 | | - variant='outlined' |
20 | | - onClick={props.dismissButtonOnClick} |
21 | | - > |
22 | | - {props.dismissButtonLabel ?? 'Close'} |
23 | | - </Button> |
24 | | - </Grid> |
25 | | - </>; |
26 | | - |
27 | 15 | const cardColor = props.theme === 'dark' ? '#fff' : '#000'; |
28 | 16 | const cardBackground = `${props.color}.${props.theme}`; |
29 | 17 | return <> |
30 | 18 | <Collapse in={props.open}> |
31 | | - <Paper elevation={0} sx={{ display: 'block', width: '100%', mx: 'auto' }}> |
32 | | - <Card |
33 | | - elevation={0} |
34 | | - sx={{ |
| 19 | + <Paper |
| 20 | + elevation={0} |
| 21 | + sx={{ |
| 22 | + display: 'block', |
| 23 | + width: '100%', |
| 24 | + mx: 'auto', |
| 25 | + pb: 1, pr: 1, pl: 2, pt: 1.25, |
| 26 | + color: cardColor, |
| 27 | + bgcolor: cardBackground, |
| 28 | + '& a': { |
35 | 29 | color: cardColor, |
36 | | - bgcolor: cardBackground, |
37 | | - '& a': { |
38 | | - color: cardColor, |
39 | | - fontWeight: 'bold' |
40 | | - } |
41 | | - }} |
| 30 | + fontWeight: 'bold' |
| 31 | + } |
| 32 | + }} |
| 33 | + > |
| 34 | + <Grid |
| 35 | + container |
| 36 | + spacing={2} |
42 | 37 | > |
43 | | - <CardContent sx={{ pb: 1, pr: 1, pl: 2, pt: 1.25 }}> |
44 | | - <Grid |
45 | | - container |
46 | | - wrap='nowrap' |
47 | | - spacing={2} |
48 | | - direction='row' |
49 | | - justifyContent='flex-start' |
50 | | - alignItems='flex-start' |
51 | | - > |
52 | | - <Grid item sx={{ alignSelf: 'center' }}> |
53 | | - {props.children} |
54 | | - </Grid> |
55 | | - { |
56 | | - props.showDismissButton ? |
57 | | - <Hidden smDown> |
58 | | - {renderButtons} |
59 | | - </Hidden> : null |
60 | | - } |
61 | | - </Grid> |
62 | | - </CardContent> |
| 38 | + <Grid item xs={12} sm sx={{ alignSelf: 'center' }}> |
| 39 | + {props.children} |
| 40 | + </Grid> |
63 | 41 | { |
64 | | - props.showDismissButton ? |
65 | | - <> |
66 | | - <Hidden mdUp> |
67 | | - <CardActions> |
68 | | - {renderButtons} |
69 | | - </CardActions> |
70 | | - </Hidden> |
71 | | - |
72 | | - <Hidden smDown> |
73 | | - <div /> |
74 | | - </Hidden> |
75 | | - </> : null |
| 42 | + props.showDismissButton && |
| 43 | + <Grid item xs={12} sm='auto' sx={{ whiteSpace: 'nowrap', alignSelf: 'flex-end', paddingLeft: '90px !important' }}> |
| 44 | + <Button |
| 45 | + sx={{ float: 'right' }} |
| 46 | + variant='outlined' |
| 47 | + onClick={props.dismissButtonOnClick} |
| 48 | + > |
| 49 | + {props.dismissButtonLabel ?? 'Close'} |
| 50 | + </Button> |
| 51 | + </Grid> |
76 | 52 | } |
77 | | - </Card> |
78 | | - |
79 | | - <Divider /> |
| 53 | + </Grid> |
80 | 54 | </Paper> |
81 | 55 | </Collapse> |
82 | 56 | </>; |
|
0 commit comments