Files
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

44 lines
847 B
TypeScript

import { ScaleableProps } from './scaleable-context'
export type ScaleablePropsAndInvalid = keyof ScaleableProps | 'size'
export const ScaleablePropKeys: Array<ScaleablePropsAndInvalid> = [
'paddingLeft',
'pl',
'paddingRight',
'pr',
'paddingTop',
'pt',
'paddingBottom',
'pb',
'marginTop',
'mt',
'marginRight',
'mr',
'marginBottom',
'mb',
'marginLeft',
'ml',
'px',
'py',
'mx',
'my',
'width',
'height',
'font',
'unit',
'scale',
'size',
]
export const filterScaleableProps = <T extends Record<any, any>>(props: T) => {
const keys = Object.keys(props).filter(key => key !== '')
const nextProps: any = {}
for (const key of keys) {
if (!(ScaleablePropKeys as string[]).includes(key)) {
nextProps[key] = props[key]
}
}
return nextProps as Omit<T, ScaleablePropsAndInvalid>
}