File tree Expand file tree Collapse file tree 9 files changed +34
-2
lines changed Expand file tree Collapse file tree 9 files changed +34
-2
lines changed Original file line number Diff line number Diff line change 35
35
font-size : $cell-extra-font-size ;
36
36
color : $cell-extra-color ;
37
37
}
38
+ & :active ::before {
39
+ opacity : 0.1 ;
40
+ }
41
+ & -clickable {
42
+ cursor : pointer ;
43
+ & ::before {
44
+ position : absolute ;
45
+ top : 50% ;
46
+ left : 50% ;
47
+ width : 100% ;
48
+ height : 100% ;
49
+ background-color : $black ;
50
+ border : inherit ;
51
+ border-color : $black ;
52
+ border-radius : inherit ;
53
+ transform : translate (-50% , -50% );
54
+ opacity : 0 ;
55
+ content : ' ' ;
56
+ }
57
+ }
38
58
}
Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ export interface CellProps extends BasicComponent {
10
10
extra : ReactNode
11
11
radius : string | number
12
12
align : 'flex-start' | 'center' | 'flex-end'
13
+ clickable : boolean
13
14
onClick : ( event : React . MouseEvent < HTMLDivElement , MouseEvent > ) => void
14
15
}
15
16
@@ -20,6 +21,7 @@ const defaultProps = {
20
21
extra : null ,
21
22
radius : '6px' ,
22
23
align : 'flex-start' ,
24
+ clickable : false ,
23
25
onClick : ( event : React . MouseEvent < HTMLDivElement , MouseEvent > ) => { } ,
24
26
} as CellProps
25
27
@@ -39,6 +41,7 @@ export const Cell: FunctionComponent<
39
41
align,
40
42
className,
41
43
style,
44
+ clickable,
42
45
...rest
43
46
} = {
44
47
...defaultProps ,
@@ -63,7 +66,7 @@ export const Cell: FunctionComponent<
63
66
}
64
67
return (
65
68
< div
66
- className = { classNames ( classPrefix , className ) }
69
+ className = { ` ${ classNames ( classPrefix , className , clickable ? ` ${ classPrefix } -clickable` : '' ) } ` }
67
70
onClick = { ( event ) => handleClick ( event ) }
68
71
style = { baseStyle }
69
72
{ ...rest }
Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ export interface CellProps extends BasicComponent {
10
10
extra : ReactNode
11
11
radius : string | number
12
12
align : 'flex-start' | 'center' | 'flex-end'
13
+ clickable : boolean
13
14
onClick : ( event : React . MouseEvent < HTMLDivElement , MouseEvent > ) => void
14
15
}
15
16
@@ -20,6 +21,7 @@ const defaultProps = {
20
21
extra : null ,
21
22
radius : '6px' ,
22
23
align : 'flex-start' ,
24
+ clickable : false ,
23
25
onClick : ( event : React . MouseEvent < HTMLDivElement , MouseEvent > ) => { } ,
24
26
} as CellProps
25
27
@@ -31,6 +33,7 @@ export const Cell: FunctionComponent<
31
33
const ctx = useContext ( CellGroupContext )
32
34
const {
33
35
children,
36
+ clickable,
34
37
onClick,
35
38
title,
36
39
description,
@@ -63,7 +66,7 @@ export const Cell: FunctionComponent<
63
66
}
64
67
return (
65
68
< div
66
- className = { classNames ( classPrefix , className ) }
69
+ className = { ` ${ classNames ( classPrefix , className , clickable ? ` ${ classPrefix } -clickable` : '' ) } ` }
67
70
onClick = { ( event ) => handleClick ( event ) }
68
71
style = { baseStyle }
69
72
{ ...rest }
Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ const Demo1 = () => {
12
12
< Cell title = "我是标题" extra = "描述文字" />
13
13
< Cell title = "我是标题" description = "我是描述" extra = "描述文字" />
14
14
< Cell
15
+ clickable
15
16
title = "点击测试"
16
17
onClick = { (
17
18
event : React . MouseEvent < HTMLDivElement , globalThis . MouseEvent >
Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ const Demo1 = () => {
13
13
< Cell title = "我是标题" description = "我是描述" extra = "描述文字" />
14
14
< Cell
15
15
title = "点击测试"
16
+ clickable
16
17
onClick = { (
17
18
event : React . MouseEvent < HTMLDivElement , globalThis . MouseEvent >
18
19
) => testClick ( event ) }
Original file line number Diff line number Diff line change @@ -91,6 +91,7 @@ The 'divider' property allows you to keep the lower edge from being displayed be
91
91
| extra | Extra | ` ReactNode ` | ` - ` |
92
92
| radius | Corner radius | ` string ` | ` 6px ` |
93
93
| align | Alignment in the vertical direction | ` flex-start ` \| ` center ` \| ` flex-end ` | ` flex-start ` |
94
+ | clickable | click style feedback | ` boolean ` | ` false ` |
94
95
| onClick | Emitted when cell is clicked | ` onClick: (event: React.MouseEvent<HTMLDivElement, globalThis.MouseEvent>) => void ` | ` false ` |
95
96
96
97
## Theming
Original file line number Diff line number Diff line change @@ -93,6 +93,7 @@ import { Cell } from '@nutui/nutui-react'
93
93
| extra | 右侧描述 | ` ReactNode ` | ` - ` |
94
94
| radius | 圆角半径 | ` string ` | ` 6px ` |
95
95
| align | 纵轴方向上的对齐方式 | ` flex-start ` \| ` center ` \| ` flex-end ` | ` flex-start ` |
96
+ | clickable | 点击的样式反馈 | ` boolean ` | ` false ` |
96
97
| onClick | 点击事件 | ` onClick: (event: React.MouseEvent<HTMLDivElement, globalThis.MouseEvent>) => void ` | ` false ` |
97
98
98
99
## 主题定制
Original file line number Diff line number Diff line change @@ -92,6 +92,7 @@ import { Cell } from '@nutui/nutui-react-taro'
92
92
| extra | 右侧描述 | ` ReactNode ` | ` - ` |
93
93
| radius | 圆角半径 | ` string ` | ` 6px ` |
94
94
| align | 纵轴方向上的对齐方式 | ` flex-start ` \| ` center ` \| ` flex-end ` | ` flex-start ` |
95
+ | clickable | 点击的样式反馈 | ` boolean ` | ` false ` |
95
96
| onClick | 点击事件 | ` onClick: (event: React.MouseEvent<HTMLDivElement, globalThis.MouseEvent>) => void ` | ` false ` |
96
97
97
98
## 主题定制
Original file line number Diff line number Diff line change @@ -93,6 +93,7 @@ import { Cell } from '@nutui/nutui-react'
93
93
| extra | 右側描述 | ` ReactNode ` | ` - ` |
94
94
| radius | 圓角半徑 | ` string ` | ` 6px ` |
95
95
| align | 縱軸方向上的對齊方式 | ` flex-start ` \| ` center ` \| ` flex-end ` | ` flex-start ` |
96
+ | clickable | 點擊的樣式反饋 | ` boolean ` | ` false ` |
96
97
| onClick | 點擊事件 | ` onClick: (event: React.MouseEvent<HTMLDivElement, globalThis.MouseEvent>) => void ` | ` false ` |
97
98
98
99
## 主題定製
You can’t perform that action at this time.
0 commit comments