-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Definitions are centred in the box, it looks better when the definition is short
- Loading branch information
1 parent
05d9adf
commit 05e298c
Showing
1 changed file
with
47 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,56 +1,63 @@ | ||
import React, {ReactElement} from "react"; | ||
import {Box, BoxProps, Container, Grid, Typography} from "@material-ui/core"; | ||
import {makeStyles} from "@material-ui/core/styles"; | ||
import React, { ReactElement } from "react"; | ||
import { Box, BoxProps, Container, Grid, Typography } from "@material-ui/core"; | ||
import { makeStyles } from "@material-ui/core/styles"; | ||
|
||
interface DefinitionWrapperProps { | ||
definition?: string; | ||
source?: string; | ||
illustration: ReactElement; | ||
definition?: string; | ||
source?: string; | ||
illustration: ReactElement; | ||
} | ||
|
||
const defaultProps = { | ||
borderColor: "primary.main", | ||
minHeight: 144, | ||
px: 3, | ||
py: 2, | ||
border: 2, | ||
borderRadius: 16, | ||
borderColor: "primary.main", | ||
minHeight: 144, | ||
px: 3, | ||
py: 2, | ||
border: 2, | ||
borderRadius: 16, | ||
}; | ||
|
||
const useStyles = makeStyles((theme) => ({ | ||
definitionImageWrapper: { | ||
[theme.breakpoints.down("xs")]: { | ||
display: "none", | ||
}, | ||
definitionImageWrapper: { | ||
[theme.breakpoints.down("xs")]: { | ||
display: "none", | ||
}, | ||
}, | ||
})); | ||
|
||
const DefinitionWrapper: React.FC<DefinitionWrapperProps & BoxProps> = (props) => { | ||
const classes = useStyles(); | ||
const DefinitionWrapper: React.FC<DefinitionWrapperProps & BoxProps> = ( | ||
props | ||
) => { | ||
const classes = useStyles(); | ||
|
||
return ( | ||
<Container> | ||
<Box px={2} mt={4}> | ||
<Grid container> | ||
<Grid item sm={10} xs={12}> | ||
<Box {...defaultProps}> | ||
<Box mb={2}> | ||
<Typography variant="h6">{props.definition}</Typography> | ||
</Box> | ||
{props.source && ( | ||
<Box fontStyle="italic" color="text.disabled"> | ||
<Typography variant="body1">{props.source}</Typography> | ||
</Box> | ||
)} | ||
</Box> | ||
</Grid> | ||
<Grid item sm={2} className={classes.definitionImageWrapper}> | ||
{props.illustration} | ||
</Grid> | ||
</Grid> | ||
return ( | ||
<Container> | ||
<Box px={2} mt={4}> | ||
<Grid container> | ||
<Grid item sm={10} xs={12}> | ||
<Box | ||
{...defaultProps} | ||
display="flex" | ||
flexDirection="column" | ||
justifyContent="center" | ||
> | ||
<Box mb={props.source ? 2 : 0}> | ||
<Typography variant="h6">{props.definition}</Typography> | ||
</Box> | ||
{props.source && ( | ||
<Box fontStyle="italic" color="text.disabled"> | ||
<Typography variant="body1">{props.source}</Typography> | ||
</Box> | ||
)} | ||
</Box> | ||
</Container> | ||
); | ||
</Grid> | ||
<Grid item sm={2} className={classes.definitionImageWrapper}> | ||
{props.illustration} | ||
</Grid> | ||
</Grid> | ||
</Box> | ||
</Container> | ||
); | ||
}; | ||
|
||
export default DefinitionWrapper; |