WemetaButtonNative.tsx 944 B

1234567891011121314151617181920212223242526272829
  1. import { Button, View } from "@tarojs/components";
  2. interface IProps {
  3. onClick?: (e:any)=> void
  4. disabled?: boolean
  5. className?: string
  6. type?: 'primary'|'normal'|'danger'
  7. children: JSX.Element|JSX.Element[]|string
  8. style?: React.CSSProperties
  9. }
  10. export default function WemetaButton({ onClick, type = 'primary', disabled = false, className='', style, children }:IProps) {
  11. let typeClass = ''
  12. if(type ==='danger'){
  13. typeClass = 'bg-white text-red'
  14. }else if(type ==='primary'){
  15. typeClass = 'bg-primary text-white'
  16. }else{
  17. typeClass = 'bg-white'
  18. }
  19. const handleClick = (e:any)=> {
  20. if(!disabled){
  21. onClick && onClick(e)
  22. }
  23. }
  24. return (
  25. <Button disabled={disabled} style={style} className={`p-14 text-14 leading-20 block font-normal rounded-8 items-center justify-center font-pingfangSCMedium ${typeClass} ${disabled ? 'opacity-50': ''} ${className}`} onClick={handleClick}>{children}</Button>
  26. );
  27. }