@yorkjs/hive-ui 2.0.4 → 2.0.5

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": "2.0.4",
3
+ "version": "2.0.5",
4
4
  "description": "Hive UI - Taro React component library",
5
5
  "main": "src/index.ts",
6
6
  "module": "src/index.ts",
@@ -0,0 +1,59 @@
1
+ @import '../../styles/mixin.styl'
2
+ @import '../../styles/variable.styl'
3
+
4
+ .section-card-wrapper
5
+ display flex
6
+ flex-direction column
7
+
8
+ &.show-top-gutter
9
+ margin-top $GUTTER_BLANK
10
+
11
+ &.show-bottom-gutter
12
+ margin-bottom $GUTTER_BLANK
13
+
14
+ &.show-top-blank
15
+ margin-top 15PX
16
+
17
+ .section-header
18
+ padding 0 12PX
19
+ font-size 15PX
20
+ color var(--textContent)
21
+ line-height 21PX
22
+ margin 0 12PX
23
+ margin-bottom 11PX
24
+
25
+ .section-card-body
26
+ overflow hidden
27
+
28
+ .main-content
29
+ padding 13PX 15PX
30
+ display flex
31
+ flex-direction row
32
+ justify-content space-between
33
+ align-items center
34
+
35
+ // &.is-clickable:active
36
+ // background-color rgba(0, 0, 0, 0.02)
37
+
38
+ .info-body
39
+ flex 1
40
+ min-width 0
41
+
42
+ .info-title
43
+ font-size 16PX
44
+ color var(--textTitle)
45
+ line-height 23PX
46
+ margin-bottom 4PX
47
+
48
+ .info-desc
49
+ font-size 12PX
50
+ color var(--textContent)
51
+ line-height 17PX
52
+
53
+ .arrow-box
54
+ margin-left 12PX
55
+ flex-shrink 0
56
+
57
+ .section-footer
58
+ width 100%
59
+ border-top 1PX solid var(--lineBorder)
@@ -0,0 +1,150 @@
1
+ import React from 'react'
2
+ import { View, Text } from '@tarojs/components'
3
+ import { formatClassNames } from '../../util/function'
4
+
5
+ import styles from './index.module.styl'
6
+ import Card from '../Card'
7
+ import Icon from '../Icon'
8
+
9
+ export interface SectionCardProps {
10
+ /** 顶部的外置标题(如:4月29日) */
11
+ sectionTitle?: React.ReactNode
12
+ title?: React.ReactNode
13
+ /** 中间多行描述 */
14
+ contents?: React.ReactNode[]
15
+ arrow?: 'right' | 'down' | 'none'
16
+ arrowColor?: string
17
+ /** 底部自定义区域 */
18
+ children?: React.ReactNode
19
+ /** 点击回调 */
20
+ onClick?: () => void
21
+ /** 外部样式类 */
22
+ className?: string
23
+ /** 间距控制属性 */
24
+ showTopGutter?: boolean
25
+ showBottomGutter?: boolean
26
+ showTopBlank?: boolean
27
+ }
28
+
29
+ const SectionCard: React.FC<SectionCardProps> = (props) => {
30
+ const {
31
+ sectionTitle,
32
+ title,
33
+ contents = [],
34
+ children,
35
+ onClick,
36
+ className,
37
+ arrow = 'none',
38
+ arrowColor = 'var(--textPlaceholder)',
39
+ showTopGutter = false,
40
+ showBottomGutter = false,
41
+ showTopBlank = false,
42
+ } = props
43
+
44
+ const wrapperClass = formatClassNames(
45
+ styles['section-card-wrapper'],
46
+ {
47
+ [styles['show-top-gutter']]: showTopGutter,
48
+ [styles['show-bottom-gutter']]: showBottomGutter,
49
+ [styles['show-top-blank']]: showTopBlank,
50
+ },
51
+ className
52
+ )
53
+
54
+ return (
55
+ <View
56
+ className={wrapperClass}
57
+ >
58
+ {
59
+ sectionTitle
60
+ ? (
61
+ <View
62
+ className={styles['section-header']}
63
+ >
64
+ {
65
+ typeof sectionTitle === 'string'
66
+ ? (<Text>{sectionTitle}</Text>)
67
+ : sectionTitle
68
+ }
69
+ </View>
70
+ )
71
+ : undefined
72
+ }
73
+
74
+ <Card
75
+ className={styles['section-card-body']}
76
+ >
77
+ <View
78
+ className={formatClassNames(styles['main-content'], {
79
+ [styles['is-clickable']]: !!onClick
80
+ })}
81
+ onClick={onClick}
82
+ >
83
+ <View
84
+ className={styles['info-body']}
85
+ >
86
+ {
87
+ title
88
+ ? (
89
+ <View
90
+ className={styles['info-title']}
91
+ >
92
+ {
93
+ typeof title === 'string'
94
+ ? (<Text>{title}</Text>)
95
+ : title
96
+ }
97
+ </View>
98
+ )
99
+ : undefined
100
+ }
101
+ {
102
+ contents.map((item, index) => (
103
+ <View
104
+ key={index}
105
+ className={styles['info-desc']}
106
+ >
107
+ {
108
+ typeof item === 'string'
109
+ ? (<Text>{item}</Text>)
110
+ : item
111
+ }
112
+ </View>
113
+ ))
114
+ }
115
+ </View>
116
+
117
+ {
118
+ arrow && arrow !== 'none'
119
+ ? (
120
+ <View
121
+ className={styles['arrow-box']}
122
+ >
123
+ <Icon
124
+ name={arrow}
125
+ size={14}
126
+ color={arrowColor}
127
+ />
128
+ </View>
129
+ )
130
+ : undefined
131
+ }
132
+ </View>
133
+
134
+ {
135
+ children
136
+ ? (
137
+ <View
138
+ className={styles['section-footer']}
139
+ >
140
+ {children}
141
+ </View>
142
+ )
143
+ : undefined
144
+ }
145
+ </Card>
146
+ </View>
147
+ )
148
+ }
149
+
150
+ export default React.memo(SectionCard)
package/src/index.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  export { setGlobalTheme, useTheme } from './config'
2
2
 
3
+ export { default as Card } from './components/Card'
3
4
  export { default as NumberKeyboard } from './components/NumberKeyboard'
4
5
  export { default as Cell, setCellConfig } from './components/Cell'
5
6
  export { default as Icon } from './components/Icon'
@@ -7,10 +8,11 @@ export { default as Checkbox } from './components/Checkbox'
7
8
  export { default as Tag } from './components/Tag'
8
9
  export { default as FieldCard } from './components/FieldCard'
9
10
  export { default as DisplayCard } from './components/DisplayCard'
10
- export { default as Card } from './components/Card'
11
+ export { default as SectionCard } from './components/SectionCard'
11
12
  export { default as RemoteImage } from './components/RemoteImage'
12
13
  export { default as Alert } from './components/Alert'
13
14
  export { default as Switch } from './components/Switch'
14
15
 
15
16
  export { default as FlowItem } from './item/FlowItem'
17
+ export { default as ListItem } from './item/ListItem'
16
18
  export { default as ProductItem, setProductItemConfig } from './item/ProductItem'
@@ -0,0 +1,60 @@
1
+ @import '../../styles/mixin.styl'
2
+
3
+ $saas_padding = 15PX
4
+
5
+ .list-item-card
6
+ padding $saas_padding
7
+ padding-bottom 0
8
+ position relative
9
+
10
+ .card-main-body
11
+ display flex
12
+ flex-direction row
13
+ justify-content space-between
14
+ align-items flex-start
15
+ padding-bottom $saas_padding
16
+
17
+ &.show-separator
18
+ halfBorder(bottom, var(--lineBorder))
19
+
20
+ &.no-footer
21
+ padding-bottom $saas_padding
22
+
23
+ .card-info
24
+ flex 1
25
+ display flex
26
+ flex-direction column
27
+ min-width 0
28
+
29
+ .card-title
30
+ font-size 16PX
31
+ color var(--textTitle)
32
+ line-height 23PX
33
+ margin-bottom 9PX
34
+ wordBreak()
35
+
36
+ .card-text-line
37
+ font-size 14PX
38
+ color var(--textTitle)
39
+ line-height 20PX
40
+ wordBreak()
41
+ & + .card-text-line
42
+ margin-top 6PX
43
+
44
+ .card-right-section
45
+ margin-left 10PX
46
+ flex-shrink 0
47
+ display flex
48
+ flex-direction row
49
+ align-items center
50
+
51
+ .extra-wrapper
52
+ display flex
53
+ align-items center
54
+
55
+ .internal-arrow
56
+ margin-left 10PX
57
+ flex-shrink 0
58
+
59
+ .card-footer
60
+ width 100%
@@ -0,0 +1,127 @@
1
+ import React from 'react'
2
+ import { View, Text } from '@tarojs/components'
3
+ import { formatClassNames } from '../../util/function'
4
+
5
+ import Card from '../../components/Card'
6
+
7
+ import styles from './index.module.styl'
8
+ import Icon from '../../components/Icon'
9
+
10
+ export interface ListItemCardProps {
11
+ /** 标题 */
12
+ title: React.ReactNode
13
+ /** 中间多行内容:支持字符串数组或 ReactNode 数组 */
14
+ contents?: React.ReactNode[]
15
+ /** 右侧额外区域:完全自定义 Tag */
16
+ extra?: React.ReactNode
17
+ /** 是否显示右侧内置箭头 */
18
+ showArrow?: boolean
19
+ /** 箭头颜色,默认 #CCCCCC */
20
+ arrowColor?: string
21
+ /** 底部操作区域(自定义按钮组等) */
22
+ footer?: React.ReactNode
23
+ /** 是否显示顶边距 (通常 10PX) */
24
+ showTopGutter?: boolean
25
+ /** 是否显示底边距 (通常 10PX) */
26
+ showBottomGutter?: boolean
27
+ /** 是否显示顶部大留白 (通常 16PX) */
28
+ showTopBlank?: boolean
29
+ /** 是否显示底部分割线 */
30
+ showSeparator?: boolean
31
+ /** 点击主体区域的回调 */
32
+ onClick?: () => void
33
+ /** 外部样式 */
34
+ className?: string
35
+ }
36
+
37
+ const ListItem: React.FC<ListItemCardProps> = (props) => {
38
+ const {
39
+ title,
40
+ contents = [],
41
+ extra,
42
+ showArrow = false,
43
+ arrowColor = 'var(--textPlaceholder)',
44
+ footer,
45
+ showTopGutter,
46
+ showBottomGutter,
47
+ showTopBlank,
48
+ showSeparator = false,
49
+ onClick,
50
+ className,
51
+ } = props
52
+
53
+ return (
54
+ <Card
55
+ className={formatClassNames(
56
+ styles['list-item-card'],
57
+ className
58
+ )}
59
+ showTopBlank={showTopBlank}
60
+ showTopGutter={showTopGutter}
61
+ showBottomGutter={showBottomGutter}
62
+ >
63
+ <View
64
+ className={
65
+ formatClassNames(styles['card-main-body'], {
66
+ [styles['show-separator']]: showSeparator,
67
+ [styles['no-footer']]: !footer
68
+ })}
69
+ onClick={onClick}
70
+ >
71
+ <View className={styles['card-info']}>
72
+ <View className={styles['card-title']}>
73
+ {
74
+ typeof title === 'string'
75
+ ? <Text>{title}</Text>
76
+ : title
77
+ }
78
+ </View>
79
+
80
+ {contents.map((item, index) => (
81
+ <View key={index} className={styles['card-text-line']}>
82
+ {
83
+ typeof item === 'string'
84
+ ? <Text>{item}</Text>
85
+ : item
86
+ }
87
+ </View>
88
+ ))}
89
+ </View>
90
+
91
+ {(extra || showArrow) && (
92
+ <View className={styles['card-right-section']}>
93
+ {
94
+ extra
95
+ ? (
96
+ <View className={styles['extra-wrapper']}>
97
+ {extra}
98
+ </View>
99
+ )
100
+ : undefined
101
+ }
102
+ {showArrow && (
103
+ <Icon
104
+ name="right"
105
+ size={13}
106
+ color={arrowColor}
107
+ className={styles['internal-arrow']}
108
+ />
109
+ )}
110
+ </View>
111
+ )}
112
+ </View>
113
+
114
+ {
115
+ footer
116
+ ? (
117
+ <View className={styles['card-footer']}>
118
+ {footer}
119
+ </View>
120
+ )
121
+ : undefined
122
+ }
123
+ </Card>
124
+ )
125
+ }
126
+
127
+ export default React.memo(ListItem)