antd-mobile-taro-ui
Version:
以antd-mobile为设计标准,基于taro框架的微信小程序组件库
39 lines • 1.3 kB
JavaScript
import React from 'react';
import classNames from 'classnames';
import { RoundCheckFillIcon, RoundCloseFillIcon, InfoFillIcon, WarnFillIcon, TimeFillIcon } from 'antd-mobile-taro-icons';
import { withNativeProps } from 'antd-mobile/es/utils/native-props';
import { mergeProps } from 'antd-mobile/es/utils/with-default-props';
import { View } from '@tarojs/components';
const classPrefix = `adm-result`;
const iconRecord = {
success: RoundCheckFillIcon,
error: RoundCloseFillIcon,
info: InfoFillIcon,
waiting: TimeFillIcon,
warning: WarnFillIcon
};
const defaultProps = {
status: 'info'
};
export const Result = p => {
const props = mergeProps(defaultProps, p);
const {
status,
title,
description,
icon
} = props;
if (!status) return null;
const resultIcon = icon || React.createElement(iconRecord[status], {
className: `${classPrefix}-iconfont`
});
return withNativeProps(props, React.createElement(View, {
className: classNames(classPrefix, `${classPrefix}-${status}`)
}, React.createElement(View, {
className: `${classPrefix}-icon`
}, resultIcon), React.createElement(View, {
className: `${classPrefix}-title`
}, title), description ? React.createElement(View, {
className: `${classPrefix}-description`
}, description) : null));
};