antd-mobile-taro-ui
Version:
以antd-mobile为设计标准,基于taro框架的微信小程序组件库
30 lines • 1.04 kB
JavaScript
import React from 'react';
import classNames from 'classnames';
import { View } from '@tarojs/components';
import { withNativeProps } from 'antd-mobile/es/utils/native-props';
import { mergeProps } from 'antd-mobile/es/utils/with-default-props';
const classPrefix = `adm-space`;
const defaultProps = {
direction: 'horizontal'
};
export const Space = p => {
const props = mergeProps(defaultProps, p);
const {
direction,
onClick
} = props;
return withNativeProps(props, React.createElement(View, {
className: classNames(classPrefix, {
[`${classPrefix}-wrap`]: props.wrap,
[`${classPrefix}-block`]: props.block,
[`${classPrefix}-${direction}`]: true,
[`${classPrefix}-align-${props.align}`]: !!props.align,
[`${classPrefix}-justify-${props.justify}`]: !!props.justify
}),
onClick: onClick
}, React.Children.map(props.children, child => {
return child !== null && child !== undefined && React.createElement(View, {
className: `${classPrefix}-item`
}, child);
})));
};