UNPKG

antd-mobile

Version:
36 lines 1.22 kB
import React from 'react'; import classNames from 'classnames'; import { CheckCircleFill, CloseCircleFill, InformationCircleFill, ClockCircleFill, ExclamationCircleFill } from 'antd-mobile-icons'; import { withNativeProps } from '../../utils/native-props'; import { mergeProps } from '../../utils/with-default-props'; const classPrefix = `adm-result`; const iconRecord = { success: CheckCircleFill, error: CloseCircleFill, info: InformationCircleFill, waiting: ClockCircleFill, warning: ExclamationCircleFill }; 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]); return withNativeProps(props, React.createElement("div", { className: classNames(classPrefix, `${classPrefix}-${status}`) }, React.createElement("div", { className: `${classPrefix}-icon` }, resultIcon), React.createElement("div", { className: `${classPrefix}-title` }, title), !!description && React.createElement("div", { className: `${classPrefix}-description` }, description))); };