@yorkjs/hive-ui 0.0.5 → 0.0.7

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.0.5",
3
+ "version": "0.0.7",
4
4
  "description": "Hive UI - Taro React component library",
5
5
  "main": "src/index.ts",
6
6
  "module": "src/index.ts",
package/src/index.ts CHANGED
@@ -5,4 +5,4 @@ export { default as Checkbox } from './components/Checkbox'
5
5
  export { default as Tag } from './components/Tag'
6
6
 
7
7
  export { default as FlowItem } from './item/FlowItem'
8
- export { default as ProductCard } from './item/ProductCard'
8
+ export { default as ProductItem } from './item/ProductItem'
@@ -13,11 +13,19 @@ $F_BUY_COUNT = 14PX // RN 14
13
13
 
14
14
  .item-container
15
15
  position relative
16
- display flex
17
- flex-direction column
18
- padding 15PX 10PX // 对齐 RN: paddingVertical: 15, paddingHorizontal: 10
19
16
  background-color var(--containerCard)
17
+ padding 0 10PX
20
18
  box-sizing border-box
19
+ &.show-bottom-border
20
+ halfBorder(bottom, var(--lineBorder))
21
+
22
+ .card-info
23
+ display flex
24
+ flex-direction column
25
+ width 100%
26
+ padding 15PX 0
27
+ &.show-separator
28
+ halfBorder(bottom, var(--lineBorder))
21
29
 
22
30
  .card-main-body
23
31
  display flex
@@ -254,5 +262,4 @@ $F_BUY_COUNT = 14PX // RN 14
254
262
  color var(--textContent)
255
263
 
256
264
  .card-footer
257
- width 100%
258
- margin-top 12PX
265
+ width 100%
@@ -73,6 +73,10 @@ export interface IProductCardProps {
73
73
  customization?: string
74
74
  /** 做法描述最大显示行数 (默认3) */
75
75
  customizationMaxLines?: number
76
+ /** 套餐信息描述 */
77
+ combo? : string
78
+ /** 套餐描述最大显示行数 (默认3) */
79
+ comboMaxLines?: number
76
80
  /** 售价 */
77
81
  salePrice: string | number
78
82
  /** 原价 (划线价) */
@@ -95,6 +99,10 @@ export interface IProductCardProps {
95
99
  action?: React.ReactNode
96
100
  /** 国际化标签注入 */
97
101
  labels?: IProductCardLabels
102
+ /** 是否显示底部分边框 */
103
+ showBottomBorder?: boolean
104
+ /** 是否显示底部分割线 */
105
+ showSeparator?: boolean
98
106
  // 卡片点击事件
99
107
  onClick?: () => void
100
108
  children?: React.ReactNode
@@ -114,7 +122,7 @@ const DEFAULT_LABELS: IProductCardLabels = {
114
122
  offline: '已下架'
115
123
  }
116
124
 
117
- const ProductCard: React.FC<IProductCardProps> = (props) => {
125
+ const ProductItem: React.FC<IProductCardProps> = (props) => {
118
126
  const {
119
127
  image,
120
128
  title,
@@ -130,6 +138,8 @@ const ProductCard: React.FC<IProductCardProps> = (props) => {
130
138
  deliveryTypes = [],
131
139
  customization,
132
140
  customizationMaxLines = 3,
141
+ combo,
142
+ comboMaxLines = 3,
133
143
  salePrice,
134
144
  originalPrice,
135
145
  buyCount,
@@ -143,6 +153,8 @@ const ProductCard: React.FC<IProductCardProps> = (props) => {
143
153
  onDelete,
144
154
  action,
145
155
  className,
156
+ showBottomBorder = false,
157
+ showSeparator = false,
146
158
  labels: customLabels,
147
159
  onClick,
148
160
  children
@@ -254,139 +266,167 @@ const ProductCard: React.FC<IProductCardProps> = (props) => {
254
266
  }, [stockCount, saleCount, labels])
255
267
 
256
268
  return (
257
- <View className={formatClassNames(styles['item-container'], className)} onClick={handleCardClick}>
258
- <View className={styles['card-main-body']}>
259
- {showCheckbox && (
260
- <View className={styles['checkbox-container']}>
261
- <Checkbox
262
- checked={checkboxChecked}
263
- disabled={checkboxDisabled}
264
- readOnly
265
- />
266
- </View>
267
- )}
268
- <View className={styles['image-container']}>
269
- <Image
270
- src={image?.url}
271
- className={styles['product-image']}
272
- mode='aspectFill'
273
- />
274
- {(showSoldOut || showOffline) && (
275
- <View className={styles['status-overlay']}>
276
- <Text className={styles['status-text']}>
277
- {showSoldOut ? labels.sold_out : labels.offline}
278
- </Text>
269
+ <View
270
+ className={formatClassNames(
271
+ styles['item-container'],
272
+ {
273
+ [styles['show-bottom-border']]: showBottomBorder,
274
+ },
275
+ className
276
+ )}
277
+ onClick={handleCardClick}
278
+ >
279
+ <View className={formatClassNames(
280
+ styles['card-info'],
281
+ {
282
+ [styles['show-separator']]: showSeparator
283
+ }
284
+ )}>
285
+ <View className={styles['card-main-body']}>
286
+ {showCheckbox && (
287
+ <View className={styles['checkbox-container']}>
288
+ <Checkbox
289
+ checked={checkboxChecked}
290
+ disabled={checkboxDisabled}
291
+ readOnly
292
+ />
279
293
  </View>
280
294
  )}
281
- </View>
282
- <View className={styles['content-container']}>
283
- <View className={styles['content-body']}>
284
- <View className={styles['title-row']} style={{ marginRight: showDelete ? '30PX' : '0' }}>
285
- {productTypeTag}
286
- <Text className={styles['title']} style={{ WebkitLineClamp: titleMaxLines }}>{title}</Text>
287
- </View>
288
- {(showMultipleSpec || stockCount || saleCount || barcode) && (
289
- <ScrollView scrollX className={styles['second-row']} showScrollbar={false}>
290
- <View className={styles['second-row-inner']}>
291
- {showMultipleSpec && <Text className={styles['primary-text']}>{labels.multiple_spec}</Text>}
292
- {showMultipleSpec && stockAndSaleElem && <View className={styles['info-line']} />}
293
- {stockAndSaleElem}
294
- {((showMultipleSpec || stockAndSaleElem) && barcode) && <View className={styles['info-line']} />}
295
- {barcode && <Text className={styles['info-text']}>{labels.barcode_label} {barcode}</Text>}
296
- </View>
297
- </ScrollView>
298
- )}
299
- {(activityType || deliveryTags) && (
300
- <View className={styles['tag-row']}>
301
- {activityType && labels.activity_type && (
302
- <View className={styles['activity-tag']}>
303
- {activityType === PROMOTION_ACTIVITY_TYPE_PRESENT && <View className={styles['activity-tag-badge']}><Text className={styles['activity-tag-badge-text']}>{labels.present_badge}</Text></View>}
304
- <View className={styles['activity-tag-content']}>
305
- <Text className={styles['activity-tag-text']}>
306
- {activityType === PROMOTION_ACTIVITY_TYPE_FLASH && labels.activity_type.flash}
307
- {activityType === PROMOTION_ACTIVITY_TYPE_BRAND && labels.activity_type.brand}
308
- {activityType === PROMOTION_ACTIVITY_TYPE_HOT && labels.activity_type.hot}
309
- {activityType === PROMOTION_ACTIVITY_TYPE_PRESENT && labels.activity_type.present}
310
- </Text>
311
- </View>
312
- </View>
313
- )}
314
- {deliveryTags}
295
+ <View className={styles['image-container']}>
296
+ <Image
297
+ src={image?.url}
298
+ className={styles['product-image']}
299
+ mode='aspectFill'
300
+ />
301
+ {(showSoldOut || showOffline) && (
302
+ <View className={styles['status-overlay']}>
303
+ <Text className={styles['status-text']}>
304
+ {showSoldOut ? labels.sold_out : labels.offline}
305
+ </Text>
315
306
  </View>
316
307
  )}
317
- {
318
- spec
319
- ? (
320
- <Text
321
- className={styles['spec-text']}
322
- style={{ WebkitLineClamp: specMaxLines }}
323
- >
324
- {labels.spec_label}:{spec}
325
- </Text>
326
- )
327
- : undefined
328
- }
329
- {
330
- customization
331
- ? (
332
- <Text
333
- className={styles['customization-text']}
334
- style={{ WebkitLineClamp: customizationMaxLines }}
335
- >
336
- {customization}
337
- </Text>
338
- )
339
- : undefined
340
- }
341
308
  </View>
342
- <View className={styles['content-bottom']}>
343
- <View className={styles['price-container']}>
344
- <View className={styles['price-row']}>
345
- <Text className={styles['price-symbol']}>
346
- ¥
347
- </Text>
348
- <Text className={styles['price-value']}>
349
- {salePrice}
350
- </Text>
309
+ <View className={styles['content-container']}>
310
+ <View className={styles['content-body']}>
311
+ <View className={styles['title-row']} style={{ marginRight: showDelete ? '30PX' : '0' }}>
312
+ {productTypeTag}
313
+ <Text className={styles['title']} style={{ WebkitLineClamp: titleMaxLines }}>{title}</Text>
351
314
  </View>
315
+ {(showMultipleSpec || stockCount || saleCount || barcode) && (
316
+ <ScrollView scrollX className={styles['second-row']} showScrollbar={false}>
317
+ <View className={styles['second-row-inner']}>
318
+ {showMultipleSpec && <Text className={styles['primary-text']}>{labels.multiple_spec}</Text>}
319
+ {showMultipleSpec && stockAndSaleElem && <View className={styles['info-line']} />}
320
+ {stockAndSaleElem}
321
+ {((showMultipleSpec || stockAndSaleElem) && barcode) && <View className={styles['info-line']} />}
322
+ {barcode && <Text className={styles['info-text']}>{labels.barcode_label} {barcode}</Text>}
323
+ </View>
324
+ </ScrollView>
325
+ )}
326
+ {(activityType || deliveryTags) && (
327
+ <View className={styles['tag-row']}>
328
+ {activityType && labels.activity_type && (
329
+ <View className={styles['activity-tag']}>
330
+ {activityType === PROMOTION_ACTIVITY_TYPE_PRESENT && <View className={styles['activity-tag-badge']}><Text className={styles['activity-tag-badge-text']}>{labels.present_badge}</Text></View>}
331
+ <View className={styles['activity-tag-content']}>
332
+ <Text className={styles['activity-tag-text']}>
333
+ {activityType === PROMOTION_ACTIVITY_TYPE_FLASH && labels.activity_type.flash}
334
+ {activityType === PROMOTION_ACTIVITY_TYPE_BRAND && labels.activity_type.brand}
335
+ {activityType === PROMOTION_ACTIVITY_TYPE_HOT && labels.activity_type.hot}
336
+ {activityType === PROMOTION_ACTIVITY_TYPE_PRESENT && labels.activity_type.present}
337
+ </Text>
338
+ </View>
339
+ </View>
340
+ )}
341
+ {deliveryTags}
342
+ </View>
343
+ )}
352
344
  {
353
- originalPrice
345
+ spec
354
346
  ? (
355
- <Text className={styles['original-price']}>
356
- ¥{originalPrice}
347
+ <Text
348
+ className={styles['spec-text']}
349
+ style={{ WebkitLineClamp: specMaxLines }}
350
+ >
351
+ {labels.spec_label}:{spec}
357
352
  </Text>
358
353
  )
359
354
  : undefined
360
355
  }
361
- </View>
362
- <View
363
- className={styles['action-area']}
364
- >
365
356
  {
366
- buyCount
357
+ customization
367
358
  ? (
368
- <Text className={styles['buy-count-value']}>
369
- x{buyCount}
359
+ <Text
360
+ className={styles['customization-text']}
361
+ style={{ WebkitLineClamp: customizationMaxLines }}
362
+ >
363
+ {customization}
370
364
  </Text>
371
365
  )
372
- : action
366
+ : undefined
373
367
  }
368
+ {
369
+ combo
370
+ ? (
371
+ <Text
372
+ className={styles['customization-text']}
373
+ style={{ WebkitLineClamp: comboMaxLines }}
374
+ >
375
+ {combo}
376
+ </Text>
377
+ )
378
+ : undefined
379
+ }
380
+ </View>
381
+ <View className={styles['content-bottom']}>
382
+ <View className={styles['price-container']}>
383
+ <View className={styles['price-row']}>
384
+ <Text className={styles['price-symbol']}>
385
+ ¥
386
+ </Text>
387
+ <Text className={styles['price-value']}>
388
+ {salePrice}
389
+ </Text>
390
+ </View>
391
+ {
392
+ originalPrice
393
+ ? (
394
+ <Text className={styles['original-price']}>
395
+ ¥{originalPrice}
396
+ </Text>
397
+ )
398
+ : undefined
399
+ }
400
+ </View>
401
+ <View
402
+ className={styles['action-area']}
403
+ >
404
+ {
405
+ buyCount
406
+ ? (
407
+ <Text className={styles['buy-count-value']}>
408
+ x{buyCount}
409
+ </Text>
410
+ )
411
+ : action
412
+ }
413
+ </View>
374
414
  </View>
375
415
  </View>
376
416
  </View>
417
+ {
418
+ children
419
+ ? (
420
+ <View
421
+ className={styles['card-footer']}
422
+ onClick={e => e.stopPropagation()}
423
+ >
424
+ {children}
425
+ </View>
426
+ )
427
+ : undefined
428
+ }
377
429
  </View>
378
- {
379
- children
380
- ? (
381
- <View
382
- className={styles['card-footer']}
383
- onClick={e => e.stopPropagation()}
384
- >
385
- {children}
386
- </View>
387
- )
388
- : undefined
389
- }
390
430
  {
391
431
  showDelete
392
432
  ? (
@@ -410,4 +450,4 @@ const ProductCard: React.FC<IProductCardProps> = (props) => {
410
450
  )
411
451
  }
412
452
 
413
- export default React.memo(ProductCard)
453
+ export default React.memo(ProductItem)