UNPKG

antd-mobile-taro-ui

Version:

以antd-mobile为设计标准,基于taro框架的微信小程序组件库

41 lines (39 loc) 1.12 kB
import React from 'react'; import { mergeProps } from 'antd-mobile/es/utils/with-default-props'; import { withNativeProps } from 'antd-mobile/es/utils/native-props'; import { toCSSLength } from 'antd-mobile/es/utils/to-css-length'; import { View } from '@tarojs/components'; const classPrefix = `adm-grid`; export const Grid = props => { const style = { '--columns': props.columns.toString() }; const { gap } = props; if (gap !== undefined) { if (Array.isArray(gap)) { style['--gap-horizontal'] = toCSSLength(gap[0]); style['--gap-vertical'] = toCSSLength(gap[1]); } else { style['--gap'] = toCSSLength(gap); } } return withNativeProps(props, React.createElement(View, { className: classPrefix, style: style }, props.children)); }; export const GridItem = p => { const props = mergeProps({ span: '1' }, p); const itemStyle = { '--item-span': String(props.span) }; return withNativeProps(props, React.createElement(View, { className: `${classPrefix}-item`, style: itemStyle, onClick: props.onClick }, props.children)); };