UNPKG

antd-mobile-taro-ui

Version:

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

23 lines 970 B
import classNames from 'classnames'; import React, { Fragment } from 'react'; import { withNativeProps } from 'antd-mobile/es/utils/native-props'; import { View } from '@tarojs/components'; const classPrefix = `adm-badge`; export const dot = React.createElement(Fragment, null); export const Badge = props => { const { content, children } = props; const isDot = content === dot; const badgeCls = classNames(classPrefix, !!children && `${classPrefix}-fixed`, isDot && `${classPrefix}-dot`, props.bordered && `${classPrefix}-bordered`); const element = content || content === 0 ? withNativeProps(props, React.createElement(View, { className: badgeCls }, !isDot && React.createElement(View, { className: `${classPrefix}-content` }, content))) : null; return children ? React.createElement(View, { className: classNames(`${classPrefix}-wrapper`, props.wrapperClassName), style: props.wrapperStyle }, children, element) : element; };