mirror of
https://github.com/zhigang1992/react.git
synced 2026-04-28 12:15:32 +08:00
37 lines
776 B
TypeScript
37 lines
776 B
TypeScript
import React from 'react'
|
|
import useTheme from '../styles/use-theme'
|
|
import withDefaults from '../utils/with-defaults'
|
|
|
|
interface Props {
|
|
className?: string
|
|
}
|
|
|
|
const defaultProps = {
|
|
className: '',
|
|
}
|
|
|
|
type NativeAttrs = Omit<React.HTMLAttributes<any>, keyof Props>
|
|
export type PageContentProps = Props & typeof defaultProps & NativeAttrs
|
|
|
|
const PageContent: React.FC<React.PropsWithChildren<PageContentProps>> = ({
|
|
className,
|
|
children,
|
|
...props
|
|
}) => {
|
|
const theme = useTheme()
|
|
|
|
return (
|
|
<main className={className} {...props}>
|
|
{children}
|
|
<style jsx>{`
|
|
main {
|
|
width: 100%;
|
|
padding: calc(${theme.layout.gap} * 2.5) 0;
|
|
}
|
|
`}</style>
|
|
</main>
|
|
)
|
|
}
|
|
|
|
export default withDefaults(PageContent, defaultProps)
|