@yorkjs/hive-ui 0.1.2 → 0.1.4

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yorkjs/hive-ui",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
4
4
  "description": "Hive UI - Taro React component library",
5
5
  "main": "src/index.ts",
6
6
  "module": "src/index.ts",
@@ -23,6 +23,8 @@ export interface CellProps {
23
23
  showSeparator?: boolean
24
24
  showTopBorder?: boolean
25
25
  showBottomBorder?: boolean
26
+ clickable?: boolean
27
+ readOnly?: boolean
26
28
  onClick?: () => void
27
29
  className?: string
28
30
  children?: React.ReactNode
@@ -43,18 +45,25 @@ const Cell: React.FC<CellProps> = (props) => {
43
45
  showSeparator = false,
44
46
  showTopBorder = false,
45
47
  showBottomBorder = false,
48
+ clickable,
49
+ readOnly = false,
46
50
  onClick,
47
51
  className,
48
52
  children
49
53
  } = props
50
54
 
55
+ const finalRequired = readOnly ? false : required
56
+ const finalShowArrow = readOnly ? false : showArrow
57
+ const isClickable = readOnly ? false : (clickable !== undefined ? clickable : !!onClick)
58
+
51
59
  const containerClass = formatClassNames(
52
60
  styles['cell-container'],
53
61
  vertical ? styles['is-vertical'] : styles['is-horizontal'],
54
62
  {
55
- [styles['is-clickable']]: !!onClick,
63
+ [styles['is-clickable']]: isClickable,
56
64
  [styles['border-top']]: showTopBorder,
57
65
  [styles['border-bottom']]: showBottomBorder,
66
+ [styles['is-readonly']]: readOnly
58
67
  },
59
68
  className
60
69
  )
@@ -77,7 +86,10 @@ const Cell: React.FC<CellProps> = (props) => {
77
86
  }
78
87
 
79
88
  return (
80
- <View className={containerClass} onClick={onClick}>
89
+ <View
90
+ className={containerClass}
91
+ onClick={readOnly ? undefined : onClick}
92
+ >
81
93
  <View className={innerClass}>
82
94
  <View className={styles['cell-main']}>
83
95
  {
@@ -101,13 +113,19 @@ const Cell: React.FC<CellProps> = (props) => {
101
113
  <View className={styles['title-section']}>
102
114
  {
103
115
  typeof title === 'string'
104
- ? <CellTitle title={title} required={required} tooltip={tooltip} />
116
+ ? (
117
+ <CellTitle
118
+ title={title}
119
+ required={finalRequired}
120
+ tooltip={tooltip}
121
+ />
122
+ )
105
123
  : title
106
124
  }
107
125
  </View>
108
126
  </View>
109
127
  {
110
- showArrow
128
+ finalShowArrow
111
129
  ? <View className={styles['arrow-wrapper']}><CellArrow /></View>
112
130
  : undefined
113
131
  }
@@ -130,7 +148,13 @@ const Cell: React.FC<CellProps> = (props) => {
130
148
  >
131
149
  {
132
150
  typeof title === 'string'
133
- ? <CellTitle title={title} required={required} tooltip={tooltip} />
151
+ ? (
152
+ <CellTitle
153
+ title={title}
154
+ required={finalRequired}
155
+ tooltip={tooltip}
156
+ />
157
+ )
134
158
  : title
135
159
  }
136
160
  </View>
@@ -138,7 +162,7 @@ const Cell: React.FC<CellProps> = (props) => {
138
162
  {renderContent()}
139
163
  </View>
140
164
  {
141
- showArrow
165
+ finalShowArrow
142
166
  ? <View className={styles['arrow-wrapper']}><CellArrow /></View>
143
167
  : undefined
144
168
  }
@@ -0,0 +1,56 @@
1
+ @import '../../styles/mixin.styl'
2
+ @import '../../styles/variable.styl'
3
+
4
+ $CELL_PADDING_HORIZONTAL = 10PX
5
+ $CELL_PADDING_VERTICAL = 15PX
6
+ $LABEL_MARGIN_RIGHT = 20PX
7
+
8
+ .display-card
9
+ padding $CELL_PADDING_VERTICAL $CELL_PADDING_HORIZONTAL
10
+ background-color var(--containerCard)
11
+ margin 0 $WING_BLANK
12
+ border-radius 10PX
13
+ &.show-top-gutter
14
+ margin-top $GUTTER_BLANK
15
+ &.show-bottom-gutter
16
+ margin-bottom $GUTTER_BLANK
17
+ &.show-top-blank
18
+ margin-top $CARD_BLANK
19
+
20
+ .card-header
21
+ display flex
22
+ justify-content space-between
23
+ align-items center
24
+ margin-bottom 15PX
25
+
26
+ .header-title
27
+ font-size 16PX
28
+ font-weight bold
29
+ color var(--textTitle)
30
+
31
+ .header-extra
32
+ font-size 14PX
33
+ color var(--textMuted)
34
+
35
+ .info-row
36
+ display flex
37
+ flex-direction row
38
+ align-items flex-start
39
+ margin-bottom 15PX
40
+ &:last-child
41
+ margin-bottom 0
42
+
43
+ .info-label
44
+ font-size 14PX
45
+ color var(--textContent)
46
+ flex-shrink 0
47
+ margin-right $LABEL_MARGIN_RIGHT
48
+ min-width 70PX
49
+
50
+ .info-value
51
+ flex 1
52
+ font-size 14PX
53
+ color var(--textTitle)
54
+ word-break break-all
55
+ display flex
56
+ flex-direction row
@@ -0,0 +1,120 @@
1
+ import React from 'react'
2
+ import { View, Text } from '@tarojs/components'
3
+ import styles from './index.module.styl'
4
+ import { formatClassNames } from '../../util/function'
5
+
6
+ interface IRowProps {
7
+ label: React.ReactNode
8
+ value?: React.ReactNode
9
+ children?: React.ReactNode
10
+ className?: string
11
+ }
12
+
13
+ const InfoRow: React.FC<IRowProps> = ({
14
+ label,
15
+ value,
16
+ children,
17
+ className
18
+ }) => (
19
+ <View
20
+ className={formatClassNames(styles['info-row'], className)}
21
+ >
22
+ <View className={styles['info-label']}>
23
+ {
24
+ typeof label === 'string'
25
+ ? <Text>{label}</Text>
26
+ : label
27
+ }
28
+ </View>
29
+ <View className={styles['info-value']}>
30
+ {children || value || '-'}
31
+ </View>
32
+ </View>
33
+ )
34
+
35
+ interface IBlockProps {
36
+ children?: React.ReactNode
37
+ className?: string
38
+ }
39
+
40
+ const InfoBlock: React.FC<IBlockProps> = ({
41
+ children,
42
+ className
43
+ }) => (
44
+ <View
45
+ className={className}
46
+ >
47
+ {children}
48
+ </View>
49
+ )
50
+
51
+ interface ICardProps {
52
+ title?: React.ReactNode
53
+ showTopGutter?: boolean
54
+ showBottomGutter?: boolean
55
+ showTopBlank?: boolean
56
+ extra?: React.ReactNode
57
+ children?: React.ReactNode
58
+ className?: string
59
+ style?: React.CSSProperties
60
+ }
61
+
62
+ const DisplayCardMain: React.FC<ICardProps> = ({
63
+ title,
64
+ extra,
65
+ children,
66
+ className,
67
+ style,
68
+ showTopGutter = false,
69
+ showBottomGutter = false,
70
+ showTopBlank = false,
71
+ }) => {
72
+ return (
73
+ <View
74
+ className={formatClassNames(
75
+ styles['display-card'],
76
+ {
77
+ [styles['show-top-gutter']]: showTopGutter,
78
+ [styles['show-bottom-gutter']]: showBottomGutter,
79
+ [styles['show-top-blank']]: showTopBlank,
80
+ },
81
+ className
82
+ )}
83
+ style={style}
84
+ >
85
+ {
86
+ (title || extra)
87
+ ? (
88
+ <View className={styles['card-header']}>
89
+ <View className={styles['header-title']}>
90
+ {
91
+ typeof title === 'string'
92
+ ? <Text>{title}</Text>
93
+ : title
94
+ }
95
+ </View>
96
+ {
97
+ extra ? (
98
+ <View className={styles['header-extra']}>
99
+ {extra}
100
+ </View>
101
+ )
102
+ : undefined
103
+ }
104
+ </View>
105
+ )
106
+ : undefined
107
+ }
108
+ <View className={styles['card-content']}>
109
+ {children}
110
+ </View>
111
+ </View>
112
+ )
113
+ }
114
+
115
+ const DisplayCard = Object.assign(DisplayCardMain, {
116
+ Row: InfoRow,
117
+ Block: InfoBlock,
118
+ })
119
+
120
+ export default DisplayCard
@@ -2,6 +2,8 @@
2
2
  export const MALL_PRODUCT_TYPE_REAL = 1
3
3
  export const MALL_PRODUCT_TYPE_VIRTUAL = 2
4
4
  export const MALL_PRODUCT_TYPE_SERVICE = 3
5
+ // 前端定义的字段后台不存在
6
+ export const MALL_PRODUCT_TYPE_COMBO = 4
5
7
 
6
8
  // 快递发货
7
9
  export const MALL_PRODUCT_DELIVERY_TYPE_EXPRESS = 1
package/src/index.ts CHANGED
@@ -6,6 +6,7 @@ export { default as Icon } from './components/Icon'
6
6
  export { default as Checkbox } from './components/Checkbox'
7
7
  export { default as Tag } from './components/Tag'
8
8
  export { default as FieldCard } from './components/FieldCard'
9
+ export { default as DisplayCard } from './components/DisplayCard'
9
10
 
10
11
  export { default as FlowItem } from './item/FlowItem'
11
12
  export { default as ProductItem, setProductItemConfig } from './item/ProductItem'
@@ -20,13 +20,14 @@ import {
20
20
  PROMOTION_ACTIVITY_TYPE_HOT,
21
21
  PROMOTION_ACTIVITY_TYPE_PRESENT,
22
22
  PROMOTION_ACTIVITY_TYPE_COUNT_DISCOUNT,
23
+ MALL_PRODUCT_TYPE_COMBO,
23
24
  } from '../../constant/mall'
24
25
  import { getProductItemConfig } from './config'
25
26
 
26
27
  import styles from './index.module.styl'
27
28
 
28
29
  export interface IProductCardLabels {
29
- product_type?: { real: string; virtual: string; service: string }
30
+ product_type?: { real: string; virtual: string; service: string; combo: string }
30
31
  delivery_type?: { dine: string; self_pickup: string; delivery: string }
31
32
  activity_type?: { flash: string; brand: string; hot: string; present: string; full_discount: string }
32
33
  present_badge?: string
@@ -181,6 +182,10 @@ const ProductItem: React.FC<IProductCardProps> = (props) => {
181
182
  color: '#03BE02',
182
183
  text: labels.product_type?.service
183
184
  },
185
+ [MALL_PRODUCT_TYPE_COMBO] : {
186
+ color: '#E4B700',
187
+ text: labels.product_type?.combo
188
+ },
184
189
  }
185
190
  const item = colorMap[productType]
186
191
  if (!item) return null
@@ -5,7 +5,8 @@ let globalLabels: IProductCardLabels = {
5
5
  product_type: {
6
6
  real: '实物',
7
7
  virtual: '虚拟',
8
- service: '服务'
8
+ service: '服务',
9
+ combo: '套餐'
9
10
  },
10
11
  delivery_type: {
11
12
  dine: '堂食',