Skip to content

Commit 24d47b0

Browse files
✨ Adding Grid component (#28)
Adding Grid component
2 parents e3071c8 + 4d40272 commit 24d47b0

File tree

15 files changed

+1324
-54
lines changed

15 files changed

+1324
-54
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@commitd/components",
3-
"version": "0.0.18",
3+
"version": "0.0.19",
44
"description": "Committed Component Library",
55
"author": "Committed",
66
"license": "UNLICENSED",

src/components/box/Box.tsx

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,28 @@
1-
import { FC, Ref } from 'react'
2-
import Box, { BoxProps } from '@material-ui/core/Box'
3-
export type BoxProps = BoxProps & { ref?: Ref<HTMLDivElement> }
4-
export { Box }
1+
import { FC, ComponentType, Ref } from 'react'
2+
import { styled } from '@material-ui/styles'
3+
import { compose } from '@material-ui/system'
4+
import {
5+
gridcontainer,
6+
griditem,
7+
GridcontinerProps,
8+
GriditemProps
9+
} from '../../internal'
10+
import MaterialBox, {
11+
BoxProps as MaterialBoxProps
12+
} from '@material-ui/core/Box'
13+
14+
export type BoxProps = MaterialBoxProps &
15+
Omit<GridcontinerProps, 'justifyContent' | 'alignItems'> &
16+
Omit<GriditemProps, 'justifySelf' | 'alignSelf'> & {
17+
ref?: Ref<HTMLDivElement>
18+
}
19+
20+
export const Box: ComponentType<BoxProps> = styled(MaterialBox)(
21+
compose(
22+
gridcontainer,
23+
griditem
24+
)
25+
)
526

627
// For documentation only
728
import {

src/components/grid/Grid.tsx

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import React, { FC } from 'react'
2+
import { BoxProps, Box } from '../box/Box'
3+
4+
export type GridProps = Omit<BoxProps, 'display'>
5+
6+
export type GridRef = HTMLDivElement
7+
8+
export const Grid = React.forwardRef<GridRef, GridProps>(
9+
(props: GridProps, ref) => <Box ref={ref} {...props} display="grid" />
10+
)
11+
12+
// For documentation only
13+
import {
14+
BordersProps,
15+
PaletteProps,
16+
PositionsProps,
17+
ShadowsProps,
18+
TypographyProps
19+
} from '@material-ui/system'
20+
export type GridDocsProps = BordersProps &
21+
PaletteProps &
22+
PositionsProps &
23+
ShadowsProps &
24+
TypographyProps
25+
26+
export const GridDocs: FC<GridDocsProps> = () => null

0 commit comments

Comments
 (0)