Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: modal mini #1159

Open
wants to merge 6 commits into
base: next
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
chore: modal mini
  • Loading branch information
Yang committed Dec 14, 2023
commit ece9be422a459e8eeff3d740bb122afb1cbf8526
2 changes: 1 addition & 1 deletion packages/mini-demo/order.json
Original file line number Diff line number Diff line change
@@ -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}}
{"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"}}
1 change: 1 addition & 0 deletions packages/mini-demo/src/app.config.ts
Original file line number Diff line number Diff line change
@@ -8,6 +8,7 @@ export default defineAppConfig({
'pages/tabs/index',
'pages/input/index',
'pages/swipe-action/index',
'pages/modal/index',
],
window: {
backgroundTextStyle: 'light',
37 changes: 37 additions & 0 deletions packages/mini-demo/src/pages/checkbox/component/custom-icon.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import React from 'react';
import { List, Checkbox, Panel } from 'zarm/mini';
import { Star, StarFill, Success, Close } from '@zarm-design/icons';

/* order: 6 */

const Demo = () => {
return (
<Panel title="自定义icon">
<List>
<List.Item>
<Checkbox.Group>
<Checkbox
value="0"
renderIcon={({ checked }) =>
checked ? <Success theme="primary" style={{ color: 'var(--za-theme-primary)'}} /> : <Close theme="danger" />
}
>
选项一
</Checkbox>
<Checkbox
value="1"
renderIcon={({ checked }) =>
checked ? <StarFill theme="primary" style={{ color: 'var(--za-theme-primary)'}}/> : <Star theme="primary" />
}
>
选项二
</Checkbox>
<Checkbox value="2">选项三</Checkbox>
</Checkbox.Group>
</List.Item>
</List>
</Panel>
)
}

export default Demo;
73 changes: 73 additions & 0 deletions packages/mini-demo/src/pages/checkbox/component/custom.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
import React, { useState, useRef } from 'react';
import { List, Checkbox, Panel } from 'zarm/mini';
import { Success } from '@zarm-design/icons';
import { View } from '@tarojs/components';

/* order: 6 */

const items = ['选项一', '选项二', '选项三'];

const Demo = () => {
const [value, setValue] = useState(['0']);

const onChange = (v) => {
console.log('onChange', v);
setValue(v);
};

const CustomCheckbox = (props) => {
return (
<Checkbox
value={props.value}
>
{({ checked }) => (
<View
style={{
position: 'relative',
padding: '4px 8px',
fontSize: 14,
borderWidth: '1px',
borderStyle: 'solid',
borderColor: checked ? 'var(--za-theme-primary)' : 'var(--za-theme-default)',
}}
>
<View
style={{
display: checked ? 'inline-block' : 'none',
position: 'absolute',
right: 0,
top: 0,
fontSize: 0,
}}
>
<Success style={{ fontSize: 10 }} theme="primary" />
</View>
{props.label}
</View>
)}
</Checkbox>
);
};
return (
<Panel title="自定义">
<List>
<List.Item>
<Checkbox.Group
value={value}
onChange={onChange}
style={{
'--group-spacing-horizontal': '8px',
'--group-spacing-vertical': '6px',
}}
>
{items.map((item, index) => (
<CustomCheckbox key={+index} value={String(index)} label={item} />
))}
</Checkbox.Group>
</List.Item>
</List>
</Panel>
);
};

export default Demo;
57 changes: 57 additions & 0 deletions packages/mini-demo/src/pages/modal/component/alert.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import React from 'react';
import { List, Button, Modal, Panel } from 'zarm/mini';
import { View } from '@tarojs/components';

/* order: 1 */

const Demo = () => {
return (
<Panel title="警告框 Alert">
<List>
<List.Item
title="静态方法关闭"
suffix={
<Button
size="xs"
onClick={() => {
Modal.alert({
className: 'test',
title: '警告框标题',
content: '这里是警告框的内容部分',
onConfirm: () => {
console.log('点击确认');
},
});
}}
>
开启
</Button>
}
/>
<List.Item
title="使用 Promise 关闭"
suffix={
<Button
size="xs"
onClick={() => {
Modal.alert({
title: '警告框标题',
content: '这里是警告框的内容部分,点击关闭按钮,将触发 Promise 关闭警告框',
onConfirm: async () => {
await new Promise((resolve) => setTimeout(resolve, 3000));
// Toast.show({ content: '提交成功' });
},
});
}}
>
开启
</Button>
}
/>
</List>
<View id="modal-alert" />
</Panel>
);
};

export default Demo;
Loading