mirror of
https://github.com/zhigang1992/react.git
synced 2026-02-06 17:19:02 +08:00
* 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
74 lines
1.9 KiB
TypeScript
74 lines
1.9 KiB
TypeScript
import React, { ReactNode } from 'react'
|
|
import useTheme from '../use-theme'
|
|
import useScaleable, { withScaleable } from '../use-scaleable'
|
|
|
|
interface Props {
|
|
title?: ReactNode | string
|
|
content?: ReactNode | string
|
|
className?: string
|
|
}
|
|
|
|
const defaultProps = {
|
|
title: 'Title' as ReactNode | string,
|
|
content: '' as ReactNode | string,
|
|
className: '',
|
|
}
|
|
|
|
type NativeAttrs = Omit<React.HTMLAttributes<any>, keyof Props>
|
|
export type DescriptionProps = Props & NativeAttrs
|
|
|
|
const DescriptionComponent: React.FC<DescriptionProps> = ({
|
|
title,
|
|
content,
|
|
className,
|
|
...props
|
|
}: DescriptionProps & typeof defaultProps) => {
|
|
const theme = useTheme()
|
|
const { SCALES } = useScaleable()
|
|
return (
|
|
<dl className={`description ${className}`} {...props}>
|
|
<dt>{title}</dt>
|
|
<dd>{content}</dd>
|
|
|
|
<style jsx>{`
|
|
.description {
|
|
font-size: ${SCALES.font(1)};
|
|
width: ${SCALES.width(1, 'auto')};
|
|
height: ${SCALES.height(1, 'auto')};
|
|
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)};
|
|
}
|
|
|
|
dt {
|
|
font-size: 0.75em;
|
|
line-height: 1em;
|
|
margin-bottom: 0.5em;
|
|
text-transform: uppercase;
|
|
white-space: nowrap;
|
|
color: ${theme.palette.accents_5};
|
|
font-weight: 500;
|
|
display: flex;
|
|
}
|
|
|
|
dd {
|
|
font-size: 0.875em;
|
|
margin: 0;
|
|
line-height: 1.1em;
|
|
color: ${theme.palette.foreground};
|
|
font-weight: 500;
|
|
}
|
|
|
|
dd :global(p),
|
|
dt :global(p) {
|
|
margin: 0;
|
|
}
|
|
`}</style>
|
|
</dl>
|
|
)
|
|
}
|
|
|
|
DescriptionComponent.defaultProps = defaultProps
|
|
DescriptionComponent.displayName = 'GeistDescription'
|
|
const Description = withScaleable(DescriptionComponent)
|
|
export default Description
|