Skip to content

Commit

Permalink
docs(dialog): add international desc
Browse files Browse the repository at this point in the history
  • Loading branch information
richard1015 committed Apr 20, 2022
1 parent ca10678 commit 7e385c3
Show file tree
Hide file tree
Showing 7 changed files with 287 additions and 60 deletions.
85 changes: 57 additions & 28 deletions src/packages/__VUE/dialog/demo.vue
Original file line number Diff line number Diff line change
@@ -1,43 +1,71 @@
<template>
<div class="demo">
<nut-cell-group title="函数式调用">
<nut-cell title="基础弹框" @click="baseClick"></nut-cell>
<nut-cell title="无标题弹框" @click="noTitleClick"></nut-cell>
<nut-cell title="提示弹框" @click="tipsClick"></nut-cell>
<nut-cell title="底部按钮 垂直调用" @click="verticalClick"></nut-cell>
<nut-cell-group :title="translate('funUse')">
<nut-cell :title="translate('basic')" @click="baseClick"></nut-cell>
<nut-cell :title="translate('noTitle')" @click="noTitleClick"></nut-cell>
<nut-cell :title="translate('tipDialog')" @click="tipsClick"></nut-cell>
<nut-cell :title="translate('title')" @click="verticalClick"></nut-cell>
</nut-cell-group>
<nut-cell-group title="标签式使用">
<nut-cell title="组件调用" @click="componentClick"></nut-cell>
<nut-cell-group :title="translate('title1')">
<nut-cell :title="translate('title1')" @click="componentClick"></nut-cell>
<nut-dialog
teleport="#app"
title="组件调用"
content="如果需要在弹窗内嵌入组件或其他自定义内容,可以使用组件调用的方式。"
:title="translate('title1')"
:content="translate('content')"
v-model:visible="visible"
>
</nut-dialog>
<nut-cell title="底部按钮 垂直使用" @click="componentvVrticalClick"></nut-cell>
<nut-cell :title="translate('title')" @click="componentvVrticalClick"></nut-cell>
<nut-dialog
footer-direction="vertical"
teleport="#app"
title="组件调用"
content="如果需要在弹窗内嵌入组件或其他自定义内容,可以使用组件调用的方式。"
:title="translate('title1')"
:content="translate('content')"
v-model:visible="visible1"
>
</nut-dialog>
</nut-cell-group>
<nut-cell-group title="teleport 使用,挂载到指定节点">
<nut-cell title="body 节点下" @click="teleportClick('body')"></nut-cell>
<nut-cell title="#app 节点下" @click="teleportClick('#app')"></nut-cell>
<nut-cell title="demo class 元素节点下" @click="teleportClick('.demo')"></nut-cell>
<nut-cell-group :title="translate('title2')">
<nut-cell title="body element node" @click="teleportClick('body')"></nut-cell>
<nut-cell title="#app element node" @click="teleportClick('#app')"></nut-cell>
<nut-cell title="demo class element node" @click="teleportClick('.demo')"></nut-cell>
</nut-cell-group>
</div>
</template>
<script lang="ts">
import { ref } from 'vue';
import { createComponent } from '@/packages/utils/create';
const { createDemo } = createComponent('dialog');
const { createDemo, translate } = createComponent('dialog');
import { Dialog } from '@/packages/nutui.vue';
import { useTranslate } from '@/sites/assets/util/useTranslate';
useTranslate({
'zh-CN': {
funUse: '函数式调用',
basic: '基础弹框',
noTitle: '无标题弹框',
tipDialog: '提示弹框',
tips: '提示',
title: '底部按钮 垂直使用',
title1: '标签式使用',
title2: 'Teleport 使用,挂载到指定节点',
content: '支持函数调用和组件调用两种方式。',
content1: '支持底部按钮纵向排列。',
content2: '打开开发者工具看一下 Elements Tab'
},
'en-US': {
funUse: 'Function use',
basic: 'Basic Usage',
noTitle: 'No Title',
tipDialog: 'Tips Dialog',
tips: 'Tips',
title: 'Bottom button vertical use',
title1: 'Template use',
title2: 'Teleport use, mount to the specified element node',
content: 'Function call and template call are supported.',
content1: 'Support vertical arrangement of bottom buttons.',
content2: 'Open the developer tool and take a look at the Elements tab'
}
});
export default createDemo({
setup() {
const visible = ref(false);
Expand All @@ -52,32 +80,32 @@ export default createDemo({
const baseClick = (): void => {
Dialog({
title: '基础弹框',
content: '支持函数调用和组件调用两种方式。',
title: translate('basic'),
content: translate('content'),
onCancel,
onOk
});
};
const noTitleClick = () => {
Dialog({
content: '无标题弹框',
content: translate('noTitle'),
onCancel,
onOk
});
};
const tipsClick = () => {
Dialog({
title: '温馨提示',
content: '支持函数调用和组件调用两种方式。',
title: translate('tips'),
content: translate('content'),
noCancelBtn: true,
onCancel,
onOk
});
};
const verticalClick = () => {
Dialog({
title: '温馨提示',
content: '支持底部按钮纵向排列。',
title: translate('tips'),
content: translate('content1'),
footerDirection: 'vertical',
onCancel,
onOk
Expand All @@ -94,8 +122,8 @@ export default createDemo({
const teleportClick = (teleport: string) => {
Dialog({
teleport,
title: '挂载至 ' + teleport,
content: '打开开发者工具看一下 Elements Tab',
title: 'teleport to ' + teleport,
content: translate('content2'),
noCancelBtn: true,
onCancel
});
Expand All @@ -110,7 +138,8 @@ export default createDemo({
componentvVrticalClick,
tipsClick,
verticalClick,
teleportClick
teleportClick,
translate
};
}
});
Expand Down
226 changes: 226 additions & 0 deletions src/packages/__VUE/dialog/doc.en-US.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,226 @@
# Dialog


### Intro

Modal dialog box is displayed in the floating layer to guide users to carry out relevant operations. It is often used for message prompt, message confirmation, or completing specific interactive operations in the current page.

The popup box component supports function call and component call.

### Install

```javascript
import { createApp } from 'vue';
import { Dialog,Popup,OverLay } from '@nutui/nutui';

const app = createApp();
app.use(Dialog).use(Popup).use(OverLay)
```


## Function use

:::demo
```html
<template>
<nut-cell-group title="Function Use">
<nut-cell title="Title" @click="baseClick"></nut-cell>
<nut-cell title="Title" @click="noTitleClick"></nut-cell>
<nut-cell title="Title" @click="tipsClick"></nut-cell>
<nut-cell title="Title" @click="verticalClick"></nut-cell>
</nut-cell-group>
</template>
<script lang="ts">
import { ref } from 'vue';
import { Dialog } from '@nutui/nutui';
export default {
setup() {
const onCancel = () => {
console.log('event cancel');
};
const onOk = () => {
console.log('event ok');
};
const baseClick = (): void => {
Dialog({
title: 'Basic spring frame',
content: 'Function call and component call are supported.',
onCancel,
onOk
});
};
const noTitleClick = () => {
Dialog({
content: 'Content',
onCancel,
onOk
});
};
const tipsClick = () => {
Dialog({
title: 'Title',
content: 'Function call and component call are supported.',
noCancelBtn: true,
onCancel,
onOk
});
};
const verticalClick = () => {
Dialog({
title: 'Title',
content: 'Support vertical arrangement of bottom buttons.',
footerDirection: 'vertical',
onCancel,
onOk
});
};
return {
baseClick,
noTitleClick,
tipsClick,
verticalClick
};
}
}
</script>
```
:::

## Teleport use, mount to the specified element node

``` html
<nut-dialog teleport="#app" ... />
```

``` javascript
Dialog({
teleport: '#app',
...
});
Dialog({
teleport: '.demo',
...
});
```

## Function use proxy.&dialog(...)

```javascript
import { ref } from 'vue';
import { Dialog } from '@nutui/nutui';
import { getCurrentInstance } from 'vue';

export default {
setup() {
const { proxy } = getCurrentInstance();
proxy.$dialog({
title: 'Basic spring frame',
content: 'Function call and component call are supported.'
});
}
}
```


## Template use


:::demo
```html
<template>
<nut-cell-group title="Template use">
<nut-cell title="Template use" @click="componentClick"></nut-cell>
<nut-dialog
teleport="#app"
title="Template use"
content="Function call and template call are supported."
v-model:visible="visible"
>
</nut-dialog>
<nut-cell title="Bottom button vertical use" @click="componentvVrticalClick"></nut-cell>
<nut-dialog
footer-direction="vertical"
teleport="#app"
title="Template use"
content="Function call and template call are supported."
v-model:visible="visible1"
>
</nut-dialog>
</nut-cell-group>
</template>
<script lang="ts">
import { ref } from 'vue';
export default {
setup() {
const visible = ref(false);
const visible1 = ref(false);
const componentClick = () => {
visible.value = true;
};
const componentvVrticalClick = () => {
visible1.value = true;
};
return { visible,visible1,componentClick,componentvVrticalClick };
}
}
</script>
```
:::

## API
| Attribute | Description | Type | Default |
|---------------------|--------------------------------------------------------------------------------|------------------|----------------------|
| title | Title | String | - |
| id | Identifier, share one instance at the same time, default to multiple instances | String or Number | new Date().getTime() |
| content | Content, support HTML | String | - |
| teleport | Specifies a target element where Dialog will be mounted | String | "body" |
| closeOnClickOverlay | Whether to close when overlay is clicked | Boolean | false |
| noFooter | Hide bottom button bar | Boolean | false |
| noOkBtn | Hide OK button | Boolean | false |
| noCancelBtn | Hide cancel button | Boolean | false |
| cancelText | Cancel button text | String | "Cancel" |
| okText | OK button text | String | "Confirm" |
| cancelAutoClose | Click Cancel to close the popup | Boolean | true |
| textAlign | Text alignment direction, the optional value is the same as css text-align | String | "center" |
| closeOnPopstate | Whether to close when popstate | Boolean | false |
| onUpdate | Update | Boolean | false |
| onOk | Emitted when the confirm button is clicked | Function | - |
| onCancel | Emitted when the cancel button is clicked | Function | - |
| onClosed | Emitted when Dialog is closed | Function | - |


## Props

| Attribute | Description | Type | Default |
|------------------------|-----------------------------------------------------------------------------------------------------------|---------|------------|
| title | Title | String | - |
| content | Content, support HTML | String | - |
| teleport | Specifies a target element where Dialog will be mounted | String | "body" |
| close-on-click-overlay | Whether to close when overlay is clicked | Boolean | false |
| no-footer | Hide bottom button bar | Boolean | false |
| no-ok-btn | Hide OK button | Boolean | false |
| no-cancel-btn | Hide cancel button | Boolean | false |
| cancel-text | Cancel button text | String | "Cancel" |
| ok-text | OK button text | String | "Confirm" |
| cancel-auto-close | Click Cancel to close the popup | Boolean | true |
| text-align | Text alignment direction, the optional value is the same as css text-align | String | "center" |
| close-on-popstate | Whether to close when popstate | Boolean | false |
| lock-scroll | Whether to lock background scroll | Boolean | false |
| footer-direction | The bottom button uses the horizontal and vertical directions. Optional values ​​are horizontal and vertical. | string | horizontal |

## Events

| Event | Description | Type | Default |
|--------|--------------------------------------------|----------|---------|
| ok | Emitted when the confirm button is clicked | Function | - |
| cancel | Emitted when the cancel button is clicked | Function | - |
| closed | Emitted when Dialog is closed | Function | - |


## Slots

| Name | Description |
|---------|----------------|
| header | Custom title |
| default | Custom default |
| footer | Custom footer |
Loading

0 comments on commit 7e385c3

Please sign in to comment.