Created
March 25, 2019 19:42
-
-
Save schabluk/6999e07cd44233da751e12a0f03ccd37 to your computer and use it in GitHub Desktop.
Collapsible CSS Grid
This file contains hidden or 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
const GridSpace = styled.section` | |
height: 100%; | |
display: grid; | |
grid-template-columns: repeat(4, 1fr); | |
grid-template-rows: auto fit-content(100%); | |
grid-template-areas: | |
'c c c c' | |
't t t t'; | |
` | |
const GridChart = styled.div` | |
background-color: #ccc; | |
grid-area: c; | |
display: flex; | |
flex-direction: column; | |
` | |
const GridTable = styled.div` | |
background-color: #ddd; | |
grid-area: t; | |
display: flex; | |
flex-direction: column; | |
` | |
const DataGrid = props => { | |
const [expanded, setExpanded] = React.useState(true) | |
return ( | |
<GridSpace> | |
<GridChart> | |
Grid Chart | |
</GridChart> | |
<GridTable> | |
<Button size='small' color='primary' onClick={e => setExpanded(!expanded)}> | |
{expanded ? 'Close' : 'Open'} | |
</Button> | |
{expanded && <p>Grid Table</p>} | |
</GridTable> | |
</GridSpace> | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment