mirror of
https://github.com/zhigang1992/react.git
synced 2026-04-26 13:25:46 +08:00
46 lines
1.1 KiB
TypeScript
46 lines
1.1 KiB
TypeScript
import React from 'react'
|
|
import withDefaults from '../utils/with-defaults'
|
|
import useTheme from '../styles/use-theme'
|
|
|
|
interface Props {
|
|
className?: string
|
|
}
|
|
|
|
const defaultProps = {
|
|
className: '',
|
|
}
|
|
|
|
type NativeAttrs = Omit<React.HTMLAttributes<HTMLElement>, keyof Props>
|
|
export type ModalContentProps = Props & typeof defaultProps & NativeAttrs
|
|
|
|
const ModalContent: React.FC<ModalContentProps> = ({ className, children, ...props }) => {
|
|
const theme = useTheme()
|
|
|
|
return (
|
|
<>
|
|
<div className={`content ${className}`} {...props}>
|
|
{children}
|
|
</div>
|
|
<style jsx>{`
|
|
.content {
|
|
margin: 0 -${theme.layout.gap};
|
|
padding: ${theme.layout.gap} ${theme.layout.gap} ${theme.layout.gapHalf};
|
|
overflow-y: auto;
|
|
}
|
|
|
|
.content > :global(*:first-child) {
|
|
margin-top: 0;
|
|
}
|
|
|
|
.content > :global(*:last-child) {
|
|
margin-bottom: 0;
|
|
}
|
|
`}</style>
|
|
</>
|
|
)
|
|
}
|
|
|
|
const MemoModalContent = React.memo(ModalContent)
|
|
|
|
export default withDefaults(MemoModalContent, defaultProps)
|