import classNames from 'classnames' import PropTypes, { InferProps } from 'prop-types' import React from 'react' import { Image, Text, View } from '@tarojs/components' import AtIcon from '../icon' import { AtCardProps } from '../../../types/card' export default class AtCard extends React.Component { public static defaultProps: AtCardProps public static propTypes: InferProps private handleClick = (args: any): void => { if (typeof this.props.onClick === 'function') { this.props.onClick(args) } } public render(): JSX.Element { const { title, note, extra, extraStyle, thumb, isFull, icon, renderIcon } = this.props const rootClass = classNames( 'at-card', { 'at-card--full': isFull, }, this.props.className, ) // const iconClass = classNames({ // 'at-icon': true, // [`at-icon-${icon && icon.value}`]: icon && icon.value, // 'at-card__header-icon': true // }) // const iconStyle = { // color: (icon && icon.color) || '', // fontSize: (icon && `${icon.size}px`) || '' // } return ( {thumb && ( )} {renderIcon || ''} {!thumb && icon && icon.value && ( )} {title} {extra && ( {extra} )} {this.props.children} {note ? {note} : null} ) } } AtCard.defaultProps = { note: '', isFull: false, thumb: '', title: '', extra: '', extraStyle: {}, } AtCard.propTypes = { note: PropTypes.string, isFull: PropTypes.bool, thumb: PropTypes.string, title: PropTypes.string, extra: PropTypes.string, icon: PropTypes.object, onClick: PropTypes.func, renderIcon: PropTypes.oneOfType([PropTypes.string, PropTypes.element]), extraStyle: PropTypes.object, // 自定义extra样式 }