@yorkjs/hive-ui 0.0.1 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +5 -1
- package/src/components/Cell/Cell.tsx +153 -0
- package/src/components/Cell/CellArrow.tsx +25 -0
- package/src/components/Cell/CellCard.tsx +44 -0
- package/src/components/Cell/CellDescription.tsx +28 -0
- package/src/components/Cell/CellGroup.tsx +46 -0
- package/src/components/Cell/CellTitle.tsx +71 -0
- package/src/components/Cell/CellValue.tsx +50 -0
- package/src/components/Cell/config.ts +13 -0
- package/src/components/Cell/index.module.styl +145 -0
- package/src/components/Cell/index.tsx +24 -0
- package/src/components/Checkbox/index.module.styl +68 -0
- package/src/components/Checkbox/index.tsx +118 -0
- package/src/components/Icon/index.tsx +51 -0
- package/src/components/NumberKeyboard/index.module.styl +20 -7
- package/src/components/NumberKeyboard/index.tsx +30 -8
- package/src/components/Tag/index.module.styl +29 -0
- package/src/components/Tag/index.tsx +117 -0
- package/src/constant/mall.ts +22 -0
- package/src/index.ts +6 -1
- package/src/item/ProductCard/index.module.styl +251 -0
- package/src/item/ProductCard/index.tsx +300 -0
- package/src/util/env.ts +17 -0
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import React, { useMemo } from 'react'
|
|
2
|
+
import { View, Text } from '@tarojs/components'
|
|
3
|
+
|
|
4
|
+
import { isAndroid, isApp } from '../../util/env'
|
|
5
|
+
import { formatClassNames } from '../../util/function'
|
|
6
|
+
|
|
7
|
+
import Icon from '../Icon'
|
|
8
|
+
|
|
9
|
+
import styles from './index.module.styl'
|
|
10
|
+
|
|
11
|
+
export interface CheckboxProps {
|
|
12
|
+
label?: string
|
|
13
|
+
checked: boolean
|
|
14
|
+
disabled?: boolean
|
|
15
|
+
readOnly?: boolean
|
|
16
|
+
size?: 'normal' | 'large' | 'small'
|
|
17
|
+
onChange?: (checked: boolean) => void
|
|
18
|
+
className?: string
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const isDark = false
|
|
22
|
+
|
|
23
|
+
const Checkbox: React.FC<CheckboxProps> = (props) => {
|
|
24
|
+
const {
|
|
25
|
+
label,
|
|
26
|
+
checked = false,
|
|
27
|
+
disabled = false,
|
|
28
|
+
readOnly = false,
|
|
29
|
+
size = 'normal',
|
|
30
|
+
onChange,
|
|
31
|
+
className,
|
|
32
|
+
} = props
|
|
33
|
+
|
|
34
|
+
const handlePress = (e: any) => {
|
|
35
|
+
if (disabled || readOnly) return
|
|
36
|
+
onChange?.(!checked)
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const iconSize = size === 'large' ? 36 : (size === 'small' ? 16 : 20)
|
|
40
|
+
|
|
41
|
+
const getIconColor = () => {
|
|
42
|
+
if (disabled) return 'var(--extraColor)'
|
|
43
|
+
if (checked) return 'var(--primary)'
|
|
44
|
+
return isDark ? '#ffffff' : 'var(--textPlaceholder)'
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const iconName = checked ? 'check-circle-fill' : 'circle'
|
|
48
|
+
|
|
49
|
+
const iconNode = (
|
|
50
|
+
<Icon
|
|
51
|
+
name={iconName}
|
|
52
|
+
size={`${iconSize}PX`}
|
|
53
|
+
color={getIconColor()}
|
|
54
|
+
/>
|
|
55
|
+
)
|
|
56
|
+
|
|
57
|
+
const iconElement = useMemo(() => {
|
|
58
|
+
if (disabled) {
|
|
59
|
+
return (
|
|
60
|
+
<View
|
|
61
|
+
style={{
|
|
62
|
+
width: `${iconSize}PX`,
|
|
63
|
+
height: `${iconSize}PX`,
|
|
64
|
+
borderRadius: `${iconSize / 2}PX`,
|
|
65
|
+
backgroundColor: 'var(--containerInner)',
|
|
66
|
+
display: 'flex',
|
|
67
|
+
alignItems: 'center',
|
|
68
|
+
justifyContent: 'center',
|
|
69
|
+
boxSizing: 'border-box'
|
|
70
|
+
}}
|
|
71
|
+
>
|
|
72
|
+
<Icon
|
|
73
|
+
name={iconName}
|
|
74
|
+
size={`${iconSize}PX`}
|
|
75
|
+
color={checked ? 'var(--extraColor)' : 'var(--textPlaceholder)'}
|
|
76
|
+
/>
|
|
77
|
+
</View>
|
|
78
|
+
)
|
|
79
|
+
}
|
|
80
|
+
return iconNode
|
|
81
|
+
}, [disabled, checked, iconName, iconSize])
|
|
82
|
+
|
|
83
|
+
return (
|
|
84
|
+
<View
|
|
85
|
+
onClick={handlePress}
|
|
86
|
+
className={formatClassNames(
|
|
87
|
+
styles['checkbox-component'],
|
|
88
|
+
{
|
|
89
|
+
[styles['is-checked']]: checked,
|
|
90
|
+
[styles['is-disabled']]: disabled,
|
|
91
|
+
[styles['size-large']]: size === 'large',
|
|
92
|
+
[styles['size-small']]: size === 'small',
|
|
93
|
+
},
|
|
94
|
+
className
|
|
95
|
+
)}
|
|
96
|
+
>
|
|
97
|
+
<View className={styles['checkbox-icon-container']}>
|
|
98
|
+
{iconElement}
|
|
99
|
+
</View>
|
|
100
|
+
|
|
101
|
+
{/* TODO: 临时解决 app 上 Android文字偏上对齐问题 */}
|
|
102
|
+
{label && (
|
|
103
|
+
<Text
|
|
104
|
+
className={formatClassNames(
|
|
105
|
+
styles['label-text'],
|
|
106
|
+
{
|
|
107
|
+
[styles['is-app-android']]: !!(isApp && isAndroid)
|
|
108
|
+
}
|
|
109
|
+
)}
|
|
110
|
+
>
|
|
111
|
+
{label}
|
|
112
|
+
</Text>
|
|
113
|
+
)}
|
|
114
|
+
</View>
|
|
115
|
+
)
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export default React.memo(Checkbox)
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { Text } from '@tarojs/components'
|
|
3
|
+
|
|
4
|
+
import { formatClassNames } from '../../util/function'
|
|
5
|
+
|
|
6
|
+
interface IconProps {
|
|
7
|
+
/** 图标名称,对应 iconfont 中的类名后缀 */
|
|
8
|
+
name: string
|
|
9
|
+
/** 图标颜色 */
|
|
10
|
+
color?: string
|
|
11
|
+
/** 图标大小,默认单位为 PX */
|
|
12
|
+
size?: number | string
|
|
13
|
+
/** 自定义类名 */
|
|
14
|
+
className?: string
|
|
15
|
+
/** 自定义样式 */
|
|
16
|
+
style?: React.CSSProperties
|
|
17
|
+
/** 点击事件 */
|
|
18
|
+
onClick?: (event: any) => void
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const Icon: React.FC<IconProps> = (props) => {
|
|
22
|
+
const {
|
|
23
|
+
name,
|
|
24
|
+
color,
|
|
25
|
+
size,
|
|
26
|
+
className,
|
|
27
|
+
style,
|
|
28
|
+
onClick
|
|
29
|
+
} = props
|
|
30
|
+
|
|
31
|
+
const iconStyle: React.CSSProperties = {
|
|
32
|
+
...style,
|
|
33
|
+
lineHeight: 1,
|
|
34
|
+
color: color,
|
|
35
|
+
fontSize: typeof size === 'number' ? `${size}PX` : size
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return (
|
|
39
|
+
<Text
|
|
40
|
+
className={formatClassNames(
|
|
41
|
+
'iconfont',
|
|
42
|
+
`icon-${name}`,
|
|
43
|
+
className)
|
|
44
|
+
}
|
|
45
|
+
style={iconStyle}
|
|
46
|
+
onClick={onClick}
|
|
47
|
+
/>
|
|
48
|
+
)
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export default React.memo(Icon)
|
|
@@ -14,8 +14,26 @@
|
|
|
14
14
|
background-color var(--containerInner)
|
|
15
15
|
halfBorder(top, var(--lineBorder))
|
|
16
16
|
|
|
17
|
-
.header-
|
|
17
|
+
.header-side
|
|
18
18
|
flex 1
|
|
19
|
+
height 100%
|
|
20
|
+
display flex
|
|
21
|
+
align-items center
|
|
22
|
+
|
|
23
|
+
&.side-right
|
|
24
|
+
justify-content flex-end
|
|
25
|
+
|
|
26
|
+
.header-main
|
|
27
|
+
flex 2
|
|
28
|
+
display flex
|
|
29
|
+
align-items center
|
|
30
|
+
justify-content center
|
|
31
|
+
overflow hidden
|
|
32
|
+
|
|
33
|
+
.header-title
|
|
34
|
+
font-size 14PX
|
|
35
|
+
color var(--textContent)
|
|
36
|
+
lineClamp(1)
|
|
19
37
|
|
|
20
38
|
.done-btn
|
|
21
39
|
height 100%
|
|
@@ -29,7 +47,6 @@
|
|
|
29
47
|
.done-text
|
|
30
48
|
font-size 18PX
|
|
31
49
|
color var(--primary)
|
|
32
|
-
font-weight 500
|
|
33
50
|
|
|
34
51
|
.keyboard-grid
|
|
35
52
|
display flex
|
|
@@ -67,8 +84,4 @@
|
|
|
67
84
|
|
|
68
85
|
.key-text
|
|
69
86
|
font-size 24PX
|
|
70
|
-
color var(--textTitle)
|
|
71
|
-
|
|
72
|
-
.delete-icon
|
|
73
|
-
width 22PX
|
|
74
|
-
height 22PX
|
|
87
|
+
color var(--textTitle)
|
|
@@ -3,9 +3,11 @@ import { View, Text, Image } from '@tarojs/components'
|
|
|
3
3
|
|
|
4
4
|
import { formatClassNames } from '../../util/function'
|
|
5
5
|
|
|
6
|
+
import Icon from '../Icon'
|
|
7
|
+
|
|
6
8
|
import styles from './index.module.styl'
|
|
7
9
|
|
|
8
|
-
type KeyboardType = 'int' | 'number'
|
|
10
|
+
type KeyboardType = 'int' | 'number' | 'idCard'
|
|
9
11
|
|
|
10
12
|
interface IProps {
|
|
11
13
|
/** 键盘类型:int(整数), number(带小数点) */
|
|
@@ -16,6 +18,8 @@ interface IProps {
|
|
|
16
18
|
onDelete: () => void
|
|
17
19
|
/** 是否显示头部状态栏 */
|
|
18
20
|
showHead?: boolean
|
|
21
|
+
/** 标题 */
|
|
22
|
+
title?: string
|
|
19
23
|
/** 完成按钮文案 */
|
|
20
24
|
doneText?: string
|
|
21
25
|
/** 完成按钮点击 */
|
|
@@ -30,13 +34,20 @@ const NumberKeyboard: React.FC<IProps> = (props) => {
|
|
|
30
34
|
onInsert,
|
|
31
35
|
onDelete,
|
|
32
36
|
showHead = false,
|
|
37
|
+
title,
|
|
33
38
|
doneText = '完成',
|
|
34
39
|
onDone,
|
|
35
40
|
className
|
|
36
41
|
} = props
|
|
37
42
|
|
|
38
43
|
const keys = useMemo(() => {
|
|
39
|
-
|
|
44
|
+
let leftBottomKey = ''
|
|
45
|
+
if (type === 'number') {
|
|
46
|
+
leftBottomKey = '.'
|
|
47
|
+
}
|
|
48
|
+
else if (type === 'idCard') {
|
|
49
|
+
leftBottomKey = 'X'
|
|
50
|
+
}
|
|
40
51
|
return ['1', '2', '3', '4', '5', '6', '7', '8', '9', leftBottomKey, '0', 'delete']
|
|
41
52
|
}, [type])
|
|
42
53
|
|
|
@@ -55,9 +66,20 @@ const NumberKeyboard: React.FC<IProps> = (props) => {
|
|
|
55
66
|
showHead
|
|
56
67
|
? (
|
|
57
68
|
<View className="keyboard-header">
|
|
58
|
-
<View className="header-
|
|
59
|
-
|
|
60
|
-
|
|
69
|
+
<View className="header-side" />
|
|
70
|
+
|
|
71
|
+
<View className="header-main">
|
|
72
|
+
{title && (
|
|
73
|
+
<Text className="header-title" numberOfLines={1}>
|
|
74
|
+
{title}
|
|
75
|
+
</Text>
|
|
76
|
+
)}
|
|
77
|
+
</View>
|
|
78
|
+
|
|
79
|
+
<View className="header-side side-right">
|
|
80
|
+
<View className="done-btn" onClick={onDone}>
|
|
81
|
+
<Text className="done-text">{doneText}</Text>
|
|
82
|
+
</View>
|
|
61
83
|
</View>
|
|
62
84
|
</View>
|
|
63
85
|
) : undefined
|
|
@@ -81,9 +103,9 @@ const NumberKeyboard: React.FC<IProps> = (props) => {
|
|
|
81
103
|
{
|
|
82
104
|
isDelete
|
|
83
105
|
? (
|
|
84
|
-
<
|
|
85
|
-
|
|
86
|
-
|
|
106
|
+
<Icon
|
|
107
|
+
name="delete"
|
|
108
|
+
size={22}
|
|
87
109
|
/>
|
|
88
110
|
)
|
|
89
111
|
: (
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
@import '../../styles/mixin.styl'
|
|
2
|
+
|
|
3
|
+
.tag-component
|
|
4
|
+
display inline-flex
|
|
5
|
+
align-items center
|
|
6
|
+
justify-content center
|
|
7
|
+
padding 0 8PX
|
|
8
|
+
height 20PX
|
|
9
|
+
line-height 20PX
|
|
10
|
+
border-radius 4PX
|
|
11
|
+
text-align center
|
|
12
|
+
font-size 12PX
|
|
13
|
+
white-space nowrap
|
|
14
|
+
box-sizing border-box
|
|
15
|
+
|
|
16
|
+
halfBorder(top left right bottom, transparent, 8PX)
|
|
17
|
+
|
|
18
|
+
.tag-text
|
|
19
|
+
line-height 1
|
|
20
|
+
|
|
21
|
+
.type-default
|
|
22
|
+
&:before
|
|
23
|
+
border-color var(--lineBorder)
|
|
24
|
+
:global(.is-dark)
|
|
25
|
+
&:before
|
|
26
|
+
border-color transparent
|
|
27
|
+
|
|
28
|
+
.type-primary, .type-info, .type-success, .type-error
|
|
29
|
+
border none
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import React, { useMemo } from 'react'
|
|
2
|
+
import { View, Text } from '@tarojs/components'
|
|
3
|
+
|
|
4
|
+
import { formatClassNames } from '../../util/function'
|
|
5
|
+
|
|
6
|
+
import styles from './index.module.styl'
|
|
7
|
+
|
|
8
|
+
export type TagType = 'default'
|
|
9
|
+
| 'success'
|
|
10
|
+
| 'info'
|
|
11
|
+
| 'error'
|
|
12
|
+
| 'primary'
|
|
13
|
+
| 'warning'
|
|
14
|
+
| 'light-info'
|
|
15
|
+
| 'light-primary'
|
|
16
|
+
| 'light-success'
|
|
17
|
+
| 'light-error'
|
|
18
|
+
| 'light-warning'
|
|
19
|
+
|
|
20
|
+
interface TagProps {
|
|
21
|
+
type?: TagType
|
|
22
|
+
text?: string | React.ReactNode
|
|
23
|
+
className?: string
|
|
24
|
+
style?: React.CSSProperties
|
|
25
|
+
}
|
|
26
|
+
const isDark = false
|
|
27
|
+
const Tag: React.FC<TagProps> = ({
|
|
28
|
+
type = 'default',
|
|
29
|
+
text,
|
|
30
|
+
className,
|
|
31
|
+
style
|
|
32
|
+
}) => {
|
|
33
|
+
|
|
34
|
+
const themeSelect = (light: string, dark: string) => (isDark ? dark : light)
|
|
35
|
+
|
|
36
|
+
const tagStyle = useMemo(() => {
|
|
37
|
+
const colors = {
|
|
38
|
+
primary: 'var(--primary)',
|
|
39
|
+
success: 'var(--success)',
|
|
40
|
+
error: 'var(--error)',
|
|
41
|
+
info: 'var(--textTitle)',
|
|
42
|
+
warning: 'var(--warning)',
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const mapping = {
|
|
46
|
+
default: {
|
|
47
|
+
color: 'var(--textTitle)',
|
|
48
|
+
backgroundColor: themeSelect('rgba(255, 255, 255, 0.16)', 'var(--containerInner)'),
|
|
49
|
+
},
|
|
50
|
+
info: {
|
|
51
|
+
color: 'var(--textTitle)',
|
|
52
|
+
backgroundColor: themeSelect('rgba(245, 245, 245, 1)', 'var(--containerInner)'),
|
|
53
|
+
},
|
|
54
|
+
'light-info': {
|
|
55
|
+
color: 'var(--textMuted)',
|
|
56
|
+
backgroundColor: themeSelect('rgba(245, 245, 245, 1)', 'var(--containerMedium)'),
|
|
57
|
+
},
|
|
58
|
+
warning: {
|
|
59
|
+
color: '#FFFFFF',
|
|
60
|
+
backgroundColor: colors.warning,
|
|
61
|
+
},
|
|
62
|
+
'light-warning': {
|
|
63
|
+
color: colors.warning,
|
|
64
|
+
backgroundColor: 'rgba(255,103,0,0.2)',
|
|
65
|
+
},
|
|
66
|
+
primary: {
|
|
67
|
+
color: '#FFFFFF',
|
|
68
|
+
backgroundColor: colors.primary,
|
|
69
|
+
},
|
|
70
|
+
'light-primary': {
|
|
71
|
+
color: colors.primary,
|
|
72
|
+
backgroundColor: 'rgba(255, 103, 0, 0.2)',
|
|
73
|
+
},
|
|
74
|
+
success: {
|
|
75
|
+
color: '#FFFFFF',
|
|
76
|
+
backgroundColor: colors.success,
|
|
77
|
+
},
|
|
78
|
+
'light-success': {
|
|
79
|
+
color: colors.success,
|
|
80
|
+
backgroundColor: 'rgba(3, 190, 2, 0.2)',
|
|
81
|
+
},
|
|
82
|
+
error: {
|
|
83
|
+
color: '#FFFFFF',
|
|
84
|
+
backgroundColor: colors.error,
|
|
85
|
+
},
|
|
86
|
+
'light-error': {
|
|
87
|
+
color: colors.error,
|
|
88
|
+
backgroundColor: 'rgba(255, 49, 65, 0.2)',
|
|
89
|
+
},
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
return mapping[type] || mapping.default
|
|
93
|
+
}, [type])
|
|
94
|
+
|
|
95
|
+
return (
|
|
96
|
+
<View
|
|
97
|
+
className={formatClassNames(
|
|
98
|
+
styles['tag-component'],
|
|
99
|
+
styles[`type-${type}`],
|
|
100
|
+
className
|
|
101
|
+
)}
|
|
102
|
+
style={{
|
|
103
|
+
backgroundColor: tagStyle.backgroundColor,
|
|
104
|
+
color: tagStyle.color,
|
|
105
|
+
...style
|
|
106
|
+
}}
|
|
107
|
+
>
|
|
108
|
+
<Text
|
|
109
|
+
className={styles['tag-text']}
|
|
110
|
+
>
|
|
111
|
+
{text}
|
|
112
|
+
</Text>
|
|
113
|
+
</View>
|
|
114
|
+
)
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
export default Tag
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// 商品类型
|
|
2
|
+
export const MALL_PRODUCT_TYPE_REAL = 1
|
|
3
|
+
export const MALL_PRODUCT_TYPE_VIRTUAL = 2
|
|
4
|
+
export const MALL_PRODUCT_TYPE_SERVICE = 3
|
|
5
|
+
|
|
6
|
+
// 快递发货
|
|
7
|
+
export const MALL_PRODUCT_DELIVERY_TYPE_EXPRESS = 1
|
|
8
|
+
// 到店自提
|
|
9
|
+
export const MALL_PRODUCT_DELIVERY_TYPE_SELF = 2
|
|
10
|
+
// 门店配送
|
|
11
|
+
export const MALL_PRODUCT_DELIVERY_TYPE_SHOP = 3
|
|
12
|
+
// 堂食
|
|
13
|
+
export const MALL_PRODUCT_DELIVERY_TYPE_DINE = 4
|
|
14
|
+
|
|
15
|
+
// 秒杀活动
|
|
16
|
+
export const PROMOTION_ACTIVITY_TYPE_FLASH = 1
|
|
17
|
+
// 品牌活动
|
|
18
|
+
export const PROMOTION_ACTIVITY_TYPE_BRAND = 2
|
|
19
|
+
// 热点活动
|
|
20
|
+
export const PROMOTION_ACTIVITY_TYPE_HOT = 3
|
|
21
|
+
//买赠活动
|
|
22
|
+
export const PROMOTION_ACTIVITY_TYPE_PRESENT = 4
|
package/src/index.ts
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
1
|
export { default as NumberKeyboard } from './components/NumberKeyboard'
|
|
2
|
+
export { default as Cell, setCellConfig } from './components/Cell'
|
|
3
|
+
export { default as Icon } from './components/Icon'
|
|
4
|
+
export { default as Checkbox } from './components/Checkbox'
|
|
5
|
+
export { default as Tag } from './components/Tag'
|
|
2
6
|
|
|
3
|
-
export { default as FlowItem } from './item/FlowItem'
|
|
7
|
+
export { default as FlowItem } from './item/FlowItem'
|
|
8
|
+
export { default as ProductCard } from './item/ProductCard'
|