-
Notifications
You must be signed in to change notification settings - Fork 0
/
Grid.tsx
35 lines (32 loc) · 926 Bytes
/
Grid.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import * as React from 'react';
import * as classnames from 'classnames';
export type Alignment = 'left' | 'right';
export interface GridProps<T> extends React.HTMLProps<T> {
align?: Alignment,
className?: string,
fixedColumnWidth?: boolean,
tag?: string
};
const Grid: <T extends {} = HTMLDivElement>(props: GridProps<T>) => React.ReactElement<any> = ({
/* eslint-disable react/prop-types */
align,
children,
className = '',
fixedColumnWidth = false,
tag: Tag = 'div',
/* eslint-enable react/prop-types */
...otherProps
}) => {
const classes = classnames('mdc-layout-grid', className, {
[`mdc-layout-grid--align-${align}`]: !!align,
'mdc-layout-grid--fixed-column-width': fixedColumnWidth,
});
return (
// https://github.com/Microsoft/TypeScript/issues/28892
// @ts-ignore
<Tag className={classes} {...otherProps}>
{children}
</Tag>
);
};
export default Grid;