import { View } from "@tarojs/components";

interface IProps {
  onClick?: (e:any)=> void
  disabled?: boolean
  className?: string
  type?: 'primary'|'normal'|'danger'
  children: JSX.Element|JSX.Element[]|string
  style?: React.CSSProperties
}
export default function WemetaButton({ onClick, type = 'primary', disabled = false, className='', style, children }:IProps) {
  let typeClass = ''
  if(type ==='danger'){
    typeClass = 'bg-white text-red'
  }else if(type ==='primary'){
    typeClass = 'bg-primary text-white'
  }else{
    typeClass = 'bg-white'
  }

  const handleClick = (e:any)=> {
    if(!disabled){
      onClick && onClick(e)
    }
  }
  return (
    <View style={style} className={`p-14 leading-20 flex font-normal rounded-8 items-center justify-center font-pingfangSCMedium  ${typeClass} ${disabled ? 'opacity-50': ''} ${className}`} onClick={handleClick}>{children}</View>
  );
}
