import * as React from 'react'; import {BasicConfig, BasicContainer, BasicContainerPropsInterface} from '../../render/core/Container/types'; import componentLoader from '../../render/util/componentLoader'; import {Icon} from '@native-ads/antd'; export class TrendConfig extends BasicConfig { /** * up: 红色 * down: 绿色 */ flag: 'up' | 'down' | 'normal'; /** * 显示的值 */ text: string; } export class TrendPropsInterface extends BasicContainerPropsInterface { info: TrendConfig; } export class AbstractTrend extends BasicContainer { constructor(props: TrendPropsInterface) { super(props); } render() { let info = this.getPropsInfo(this.props.info); let icon; let color; switch (info.flag) { case 'up': color = '#FF5B5B'; icon = ; break; case 'down': color = '#5BC49F'; icon = ; break; case 'normal': default: break; } const trendStyle = Object.assign({ height: '25px', lineHeight: '25px' }, info.style); return (
{info.text} {icon}
); } } componentLoader.addComponent('trend', AbstractTrend, TrendPropsInterface);