mirror of
https://github.com/zhigang1992/react.git
synced 2026-04-28 20:25:29 +08:00
44 lines
928 B
TypeScript
44 lines
928 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 FieldsetContentProps = Props & typeof defaultProps & NativeAttrs
|
|
|
|
const FieldsetContent: React.FC<React.PropsWithChildren<FieldsetContentProps>> = ({
|
|
className,
|
|
children,
|
|
...props
|
|
}) => {
|
|
const theme = useTheme()
|
|
|
|
return (
|
|
<div className={`content ${className}`} {...props}>
|
|
{children}
|
|
<style jsx>{`
|
|
.content {
|
|
padding: ${theme.layout.gap};
|
|
}
|
|
|
|
.content :global(*:first-child) {
|
|
margin-top: 0;
|
|
}
|
|
|
|
.content :global(*:last-child) {
|
|
margin-bottom: 0;
|
|
}
|
|
`}</style>
|
|
</div>
|
|
)
|
|
}
|
|
|
|
export default withDefaults(FieldsetContent, defaultProps)
|