import { Text, View } from "@tarojs/components"; import Taro, { Component, pxTransform } from "@tarojs/taro"; import { classNames } from "../../lib"; import { BG_COLOR_LIST } from "../../lib/model"; import { IProps } from "../../../@types/titleBar"; interface IState {} export default class ClTitleBar extends Component { static options = { addGlobalClass: true }; static defaultProps: IProps = { bgColor: "white", textColor: "green", type: "border-title", borderLong: 20, borderColor: "green", icon: "title", iconColor: "green", title: "", subTitle: "", subTitleColor: "gray" }; render() { const textColorClassName = this.props.textColor ? `text-${this.props.textColor}` : ``; const borderColorClassName = this.props.borderColor ? BG_COLOR_LIST[this.props.borderColor] : "bg-green"; const bgColorClassName = this.props.bgColor ? BG_COLOR_LIST[this.props.bgColor] : `bg-white`; const iconClassName = this.props.icon ? `cuIcon-${this.props.icon}` : ``; const iconColorClassName = this.props.iconColor ? `text-${this.props.iconColor}` : ``; const borderComponent = ( {this.props.title} {this.props.renderRight} ); const subComponent = ( {this.props.title} {this.props.subTitle ? ( {this.props.subTitle} ) : ( {} )} {this.props.renderRight} ); const iconComponent = ( {this.props.title} {this.props.renderRight} ); return ( {this.props.type === "border-title" ? borderComponent : ""} {this.props.type === "sub-title" ? subComponent : ""} {this.props.type === "icon" ? iconComponent : ""} ); } }