Skip to content

Commit ece9be4

Browse files
author
Yang
committed
chore: modal mini
1 parent 4306793 commit ece9be4

23 files changed

Lines changed: 1117 additions & 3 deletions

File tree

packages/mini-demo/order.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"input":{"AutoHeight":"6","Basic":"1","Clearable":"2","Disabled":"5","Native":"3","ReadOnly":"4","ShowLength":"7","Vertical":"8","Readonly":"4","Disable":0},"swipe-action":{"Basic":0}}
1+
{"input":{"AutoHeight":"6","Basic":"1","Clearable":"2","Disabled":"5","Native":"3","ReadOnly":"4","ShowLength":"7","Vertical":"8","Readonly":"4","Disable":0},"swipe-action":{"Basic":0},"modal":{"Basic":"1","Button":"2","Alert":"1"}}

packages/mini-demo/src/app.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ export default defineAppConfig({
88
'pages/tabs/index',
99
'pages/input/index',
1010
'pages/swipe-action/index',
11+
'pages/modal/index',
1112
],
1213
window: {
1314
backgroundTextStyle: 'light',
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import React from 'react';
2+
import { List, Checkbox, Panel } from 'zarm/mini';
3+
import { Star, StarFill, Success, Close } from '@zarm-design/icons';
4+
5+
/* order: 6 */
6+
7+
const Demo = () => {
8+
return (
9+
<Panel title="自定义icon">
10+
<List>
11+
<List.Item>
12+
<Checkbox.Group>
13+
<Checkbox
14+
value="0"
15+
renderIcon={({ checked }) =>
16+
checked ? <Success theme="primary" style={{ color: 'var(--za-theme-primary)'}} /> : <Close theme="danger" />
17+
}
18+
>
19+
选项一
20+
</Checkbox>
21+
<Checkbox
22+
value="1"
23+
renderIcon={({ checked }) =>
24+
checked ? <StarFill theme="primary" style={{ color: 'var(--za-theme-primary)'}}/> : <Star theme="primary" />
25+
}
26+
>
27+
选项二
28+
</Checkbox>
29+
<Checkbox value="2">选项三</Checkbox>
30+
</Checkbox.Group>
31+
</List.Item>
32+
</List>
33+
</Panel>
34+
)
35+
}
36+
37+
export default Demo;
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
import React, { useState, useRef } from 'react';
2+
import { List, Checkbox, Panel } from 'zarm/mini';
3+
import { Success } from '@zarm-design/icons';
4+
import { View } from '@tarojs/components';
5+
6+
/* order: 6 */
7+
8+
const items = ['选项一', '选项二', '选项三'];
9+
10+
const Demo = () => {
11+
const [value, setValue] = useState(['0']);
12+
13+
const onChange = (v) => {
14+
console.log('onChange', v);
15+
setValue(v);
16+
};
17+
18+
const CustomCheckbox = (props) => {
19+
return (
20+
<Checkbox
21+
value={props.value}
22+
>
23+
{({ checked }) => (
24+
<View
25+
style={{
26+
position: 'relative',
27+
padding: '4px 8px',
28+
fontSize: 14,
29+
borderWidth: '1px',
30+
borderStyle: 'solid',
31+
borderColor: checked ? 'var(--za-theme-primary)' : 'var(--za-theme-default)',
32+
}}
33+
>
34+
<View
35+
style={{
36+
display: checked ? 'inline-block' : 'none',
37+
position: 'absolute',
38+
right: 0,
39+
top: 0,
40+
fontSize: 0,
41+
}}
42+
>
43+
<Success style={{ fontSize: 10 }} theme="primary" />
44+
</View>
45+
{props.label}
46+
</View>
47+
)}
48+
</Checkbox>
49+
);
50+
};
51+
return (
52+
<Panel title="自定义">
53+
<List>
54+
<List.Item>
55+
<Checkbox.Group
56+
value={value}
57+
onChange={onChange}
58+
style={{
59+
'--group-spacing-horizontal': '8px',
60+
'--group-spacing-vertical': '6px',
61+
}}
62+
>
63+
{items.map((item, index) => (
64+
<CustomCheckbox key={+index} value={String(index)} label={item} />
65+
))}
66+
</Checkbox.Group>
67+
</List.Item>
68+
</List>
69+
</Panel>
70+
);
71+
};
72+
73+
export default Demo;
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
import React from 'react';
2+
import { List, Button, Modal, Panel } from 'zarm/mini';
3+
import { View } from '@tarojs/components';
4+
5+
/* order: 1 */
6+
7+
const Demo = () => {
8+
return (
9+
<Panel title="警告框 Alert">
10+
<List>
11+
<List.Item
12+
title="静态方法关闭"
13+
suffix={
14+
<Button
15+
size="xs"
16+
onClick={() => {
17+
Modal.alert({
18+
className: 'test',
19+
title: '警告框标题',
20+
content: '这里是警告框的内容部分',
21+
onConfirm: () => {
22+
console.log('点击确认');
23+
},
24+
});
25+
}}
26+
>
27+
开启
28+
</Button>
29+
}
30+
/>
31+
<List.Item
32+
title="使用 Promise 关闭"
33+
suffix={
34+
<Button
35+
size="xs"
36+
onClick={() => {
37+
Modal.alert({
38+
title: '警告框标题',
39+
content: '这里是警告框的内容部分,点击关闭按钮,将触发 Promise 关闭警告框',
40+
onConfirm: async () => {
41+
await new Promise((resolve) => setTimeout(resolve, 3000));
42+
// Toast.show({ content: '提交成功' });
43+
},
44+
});
45+
}}
46+
>
47+
开启
48+
</Button>
49+
}
50+
/>
51+
</List>
52+
<View id="modal-alert" />
53+
</Panel>
54+
);
55+
};
56+
57+
export default Demo;

0 commit comments

Comments
 (0)