mirror of
https://github.com/zhigang1992/react.git
synced 2026-02-13 17:17:40 +08:00
* chore(deps): update styled-jsx to ^3.3.1 update styled-jsx to ^3.3.1 to allow compatiblity with react@^17 * fix(modules): fix 695-issue to compatible with React 17 * docs: fix module error caused by styled-jsx update Co-authored-by: unix <unix.bio@gmail.com>
44 lines
1.1 KiB
TypeScript
44 lines
1.1 KiB
TypeScript
import React from 'react'
|
|
import { css } from 'styled-jsx/css'
|
|
import GridContainer from './grid-container'
|
|
import GridBasicItem, { GridBasicItemComponentProps } from './basic-item'
|
|
|
|
interface Props {
|
|
className: string
|
|
}
|
|
|
|
const defaultProps = {
|
|
className: '',
|
|
}
|
|
|
|
export type GridProps = Props & typeof defaultProps & GridBasicItemComponentProps
|
|
|
|
const Grid: React.FC<React.PropsWithChildren<GridProps>> = ({
|
|
children,
|
|
className,
|
|
...props
|
|
}) => {
|
|
const { className: resolveClassName, styles } = css.resolve`
|
|
margin: 0;
|
|
box-sizing: border-box;
|
|
padding: var(--gaid-gap-unit);
|
|
`
|
|
return (
|
|
<GridBasicItem className={`${resolveClassName} ${className}`} {...props}>
|
|
{children}
|
|
{styles}
|
|
</GridBasicItem>
|
|
)
|
|
}
|
|
|
|
type MemoGridComponent<P = {}> = React.NamedExoticComponent<P> & {
|
|
Container: typeof GridContainer
|
|
}
|
|
type ComponentProps = Partial<typeof defaultProps> &
|
|
Omit<Props, keyof typeof defaultProps> &
|
|
GridBasicItemComponentProps
|
|
|
|
Grid.defaultProps = defaultProps
|
|
|
|
export default React.memo(Grid) as MemoGridComponent<ComponentProps>
|