mirror of
https://github.com/zhigang1992/react.git
synced 2026-04-28 20:25:29 +08:00
38 lines
882 B
TypeScript
38 lines
882 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<HTMLHeadingElement>, keyof Props>
|
|
export type FieldsetSubtitleProps = Props & typeof defaultProps & NativeAttrs
|
|
|
|
const FieldsetSubtitle: React.FC<FieldsetSubtitleProps> = ({ className, children, ...props }) => {
|
|
const theme = useTheme()
|
|
|
|
return (
|
|
<>
|
|
<p className={className} {...props}>
|
|
{children}
|
|
</p>
|
|
<style jsx>{`
|
|
p {
|
|
font-size: 0.875rem;
|
|
line-height: 1.6;
|
|
margin: ${theme.layout.gapHalf} 0;
|
|
}
|
|
`}</style>
|
|
</>
|
|
)
|
|
}
|
|
|
|
const MemoFieldsetSubtitle = React.memo(FieldsetSubtitle)
|
|
|
|
export default withDefaults(MemoFieldsetSubtitle, defaultProps)
|