Buttons.tsx 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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. className?:any,
  18. onClick: () => void,
  19. disabled?: boolean,
  20. lowLight?: boolean,
  21. openType?: string,
  22. btnStyle?: any,
  23. }) {
  24. function onClick() {
  25. if (props.disabled) return
  26. props.onClick()
  27. }
  28. var mainClass = 'elevated'
  29. var textClass = 'elevated_text'
  30. if (props.type == ButtonType.text) {
  31. mainClass = 'texted'
  32. return <View style={{ opacity: (props.lowLight || props.disabled) ? 0.4 : 1 }} onClick={onClick}>
  33. <Text
  34. style={{
  35. ...props.btnStyle,
  36. fontWeight:500,
  37. }} className={props.className?props.className:''}>{props.title}</Text>
  38. </View>
  39. }
  40. if (props.type == ButtonType.outline) {
  41. mainClass = 'outlined'
  42. textClass = 'outlined_text'
  43. return (
  44. <View className={mainClass} style={{ ...props.btnStyle, opacity: props.lowLight ? 0.4 : 1 }} onClick={onClick}>
  45. <Text
  46. style={{
  47. color: props.btnStyle.color,
  48. fontSize: props.btnStyle.fontSize,
  49. fontWeight:500,
  50. marginBottom:2
  51. }}>{props.title}</Text>
  52. </View>
  53. )
  54. }
  55. else {
  56. mainClass = 'puretext'
  57. textClass = 'puretext_text'
  58. }
  59. return (
  60. <View className={mainClass} style={{ ...props.btnStyle, opacity: props.lowLight ? 0.4 : 1 }} onClick={onClick}>
  61. <Text
  62. // onClick={onClick}
  63. style={{
  64. color: props.btnStyle.color,
  65. fontSize: props.btnStyle.fontSize,
  66. fontWeight:500,
  67. marginBottom:2
  68. }}>{props.title}</Text>
  69. </View>
  70. // <View onClick={onClick}>
  71. // <Text
  72. // style={{
  73. // height: props.btnStyle.height,
  74. // lineHeight: props.btnStyle.height,
  75. // color: props.btnStyle.color,
  76. // fontSize: props.btnStyle.fontSize
  77. // }}>{props.title}</Text>
  78. // </View>
  79. )
  80. }