mirror of
https://github.com/zhigang1992/react.git
synced 2026-04-28 20:25:29 +08:00
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
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import React from 'react'
|
||||
import { mount } from 'enzyme'
|
||||
import { Row, Col } from 'components'
|
||||
import Row from '../index'
|
||||
import Col from '../../col'
|
||||
|
||||
describe('Row', () => {
|
||||
it('should render correctly', () => {
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import React, { useMemo } from 'react'
|
||||
import withDefaults from '../utils/with-defaults'
|
||||
import useTheme from '../use-theme'
|
||||
|
||||
type Justify = 'start' | 'end' | 'center' | 'space-around' | 'space-between'
|
||||
@@ -22,7 +21,7 @@ const defaultProps = {
|
||||
}
|
||||
|
||||
type NativeAttrs = Omit<React.HTMLAttributes<any>, keyof Props>
|
||||
export type RowProps = Props & typeof defaultProps & NativeAttrs
|
||||
export type RowProps = Props & NativeAttrs
|
||||
|
||||
const getFlexAlignment = (justify: Justify, align: Align) => {
|
||||
const flexJustifyMap: { [key in Justify]?: string } = {
|
||||
@@ -49,7 +48,7 @@ const Container: React.FC<React.PropsWithChildren<RowProps>> = ({
|
||||
align,
|
||||
className,
|
||||
...props
|
||||
}) => {
|
||||
}: React.PropsWithChildren<RowProps> & typeof defaultProps) => {
|
||||
const Component = component
|
||||
const theme = useTheme()
|
||||
const { justifyValue, alignValue } = useMemo(() => getFlexAlignment(justify, align), [
|
||||
@@ -76,6 +75,6 @@ const Container: React.FC<React.PropsWithChildren<RowProps>> = ({
|
||||
)
|
||||
}
|
||||
|
||||
const MemoContainer = React.memo(Container)
|
||||
|
||||
export default withDefaults(MemoContainer, defaultProps)
|
||||
Container.defaultProps = defaultProps
|
||||
Container.displayName = 'GeistContainer'
|
||||
export default Container
|
||||
|
||||
Reference in New Issue
Block a user