asb_cloud_front/src/components/Grid.jsx

32 lines
760 B
React
Raw Normal View History

export const Grid = ({children, ...other}) => {
const gridContainerStyle = {
display: 'grid',
2021-09-03 09:26:20 +05:00
margin: '8px',
justifyItems: 'stretch',
alignItems: 'stretch',
...other,
}
return <div style={gridContainerStyle}>
{children}
</div>
}
export const GridItem = ({children, row, col, rowSpan, colSpan, ...other}) => {
const localRow = +row
const localCol = +col
const localColSpan = colSpan ? colSpan - 1 : 0
const localRowSpan = rowSpan ? rowSpan - 1 : 0
const gridItemStyle = {
gridColumnStart: localCol,
gridColumnEnd: localCol + localColSpan,
gridRowStart: localRow,
gridRowEnd: localRow + localRowSpan,
2021-09-03 09:26:20 +05:00
padding: '4px',
...other,
}
return <div style={gridItemStyle}>
{children}
</div>
}