|
@@ -8,7 +8,9 @@ export enum NewButtonType {
|
|
|
alpha = 'alpha', //主题半透明
|
|
alpha = 'alpha', //主题半透明
|
|
|
border = 'border', //主题边框
|
|
border = 'border', //主题边框
|
|
|
gray = 'gray', //灰色半透明
|
|
gray = 'gray', //灰色半透明
|
|
|
- text = 'text' //纯文本
|
|
|
|
|
|
|
+ text = 'text', //纯文本
|
|
|
|
|
+ link = 'link', //超链接(有可能带icon)
|
|
|
|
|
+ label = 'label',
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
function hexToHSL(hex) {
|
|
function hexToHSL(hex) {
|
|
@@ -66,7 +68,8 @@ export default function NewButton(props: {
|
|
|
width?: number,
|
|
width?: number,
|
|
|
height?: number,
|
|
height?: number,
|
|
|
fontSize?: number,
|
|
fontSize?: number,
|
|
|
- bold?:boolean,
|
|
|
|
|
|
|
+ bold?: boolean,
|
|
|
|
|
+ labelBorder?: boolean,
|
|
|
}) {
|
|
}) {
|
|
|
|
|
|
|
|
const [isTouched, setIsTouched] = useState(false)
|
|
const [isTouched, setIsTouched] = useState(false)
|
|
@@ -116,13 +119,83 @@ export default function NewButton(props: {
|
|
|
alignItems: 'center',
|
|
alignItems: 'center',
|
|
|
justifyContent: 'center',
|
|
justifyContent: 'center',
|
|
|
opacity: props.disable ? 0.6 : 1,
|
|
opacity: props.disable ? 0.6 : 1,
|
|
|
- boxSizing:'border-box'
|
|
|
|
|
|
|
+ boxSizing: 'border-box'
|
|
|
}
|
|
}
|
|
|
break;
|
|
break;
|
|
|
|
|
+ case NewButtonType.gray:
|
|
|
|
|
+ style = {
|
|
|
|
|
+ height: props.height ?? rpxToPx(72),
|
|
|
|
|
+ width: props.width ?? rpxToPx(198),
|
|
|
|
|
+ borderRadius: props.height ? props.height / 4 : rpxToPx(72 / 4),
|
|
|
|
|
+ backgroundColor: isTouched ? '#b2b2b240' : '#b2b2b210',
|
|
|
|
|
+ color: props.disable ? '#b2b2b2' : '#000000',
|
|
|
|
|
+ fontSize: props.fontSize ?? rpxToPx(30),
|
|
|
|
|
+ display: 'flex',
|
|
|
|
|
+ alignItems: 'center',
|
|
|
|
|
+ justifyContent: 'center',
|
|
|
|
|
+ // opacity: props.disable ? 0.6 : 1,
|
|
|
|
|
+ }
|
|
|
|
|
+ // style = {
|
|
|
|
|
+ // height: props.height ?? rpxToPx(72),
|
|
|
|
|
+ // width: props.width ?? rpxToPx(198),
|
|
|
|
|
+ // borderRadius: props.height ? props.height / 4 : rpxToPx(72 / 4),
|
|
|
|
|
+ // backgroundColor: isTouched ? '#9999991A' : 'transparent',
|
|
|
|
|
+ // color: props.disable ? '#999999' : '#999999',
|
|
|
|
|
+ // fontSize: props.fontSize ?? rpxToPx(30),
|
|
|
|
|
+ // display: 'flex',
|
|
|
|
|
+ // alignItems: 'center',
|
|
|
|
|
+ // justifyContent: 'center',
|
|
|
|
|
+ // // opacity: props.disable ? 0.6 : 1,
|
|
|
|
|
+ // }
|
|
|
|
|
+ break
|
|
|
|
|
+ case NewButtonType.text:
|
|
|
|
|
+ style = {
|
|
|
|
|
+ height: props.height ?? rpxToPx(72),
|
|
|
|
|
+ width: props.width ?? rpxToPx(198),
|
|
|
|
|
+ borderRadius: props.height ? props.height / 4 : rpxToPx(72 / 4),
|
|
|
|
|
+ backgroundColor: props.disable ? '#B2B2B240' : isTouched ? '#B2B2B240' : '#B2B2B21A',
|
|
|
|
|
+ color: props.disable ? '#b2b2b2' : '#000',
|
|
|
|
|
+ fontSize: props.fontSize ?? rpxToPx(30),
|
|
|
|
|
+ display: 'flex',
|
|
|
|
|
+ alignItems: 'center',
|
|
|
|
|
+ justifyContent: 'center',
|
|
|
|
|
+ }
|
|
|
|
|
+ break;
|
|
|
|
|
+ case NewButtonType.link:
|
|
|
|
|
+ style = {
|
|
|
|
|
+ display: 'flex',
|
|
|
|
|
+ alignItems: 'center',
|
|
|
|
|
+ justifyContent: 'center',
|
|
|
|
|
+ flexDirection: 'row',
|
|
|
|
|
+ flex: 1,
|
|
|
|
|
+ color: '#5C7099',
|
|
|
|
|
+ fontSize: rpxToPx(26),
|
|
|
|
|
+ opacity: isTouched ? 0.4 : 1,
|
|
|
|
|
+ }
|
|
|
|
|
+ break
|
|
|
|
|
+ case NewButtonType.label:
|
|
|
|
|
+ style = {
|
|
|
|
|
+ height: rpxToPx(64),
|
|
|
|
|
+ borderRadius: rpxToPx(32),
|
|
|
|
|
+ display: 'flex',
|
|
|
|
|
+ flexDirection: 'row',
|
|
|
|
|
+ alignItems: 'center',
|
|
|
|
|
+ justifyContent: 'center',
|
|
|
|
|
+ fontSize: rpxToPx(28),
|
|
|
|
|
+ paddingLeft: rpxToPx(24),
|
|
|
|
|
+ paddingRight: rpxToPx(24),
|
|
|
|
|
+ boxSizing: 'border-box',
|
|
|
|
|
+ backgroundColor: isTouched ? '#5C709940' : props.labelBorder ? 'transparent' : '#5C70991A',
|
|
|
|
|
+ borderWidth: rpxToPx(2),
|
|
|
|
|
+ borderColor: props.labelBorder ? '#5C709940' : 'transparent',
|
|
|
|
|
+ borderStyle: 'solid',
|
|
|
|
|
+ color: '#5C7099'
|
|
|
|
|
+ }
|
|
|
|
|
+ break
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
return <View
|
|
return <View
|
|
|
- style={{...style,fontWeight:props.bold?'bold':'normal'}}
|
|
|
|
|
|
|
+ style={{ ...style, fontWeight: props.bold ? 'bold' : 'normal' }}
|
|
|
catchMove
|
|
catchMove
|
|
|
onClick={(e) => {
|
|
onClick={(e) => {
|
|
|
if (process.env.TARO_ENV == 'weapp') {
|
|
if (process.env.TARO_ENV == 'weapp') {
|
|
@@ -144,5 +217,5 @@ export default function NewButton(props: {
|
|
|
}
|
|
}
|
|
|
setIsTouched(false)
|
|
setIsTouched(false)
|
|
|
}}
|
|
}}
|
|
|
- >{props.title}{props.component}</View>
|
|
|
|
|
|
|
+ >{props.component}{props.title}</View>
|
|
|
}
|
|
}
|