Buttons.tsx 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. import { Button, View, Text } from "@tarojs/components";
  2. import './Buttons.scss'
  3. import { ButtonType, ComponentStatus } from "../../utils/types";
  4. import { Button as RNButton } from 'react-native';
  5. /*
  6. export default function Buttons(props: { title: string, type?: ButtonType, status?: ComponentStatus,onClick?:()=>void,style?:any }) {
  7. const myStyle = props.status == ComponentStatus.disable ? { opacity: 0.4 } : {}
  8. return (
  9. <View style={{...myStyle}}>
  10. <Button className={props.type == ButtonType.outline ? 'outline_btn' : 'btn'} style={{...props.style}} onClick={props.onClick}>{props.title}</Button>
  11. </View>
  12. )
  13. }*/
  14. export default function Buttons(props: {
  15. title: string,
  16. type?: ButtonType,
  17. onClick: () => void,
  18. disabled?: boolean,
  19. lowLight?: boolean,
  20. openType?: string,
  21. btnStyle?: any,
  22. }) {
  23. function onClick() {
  24. if (props.disabled) return
  25. props.onClick()
  26. }
  27. var mainClass = 'elevated'
  28. var textClass = 'elevated_text'
  29. if (props.type == ButtonType.outline) {
  30. mainClass = 'outlined'
  31. textClass = 'outlined_text'
  32. return (
  33. <View className={mainClass} style={{ ...props.btnStyle,opacity:props.lowLight?0.4:1 }}>
  34. <Text
  35. onClick={onClick}
  36. style={{
  37. color: props.btnStyle.color,
  38. fontSize: props.btnStyle.fontSize
  39. }}>{props.title}</Text>
  40. </View>
  41. )
  42. }
  43. else {
  44. mainClass = 'puretext'
  45. textClass = 'puretext_text'
  46. }
  47. return (
  48. <View className={mainClass} style={{ ...props.btnStyle }}>
  49. <Text
  50. onClick={onClick}
  51. style={{
  52. color: props.btnStyle.color,
  53. fontSize: props.btnStyle.fontSize
  54. }}>{props.title}</Text>
  55. </View>
  56. // <View onClick={onClick}>
  57. // <Text
  58. // style={{
  59. // height: props.btnStyle.height,
  60. // lineHeight: props.btnStyle.height,
  61. // color: props.btnStyle.color,
  62. // fontSize: props.btnStyle.fontSize
  63. // }}>{props.title}</Text>
  64. // </View>
  65. )
  66. }