Browse Source

docs(drag,toast): add international en-us (#1334)

* fix: add new props

* docs: add drag international en-us

* fix: add drag 翻译
Drjingfubo 3 years ago
parent
commit
bf5a63930d

+ 1 - 1
src/packages/__VUE/actionsheet/demo.vue

@@ -81,7 +81,7 @@
 <script lang="ts">
 import { computed, reactive } from 'vue';
 import { createComponent } from '@/packages/utils/create';
-const { createDemo, translate } = createComponent('tabbar');
+const { createDemo, translate } = createComponent('actionsheet');
 import { useTranslate } from '@/sites/assets/util/useTranslate';
 useTranslate({
   'zh-CN': {

+ 35 - 11
src/packages/__VUE/drag/demo.vue

@@ -1,34 +1,57 @@
 <template>
   <div class="demo full">
-    <h2>基础用法</h2>
+    <h2>{{ translate('basic') }}</h2>
     <nut-drag :style="{ top: '120px', left: '8px' }">
-      <nut-button type="primary">触摸移动</nut-button>
+      <nut-button type="primary">{{ translate('dragBasic') }}</nut-button>
     </nut-drag>
-    <h2 style="top: 30px; position: relative">限制拖拽方向</h2>
+    <h2 style="top: 30px; position: relative">{{ translate('direction') }}</h2>
     <nut-drag direction="x" :style="{ top: '200px', left: '8px' }">
-      <nut-button type="primary">只能X轴拖拽</nut-button>
+      <nut-button type="primary">{{ translate('directionX') }}</nut-button>
     </nut-drag>
     <nut-drag direction="y" :style="{ top: '200px', right: '50px' }">
-      <nut-button type="primary">只能Y轴拖拽</nut-button>
+      <nut-button type="primary">{{ translate('directionY') }}</nut-button>
     </nut-drag>
-    <h2 style="top: 60px; position: relative">自动吸边</h2>
+    <h2 style="top: 60px; position: relative">{{ translate('attract') }}</h2>
     <nut-drag direction="x" :attract="true" :style="{ top: '275px', left: '8px' }">
-      <nut-button type="primary">拖动我</nut-button>
+      <nut-button type="primary">{{ translate('attractText') }}</nut-button>
     </nut-drag>
-    <h2 style="top: 90px; position: relative">限制拖动边界</h2>
+    <h2 style="top: 90px; position: relative">{{ translate('limitBoundaries') }}</h2>
     <div class="drag-boundary"></div>
     <nut-drag
       :boundary="{ top: 361, left: 9, bottom: bottom(), right: right() }"
       :style="{ top: '400px', left: '50px' }"
     >
-      <nut-button type="primary">限制拖拽边界</nut-button>
+      <nut-button type="primary">{{ translate('limitBoundaries') }}</nut-button>
     </nut-drag>
   </div>
 </template>
 
 <script lang="ts">
 import { createComponent } from '@/packages/utils/create';
-const { createDemo } = createComponent('drag');
+const { createDemo, translate } = createComponent('drag');
+import { useTranslate } from '@/sites/assets/util/useTranslate';
+useTranslate({
+  'zh-CN': {
+    basic: '基本用法',
+    dragBasic: '触摸移动',
+    direction: '限制拖拽方向',
+    directionX: '只能X轴拖动',
+    directionY: '只能Y轴拖动',
+    attract: '自动吸边',
+    attractText: '按钮',
+    limitBoundaries: '限制拖拽边界'
+  },
+  'en-US': {
+    basic: 'Basic Usage',
+    dragBasic: 'Button',
+    direction: 'Limit Direction',
+    directionX: 'X axis',
+    directionY: 'Y axis',
+    attract: 'Attract',
+    attractText: 'Button',
+    limitBoundaries: 'Limit Boundaries'
+  }
+});
 export default createDemo({
   setup() {
     function right() {
@@ -39,7 +62,8 @@ export default createDemo({
     }
     return {
       right,
-      bottom
+      bottom,
+      translate
     };
   }
 });

+ 97 - 0
src/packages/__VUE/drag/doc.en-US.md

@@ -0,0 +1,97 @@
+# Drag 
+### Intro
+
+Implement draggable arbitrary elements
+
+### Install
+
+``` javascript
+import { createApp } from 'vue';
+import { Drag } from '@nutui/nutui';
+
+const app = createApp();
+app.use(Drag);
+```
+
+## Basic Usage
+:::demo
+```html
+<template>
+ <nut-drag>
+      <nut-button type="primary">Button</nut-button>
+  </nut-drag>
+</template>
+```
+:::
+## Limit Direction
+:::demo
+```html
+<template>
+  <nut-drag direction="x" :style="{ top: '200px', left: '8px' }">
+      <nut-button type="primary">Button</nut-button>
+  </nut-drag>
+  </template>
+```
+:::
+## Attract
+:::demo
+```html
+<template>
+  <nut-drag
+      direction="x"
+      :attract="true"
+    >
+      <nut-button type="primary">Button</nut-button>
+    </nut-drag>
+    </template>
+```
+:::
+## Limit Boundaries
+:::demo
+```html
+<template>
+ <div class="drag-boundary"></div>
+    <nut-drag
+      :boundary="{ top: 100, left: 9, bottom: bottom(), right: right() }"
+      :style="{ top: '100px', left: '50px' }"
+    >
+      <nut-button type="primary">Button</nut-button>
+    </nut-drag>
+</template>
+<script>
+  export default {
+ setup() {
+    function right() {
+      return document.documentElement.clientWidth - 300 - 9;
+    }
+    function bottom() {
+      return document.documentElement.clientHeight - 300;
+    }
+    return {
+      right,
+      bottom
+    };
+  }
+  }
+</script>
+
+<style>
+.drag-boundary {
+  position: absolute;
+  top: 100px;
+  left: 8px;
+  width: 300px;
+  height: 200px;
+  border: 1px solid red;
+}
+</style>
+
+```
+:::
+## Prop
+
+| Attribute            | Description               | Type   | Default  |
+| :-------- | :------------------------------------------------ | :------------- | :---------------------------------- |
+| attract   | Whether to enable automatic edge suction  | Boolean        | false                                |
+| direction | The drag direction limit of the dragged element **x**/**y**/**all**| String   | 'all'         |
+| boundary  | The drag boundary of the dragged element   | Object         | {top: 0,left: 0,right: 0,bottom: 0} |

+ 2 - 0
src/packages/__VUE/numberkeyboard/doc.md

@@ -296,6 +296,8 @@ export default{
 | v-model:value | 当前输入值		 | String | - |
 | maxlength  | 输入值最大长度,结合 v-model 使用 | Number | String| 6 |
 | confirm-text  | 自定义完成按钮文字,如"支付","下一步","提交"等 | String | 完成 |
+| teleport    | 指定挂载节点(`小程序不支持`)   | String         | `"body"`      |
+| pop-class    | 自定义弹框类名     | String         | -             |
 
 
 ### Event

+ 5 - 0
src/packages/__VUE/numberkeyboard/index.taro.vue

@@ -2,6 +2,7 @@
   <nut-popup
     v-model:visible="show"
     position="bottom"
+    :popClass="popClass"
     :overlay="overlay"
     @click-overlay="closeBoard()"
     overlay-class="nut-numberkeyboard-overlay"
@@ -112,6 +113,10 @@ export default create({
     overlay: {
       type: Boolean,
       default: true
+    },
+    popClass: {
+      type: String,
+      default: ''
     }
   },
   emits: ['input', 'delete', 'close', 'update:value'],

+ 10 - 0
src/packages/__VUE/numberkeyboard/index.vue

@@ -2,6 +2,8 @@
   <nut-popup
     v-model:visible="show"
     position="bottom"
+    :teleport="teleport"
+    :popClass="popClass"
     :overlay="overlay"
     @click-overlay="closeBoard()"
     :isWrapTeleport="isWrapTeleport"
@@ -117,6 +119,14 @@ export default create({
     isWrapTeleport: {
       type: Boolean,
       default: true
+    },
+    teleport: {
+      type: [String, Element],
+      default: 'body'
+    },
+    popClass: {
+      type: String,
+      default: ''
     }
   },
   emits: ['input', 'delete', 'close', 'update:value'],

+ 48 - 16
src/packages/__VUE/toast/demo.vue

@@ -1,25 +1,56 @@
 <template>
   <div class="demo">
-    <h2>基本用法</h2>
-    <nut-cell title="Text 文字提示" is-link @click="textToast('网络失败,请稍后再试~')"></nut-cell>
-    <nut-cell title="Title 标题展示" is-link @click="titleToast('网络失败,请稍后再试~')"></nut-cell>
-    <nut-cell title="Success 成功提示" is-link @click="successToast('成功提示')"></nut-cell>
-    <nut-cell title="Error 失败提示" is-link @click="errorToast('失败提示')"></nut-cell>
-    <nut-cell title="Warning 警告提示" is-link @click="warningToast('警告提示')"></nut-cell>
-    <nut-cell title="Loading 加载提示" is-link @click="loadingToast('加载中')"></nut-cell>
-    <h2>Toast不消失</h2>
-    <nut-cell title="Toast 文字提示不消失" is-link @click="NoToast('Toast不消失~')"></nut-cell>
-    <h2>Toast自定义距离底部高度</h2>
-    <nut-cell title="Toast 自定义底部高度" is-link @click="BottomToast('自定义距离~')"></nut-cell>
-    <h2>Loading带透明遮罩</h2>
-    <nut-cell title="带文案+带透明遮罩+自动消失" is-link @click="NoLoading('加载中~')"></nut-cell>
+    <h2>{{ translate('basic') }}</h2>
+    <nut-cell :title="translate('toastText')" is-link @click="textToast(translate('toastText'))"></nut-cell>
+    <nut-cell :title="translate('toastTitle')" is-link @click="titleToast(translate('toastText'))"></nut-cell>
+    <nut-cell :title="translate('toastSuccess')" is-link @click="successToast(translate('toastSuccess'))"></nut-cell>
+    <nut-cell :title="translate('toastError')" is-link @click="errorToast(translate('toastError'))"></nut-cell>
+    <nut-cell :title="translate('toastWarning')" is-link @click="warningToast(translate('toastWarning'))"></nut-cell>
+    <nut-cell :title="translate('toastLoading')" is-link @click="loadingToast(translate('toastLoading'))"></nut-cell>
+    <h2>{{ translate('toastAll') }}</h2>
+    <nut-cell :title="translate('toastAll')" is-link @click="NoToast(translate('toastAll'))"></nut-cell>
+    <h2>{{ translate('toastBottom') }}</h2>
+    <nut-cell :title="translate('toastBottom')" is-link @click="BottomToast(translate('toastBottom'))"></nut-cell>
+    <h2>{{ translate('toastTransparent') }}</h2>
+    <nut-cell
+      :title="translate('toastTransparent')"
+      is-link
+      @click="NoLoading(translate('toastTransparent'))"
+    ></nut-cell>
   </div>
 </template>
 
 <script lang="ts">
 import { createComponent } from '@/packages/utils/create';
-const { createDemo } = createComponent('toast');
+const { createDemo, translate } = createComponent('toast');
 import { Toast } from '@/packages/nutui.vue';
+import { useTranslate } from '@/sites/assets/util/useTranslate';
+useTranslate({
+  'zh-CN': {
+    basic: '基本用法',
+    toastText: '文字提示',
+    toastTitle: '标题展示',
+    toastSuccess: '成功提示',
+    toastError: '错误提示',
+    toastWarning: '警告提示',
+    toastLoading: '加载提示',
+    toastAll: 'Toast 不消失',
+    toastBottom: '自定义底部高度',
+    toastTransparent: '加载状态透明遮罩'
+  },
+  'en-US': {
+    basic: 'Basic Usage',
+    toastText: 'Text Message',
+    toastTitle: 'Title',
+    toastSuccess: 'Success',
+    toastError: 'Error',
+    toastWarning: 'Warning',
+    toastLoading: 'Loading',
+    toastAll: 'Not Disappear',
+    toastBottom: 'Custom Bottom Height',
+    toastTransparent: 'Loading Transparent Cover'
+  }
+});
 export default createDemo({
   setup() {
     const textToast = (msg: string) => {
@@ -27,7 +58,7 @@ export default createDemo({
     };
     const titleToast = (msg: string) => {
       Toast.text(msg, {
-        title: '标题文字'
+        title: translate('toastTitle')
       });
     };
     const successToast = (msg: string) => {
@@ -67,7 +98,8 @@ export default createDemo({
       loadingToast,
       NoToast,
       NoLoading,
-      BottomToast
+      BottomToast,
+      translate
     };
   }
 });

+ 290 - 0
src/packages/__VUE/toast/doc.en-US.md

@@ -0,0 +1,290 @@
+# Toast
+
+### Intro
+
+for light tips.
+
+### Install
+
+``` javascript
+import { createApp } from 'vue';
+import { Toast } from '@nutui/nutui';
+
+const app = createApp();
+app.use(Toast);
+```
+
+## Usage
+
+#### Global Usage
+:::demo
+``` html
+<template>
+</template>
+<script>
+import { getCurrentInstance } from 'vue';
+export default {
+  setup() {
+   const { proxy } = getCurrentInstance();
+    proxy.$toast.text('global usage');
+    return {};
+  }
+}
+</script>
+```
+:::
+
+#### Text
+:::demo
+```html
+<template>
+  <nut-cell title="Text" is-link @click="textToast('text message~')"></nut-cell>
+</template>
+<script>
+import { Toast } from '@nutui/nutui';
+export default {
+  setup() {
+     const textToast = (msg) => {
+      Toast.text(msg);
+    };
+    return {
+      textToast,
+    };
+  }
+}
+</script>
+```
+:::
+#### Title
+
+:::demo
+```html
+<template>
+  <nut-cell title="Toast Title" is-link @click="textToast('title message~')"></nut-cell>
+</template>
+<script>
+import { Toast } from '@nutui/nutui';
+export default {
+  setup() {
+     const textToast = (msg) => {
+      Toast.text(msg, {
+        title: 'title'
+      });
+    };
+    return {
+      textToast,
+    };
+  }
+}
+</script>
+```
+:::
+#### Success
+
+:::demo
+```html
+<template>
+  <nut-cell title="Toast Success" is-link @click="textToast('Success')"></nut-cell>
+</template>
+<script>
+import { Toast } from '@nutui/nutui';
+export default {
+  setup() {
+     const textToast = (msg) => {
+       Toast.success(msg);
+    };
+    return {
+      textToast,
+    };
+  }
+}
+</script>
+```
+:::
+
+#### Fail
+
+:::demo
+```html
+<template>
+  <nut-cell title="Toast Fail" is-link @click="textToast('Fail')"></nut-cell>
+</template>
+<script>
+import { Toast } from '@nutui/nutui';
+export default {
+  setup() {
+     const textToast = (msg) => {
+      Toast.fail(msg);
+    };
+    return {
+      textToast,
+    };
+  }
+}
+</script>
+```
+:::
+
+#### Warn
+
+:::demo
+```html
+<template>
+  <nut-cell title="Toast Warn" is-link @click="textToast('Warn')"></nut-cell>
+</template>
+<script>
+import { Toast } from '@nutui/nutui';
+export default {
+  setup() {
+     const textToast = (msg) => {
+      Toast.warn(msg);
+    };
+    return {
+      textToast,
+    };
+  }
+}
+</script>
+```
+:::
+
+#### Loading
+
+:::demo
+```html
+<template>
+  <nut-cell title="Toast Loading" is-link @click="textToast('Loading')"></nut-cell>
+</template>
+<script>
+import { Toast } from '@nutui/nutui';
+export default {
+  setup() {
+     const textToast = (msg) => {
+      Toast.loading(msg);
+    };
+    return {
+      textToast,
+    };
+  }
+}
+</script>
+```
+:::
+
+#### Not Disappear
+
+:::demo
+```html
+<template>
+  <nut-cell title="Toast Not Disappear" is-link @click="textToast('Toast Not Disappear')"></nut-cell>
+</template>
+<script>
+import { Toast } from '@nutui/nutui';
+export default {
+  setup() {
+     const textToast = (msg) => {
+     Toast.text(msg, {
+        duration: 0
+      });
+    };
+    return {
+      textToast,
+    };
+  }
+}
+</script>
+```
+:::
+#### Custom Bottom Height
+
+:::demo
+```html
+<template>
+  <nut-cell title="Custom Bottom Height" is-link @click="textToast('Custom Bottom Height')"></nut-cell>
+</template>
+<script>
+import { Toast } from '@nutui/nutui';
+export default {
+  setup() {
+     const textToast = (msg) => {
+      Toast.text(msg, {
+        center: false,
+        bottom: '10%'
+      });
+    };
+    return {
+      textToast,
+    };
+  }
+}
+</script>
+```
+:::
+
+#### Loading with transparent cover
+:::demo
+```html
+<template>
+  <nut-cell title="Loading with transparent cover" is-link @click="textToast('Loading')"></nut-cell>
+</template>
+<script>
+import { Toast } from '@nutui/nutui';
+export default {
+  setup() {
+     const textToast = (msg) => {
+       Toast.loading(msg, {
+        cover: true
+      });
+    };
+    return {
+      textToast,
+    };
+  }
+}
+</script>
+```
+:::
+
+
+####  Support import and use in JS modules
+``` javascript
+import { Toast } from "@nutui/nutui";
+Toast.text('use in js module');
+// Return the instance, you can manually call the hide method in the instance to close the prompt
+const toast = Toast.loading('use in js module');
+toast.hide();
+```
+
+
+### API
+| Methods                    | Description              | Attribute          | Return value     |
+| ------------------------- | ----------------------------------------------------------------------- | --------------- | ---------- |
+| Toast.text                | Show text toast   |  message| options | toast instance(message support incoming HTML) |
+| Toast.success             | Show success toast     | message| options| toast instance |
+| Toast.fail                | Show fail toast   | message| options| toast instance|
+| Toast.warn                | Show warn toast    | message| options | toast instance |
+| Toast.hide                | Close toast     | clearAll: boolean   | void       |
+| Toast.loading             | Show loading toast      | message| options | toast instance |
+
+## Options
+
+| 字段                | 说明                                                                          | 类型          | 默认值                        |
+| ------------------- | ----------------------------------------------------------------------------- | ------------- | ----------------------------- |
+| id                  | Identifier, share one instance at the same time, default to multiple instances| String/Number | -            |
+| duration            | Toast duration(ms), won't disappear if value is 0      | Number        | 2000                          |
+| title            | title     | String        |           -             |
+| center  | Whether to display in the middle of the page (display at the bottom when false) | Boolean| true                          |
+| bottom | The distance from the bottom of the page (px or %), which takes effect when option.center is false | String| 30px       |
+| textAlignCenter     | Whether the multi-line copy is centered           | Boolean       | true                          |
+| bgColor             | background color (transparency) | String        | rgba(0, 0, 0, 0.8)      |
+| customClass         |   Custom Class          | String        |          -                   |
+| icon                | Custom Icon        | String        |         -                   |
+| iconSize    | Custom iconSize      | String        | 20                           |
+| size        | Text Size **small**/**base**/**large**          | String        | base      |
+| cover      | Whether to show the mask layer     | Boolean       | false |
+| cover-color   | Cover Color   | String        | rgba(0,0,0,0)             |
+| loadingRotate  | Whether the loading icon is rotated, only valid for the loading type  | Boolean | true                          |
+| close             | Callback function after close                   | function      | null                          |
+| close-on-click-overlay | 	Whether to close when overlay is clicked                  | Boolean       | false                         |
+| custom-class          | Custom Class                      | String       |               -          |
+