Files
react/components/modal/modal-subtitle.tsx
witt 7facec3849 feat(scaleable): add scaleable props to each component (#531)
* feat(scaleable): add scaleable props to each component

* chore(scaleable): update the exported type

* feat: apply scaleable to components

chore: remove with-default

test: improve testcase for scaleable

chore: resolve test warning

ci: upgrade nodejs to latest lts

docs: fix type error in document site

* docs: update documents to be compatible with scaleable

chore: fix build errors

* chore: remove all size-related attributes

docs: improve guide document

* docs: add scaleable documentation

test: update snapshots

chore: remove unused

* feat: add scaleable to grid components

* docs: improve docs

* test: update snapshots

* fix(grid): fix basic component props
2021-08-13 17:10:57 +08:00

53 lines
1.5 KiB
TypeScript

import React from 'react'
import useTheme from '../use-theme'
import useScaleable, { withScaleable } from '../use-scaleable'
interface Props {
className?: string
}
const defaultProps = {
className: '',
}
type NativeAttrs = Omit<React.HTMLAttributes<HTMLHeadingElement>, keyof Props>
export type ModalSubtitleProps = Props & NativeAttrs
const ModalSubtitleComponent: React.FC<React.PropsWithChildren<ModalSubtitleProps>> = ({
className,
children,
...props
}: React.PropsWithChildren<ModalSubtitleProps> & typeof defaultProps) => {
const theme = useTheme()
const { SCALES } = useScaleable()
return (
<>
<p className={className} {...props}>
{children}
</p>
<style jsx>{`
p {
font-weight: normal;
display: inline-block;
text-align: center;
word-break: break-word;
text-transform: uppercase;
color: ${theme.palette.accents_5};
font-size: ${SCALES.font(0.875)};
line-height: 1.5em;
width: ${SCALES.width(1, 'auto')};
height: ${SCALES.height(1, '1.5em')};
padding: ${SCALES.pt(0)} ${SCALES.pr(0)} ${SCALES.pb(0)} ${SCALES.pl(0)};
margin: ${SCALES.mt(0)} ${SCALES.mr(0)} ${SCALES.mb(0)} ${SCALES.ml(0)};
}
`}</style>
</>
)
}
ModalSubtitleComponent.defaultProps = defaultProps
ModalSubtitleComponent.displayName = 'GeistModalSubtitle'
const ModalSubtitle = withScaleable(ModalSubtitleComponent)
export default ModalSubtitle