mirror of
https://github.com/zhigang1992/react.git
synced 2026-04-28 12:15:32 +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
43 lines
1.1 KiB
TypeScript
43 lines
1.1 KiB
TypeScript
import React from 'react'
|
|
import useScaleable, { withScaleable } from '../use-scaleable'
|
|
|
|
interface Props {
|
|
inline?: boolean
|
|
className?: string
|
|
}
|
|
|
|
const defaultProps = {
|
|
inline: false,
|
|
className: '',
|
|
}
|
|
|
|
type NativeAttrs = Omit<React.HTMLAttributes<any>, keyof Props>
|
|
export type SpacerProps = Props & NativeAttrs
|
|
|
|
const SpacerComponent: React.FC<SpacerProps> = ({
|
|
inline,
|
|
className,
|
|
...props
|
|
}: SpacerProps & typeof defaultProps) => {
|
|
const { SCALES } = useScaleable()
|
|
|
|
return (
|
|
<span className={className} {...props}>
|
|
<style jsx>{`
|
|
span {
|
|
display: ${inline ? 'inline-block' : 'block'};
|
|
width: ${SCALES.width(1)};
|
|
height: ${SCALES.height(1)};
|
|
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>
|
|
</span>
|
|
)
|
|
}
|
|
|
|
SpacerComponent.defaultProps = defaultProps
|
|
SpacerComponent.displayName = 'GeistSpacer'
|
|
const Spacer = withScaleable(SpacerComponent)
|
|
export default Spacer
|