import * as Nerv from 'nervjs' import Component from '@lib/component' interface CardProps { bordered?: boolean noHover?: boolean bodyStyle?: object loading?: boolean } class CardL extends Component { static defaultProps = { bordered: true, noHover: false, loading: false } render () { const { bordered, noHover, bodyStyle, loading, children, style } = this.props let titleSlot = null let extraSlot = null let loadingSlot = null const contentSlot = [] Nerv.Children.forEach( children as object[], (child, index) => { const { slot } = child.props delete child.props.slot switch (slot) { case 'title': titleSlot = child break case 'extra': extraSlot = child break case 'loading': loadingSlot = child break default: contentSlot.push(child as never) } }, this ) return (
{!(!titleSlot && !extraSlot) ? (
{titleSlot ?
{titleSlot}
: ''} {extraSlot ?
{extraSlot}
: ''}
) : ( '' )}
{loading ? ( loadingSlot ? ( loadingSlot ) : (
) ) : ( contentSlot )}
) } } export default CardL