@yorkjs/hive-ui 0.1.0 → 0.1.2

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.0",
3
+ "version": "0.1.2",
4
4
  "description": "Hive UI - Taro React component library",
5
5
  "main": "src/index.ts",
6
6
  "module": "src/index.ts",
@@ -72,6 +72,7 @@ $DESC_FONT_SIZE = 13PX
72
72
  align-items center
73
73
 
74
74
  .title-section
75
+ display flex
75
76
  flex-shrink 0
76
77
  margin-right 10PX
77
78
 
@@ -0,0 +1,60 @@
1
+ @import '../../styles/mixin.styl'
2
+ @import '../../styles/variable.styl'
3
+
4
+ $CELL_PADDING_VERTICAL = 14PX
5
+
6
+ .field-card-container
7
+ border-radius 10PX
8
+ background-color var(--containerCard)
9
+ overflow hidden
10
+
11
+ .card-head-wrapper
12
+ padding 0PX $CELL_PADDING_VERTICAL
13
+
14
+ .card-header
15
+ display flex
16
+ flex-direction row
17
+ align-items center
18
+ justify-content space-between
19
+ padding 13PX 0PX
20
+ position relative
21
+ halfBorder(bottom, var(--lineBorder))
22
+
23
+ .header-left
24
+ flex 1
25
+ display flex
26
+ flex-direction row
27
+ align-items center
28
+ min-width 0
29
+
30
+ .header-title
31
+ color var(--textTitle)
32
+ font-size 14PX
33
+ line-height 1
34
+ lineClamp(1)
35
+
36
+ .edit-icon-wrapper
37
+ margin-left 2PX
38
+ display flex
39
+ align-items center
40
+ justify-content center
41
+ border-radius 4PX
42
+ transition background-color 0.2s
43
+
44
+ &:active
45
+ background-color rgba(0, 0, 0, 0.05)
46
+
47
+ .edit-icon
48
+ color var(--textMuted)
49
+
50
+ .header-extra
51
+ margin-left 12PX
52
+ flex-shrink 0
53
+ display flex
54
+ align-items center
55
+
56
+ .action-text
57
+ color var(--primary)
58
+ font-size 13PX
59
+ &:active
60
+ opacity 0.6
@@ -0,0 +1,101 @@
1
+ import React from 'react'
2
+ import { View, Text, ITouchEvent } from '@tarojs/components'
3
+ import { formatClassNames } from '../../util/function'
4
+ import Icon from '../Icon'
5
+ import styles from './index.module.styl'
6
+
7
+ export interface FieldCardProps {
8
+ /** 标题内容:支持字符串或自定义 DOM */
9
+ title: React.ReactNode
10
+ /** 是否显示标题旁的编辑小图标 */
11
+ showEditIcon?: boolean
12
+ /** 点击编辑图标的回调 */
13
+ onEditClick?: (e: ITouchEvent) => void
14
+ /** 右侧动作区域:支持字符串、Icon 或自定义节点 */
15
+ extra?: React.ReactNode
16
+ /** 点击右侧 extra 区域的回调 (会自动阻止冒泡) */
17
+ onExtraClick?: (e: ITouchEvent) => void
18
+ /** 子组件 */
19
+ children?: React.ReactNode
20
+ /** 外部样式 */
21
+ className?: string
22
+ }
23
+
24
+ const FieldCard: React.FC<FieldCardProps> = (props) => {
25
+ const {
26
+ title,
27
+ showEditIcon = false,
28
+ onEditClick,
29
+ extra,
30
+ onExtraClick,
31
+ children,
32
+ className
33
+ } = props
34
+
35
+ const handleEditClick = (e: ITouchEvent) => {
36
+ if (onEditClick) {
37
+ e.stopPropagation()
38
+ onEditClick(e)
39
+ }
40
+ }
41
+
42
+ const handleExtraClick = (e: ITouchEvent) => {
43
+ if (onExtraClick) {
44
+ e.stopPropagation()
45
+ onExtraClick(e)
46
+ }
47
+ }
48
+
49
+ return (
50
+ <View className={formatClassNames(styles['field-card-container'], className)}>
51
+ <View className={styles['card-head-wrapper']}>
52
+ <View className={styles['card-header']}>
53
+ <View className={styles['header-left']}>
54
+ {
55
+ typeof title === 'string'
56
+ ? (
57
+ <Text className={styles['header-title']}>{title}</Text>
58
+ )
59
+ : (
60
+ title
61
+ )
62
+ }
63
+
64
+ {showEditIcon && (
65
+ <View className={styles['edit-icon-wrapper']} onClick={handleEditClick}>
66
+ <Icon
67
+ name='edit'
68
+ size={14}
69
+ className={styles['edit-icon']}
70
+ />
71
+ </View>
72
+ )}
73
+ </View>
74
+
75
+ {extra && (
76
+ <View className={styles['header-extra']} onClick={handleExtraClick}>
77
+ {
78
+ typeof extra === 'string' ? (
79
+ <Text
80
+ className={styles['action-text']}
81
+ >
82
+ {extra}
83
+ </Text>
84
+ )
85
+ : (
86
+ extra
87
+ )
88
+ }
89
+ </View>
90
+ )}
91
+ </View>
92
+ </View>
93
+
94
+ <View className={styles['card-content']}>
95
+ {children}
96
+ </View>
97
+ </View>
98
+ )
99
+ }
100
+
101
+ export default FieldCard
@@ -19,4 +19,6 @@ export const PROMOTION_ACTIVITY_TYPE_BRAND = 2
19
19
  // 热点活动
20
20
  export const PROMOTION_ACTIVITY_TYPE_HOT = 3
21
21
  //买赠活动
22
- export const PROMOTION_ACTIVITY_TYPE_PRESENT = 4
22
+ export const PROMOTION_ACTIVITY_TYPE_PRESENT = 4
23
+ // 满减折扣
24
+ export const PROMOTION_ACTIVITY_TYPE_COUNT_DISCOUNT = 5
package/src/index.ts CHANGED
@@ -5,6 +5,7 @@ export { default as Cell, setCellConfig } from './components/Cell'
5
5
  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
+ export { default as FieldCard } from './components/FieldCard'
8
9
 
9
10
  export { default as FlowItem } from './item/FlowItem'
10
11
  export { default as ProductItem, setProductItemConfig } from './item/ProductItem'
@@ -19,6 +19,7 @@ import {
19
19
  PROMOTION_ACTIVITY_TYPE_BRAND,
20
20
  PROMOTION_ACTIVITY_TYPE_HOT,
21
21
  PROMOTION_ACTIVITY_TYPE_PRESENT,
22
+ PROMOTION_ACTIVITY_TYPE_COUNT_DISCOUNT,
22
23
  } from '../../constant/mall'
23
24
  import { getProductItemConfig } from './config'
24
25
 
@@ -27,7 +28,7 @@ import styles from './index.module.styl'
27
28
  export interface IProductCardLabels {
28
29
  product_type?: { real: string; virtual: string; service: string }
29
30
  delivery_type?: { dine: string; self_pickup: string; delivery: string }
30
- activity_type?: { flash: string; brand: string; hot: string; present: string }
31
+ activity_type?: { flash: string; brand: string; hot: string; present: string; full_discount: string }
31
32
  present_badge?: string
32
33
  stock_label?: string
33
34
  sale_label?: string
@@ -321,6 +322,7 @@ const ProductItem: React.FC<IProductCardProps> = (props) => {
321
322
  {activityType === PROMOTION_ACTIVITY_TYPE_BRAND && labels.activity_type.brand}
322
323
  {activityType === PROMOTION_ACTIVITY_TYPE_HOT && labels.activity_type.hot}
323
324
  {activityType === PROMOTION_ACTIVITY_TYPE_PRESENT && labels.activity_type.present}
325
+ {activityType === PROMOTION_ACTIVITY_TYPE_COUNT_DISCOUNT && labels.activity_type.full_discount}
324
326
  </Text>
325
327
  </View>
326
328
  </View>
@@ -16,7 +16,8 @@ let globalLabels: IProductCardLabels = {
16
16
  flash: '秒杀活动',
17
17
  brand: '品牌活动',
18
18
  hot: '热点活动',
19
- present: '买赠活动'
19
+ present: '买赠活动',
20
+ full_discount: '满件折扣'
20
21
  },
21
22
  present_badge: '赠',
22
23
  stock_label: '库存',