diff --git a/README.md b/README.md index 4ccc0e5b5..52c549d84 100644 --- a/README.md +++ b/README.md @@ -1,23 +1,23 @@ # **Vant React** -[![npm version](https://badge.fury.io/js/vant-react.svg)](https://badge.fury.io/js/vant-react) -[![NPM](https://img.shields.io/npm/l/vant-react)](LICENSE) -![Test CI](https://github.com/mxdi9i7/vant-react/workflows/Test%20CI/badge.svg) -[![Netlify Status](https://api.netlify.com/api/v1/badges/30ddabc0-3eb6-4530-ab08-58db247a2b48/deploy-status)](https://vant.bctc.io) -[![Storybook](https://cdn.jsdelivr.net/gh/storybookjs/brand@master/badge/badge-storybook.svg)](https://vant.bctc.io) +npm version +NPM +Test CI +Netlify Status +Storybook Lightweight Mobile UI Components built on Typescript and React in under 2kb! -## **Features** +### **Features** - Support Typescript - 60+ Reusable components - 100% Storybook coverage: [https://vant.bctc.io](https://vant.bctc.io) - Extensive documentation and demos -## Install +### Install -```text +``` bash # Using npm npm i vant-react -S @@ -25,9 +25,9 @@ npm i vant-react -S yarn add vant-react ``` -## Quickstart +### Quickstart -```text +``` js import React from 'react'; import { Button } from 'vant-react'; import 'vant-react/dist/index.css'; diff --git a/docs/changelog.zh-CN.md b/docs/changelog.zh-CN.md new file mode 100644 index 000000000..2d291ae49 --- /dev/null +++ b/docs/changelog.zh-CN.md @@ -0,0 +1 @@ +## 更新日志 \ No newline at end of file diff --git a/docs/contribute.zh-CN.md b/docs/contribute.zh-CN.md new file mode 100644 index 000000000..cfbca5ac4 --- /dev/null +++ b/docs/contribute.zh-CN.md @@ -0,0 +1 @@ +## 如何参与 \ No newline at end of file diff --git a/docs/locale.zh-CN.md b/docs/locale.zh-CN.md new file mode 100644 index 000000000..fe57d0e98 --- /dev/null +++ b/docs/locale.zh-CN.md @@ -0,0 +1 @@ +## 国际化 diff --git a/docs/markdown.zh-CN.md b/docs/markdown.zh-CN.md new file mode 100644 index 000000000..bf130bfc7 --- /dev/null +++ b/docs/markdown.zh-CN.md @@ -0,0 +1,23 @@ +## 组件文档如何编写 + +### 介绍 + +文档网站分为文档展示和demo展示,文档通过收集组件目录下的 `README.[locale].md`, ` locale ` 的值是国际化的标识,和 ` ./site/configs/nav.config.js ` 中的 ` key `保持一致。 + +### 使用 + +文档网站替换了storybook 自带的文档生成,在运行 ` yarn storybook ` 自动收集文档和demo的信息,生成对应的页面,并且自动在浏览器中打开页面,对于开发过程中的使用基本上没有太大的影响 + +### 添加文档配置 + +在` ./site/configs/nav.config.js ` 添加新的文档页面配置,包括标题和` path `,标题会在左侧导航展示,` path`用来生成页面路由. + +### 添加文档文件 + +在组件目录中新增 `README.zh-CN.md`,用来展示组件文档,使用 ` markdown ` 文件语法。 + +### 添加文档 demo 文件 + +在组件目录中新增 ` demo/index.tsx ` 作为文档的页面,然后就可以愉快的编写 demo 了。 +由于每次在运行` yarn storybook `时才会收集所有文档信息生成文档配置,所以每次新增的文档文件需要重新运行` yarn storybook `。 + diff --git a/docs/quickstart.zh-CN.md b/docs/quickstart.zh-CN.md new file mode 100644 index 000000000..1e8aa0de9 --- /dev/null +++ b/docs/quickstart.zh-CN.md @@ -0,0 +1,24 @@ +## 快速上手 + +### Install + +``` bash +# Using npm +npm i vant-react -S + +# Using yarn +yarn add vant-react +``` + +### Quickstart + +``` js +import React from 'react'; +import { Button } from 'vant-react'; +import 'vant-react/dist/index.css'; + +const App = () => { + return ( + + + + + +``` + +### 朴素按钮 + +通过`plain`属性将按钮设置为朴素按钮,朴素按钮的文字为按钮颜色,背景为白色。 + +```html + + +``` + +### 细边框 + +设置`hairline`属性可以开启 0.5px 边框,基于伪类实现 + +```html + + +``` + +### 禁用状态 + +通过`disabled`属性来禁用按钮,禁用状态下按钮不可点击 + +```html + + +``` + +### 加载状态 + +通过`loading`属性设置按钮为加载状态,加载状态下默认会隐藏按钮文字,可以通过`loading-text`设置加载状态下的文字 + +```html + + +``` + +### 图标按钮 + +通过`icon`属性设置按钮图标,支持 Icon 组件里的所有图标,也可以传入图标 URL + +```html + + +``` + +### 按钮尺寸 + +支持`large`、`normal`、`small`、`mini`四种尺寸,默认为`normal` + +```html + + + + +``` + +### 块级元素 + +按钮在默认情况下为行内块级元素,通过`block`属性可以将按钮的元素类型设置为块级元素 + +```html + +``` + +### 页面导航 + +可以通过`url`属性进行 URL 跳转,或通过`to`属性进行路由跳转 + +```html + + +``` + +### 自定义颜色 + +通过`color`属性可以自定义按钮的颜色 + +```html + + + +``` + +## API + +### Props + +| 参数 | 说明 | 类型 | 默认值 | +| --- | --- | --- | --- | +| type | 类型,可选值为 `primary` `info` `warning` `danger` | _string_ | `default` | +| size | 尺寸,可选值为 `large` `small` `mini` | _string_ | `normal` | +| text | 按钮文字 | _string_ | - | +| color `v2.1.8` | 按钮颜色,支持传入`linear-gradient`渐变色 | _string_ | - | +| icon | 左侧[图标名称](#/zh-CN/icon)或图片链接 | _string_ | - | +| icon-prefix `v2.6.0` | 图标类名前缀,同 Icon 组件的 [class-prefix 属性](#/zh-CN/icon#props) | _string_ | `van-icon` | +| tag | 根节点的 HTML 标签 | _string_ | `button` | +| native-type | 原生 button 标签的 type 属性 | _string_ | - | +| block | 是否为块级元素 | _boolean_ | `false` | +| plain | 是否为朴素按钮 | _boolean_ | `false` | +| square | 是否为方形按钮 | _boolean_ | `false` | +| round | 是否为圆形按钮 | _boolean_ | `false` | +| disabled | 是否禁用按钮 | _boolean_ | `false` | +| hairline | 是否使用 0.5px 边框 | _boolean_ | `false` | +| loading | 是否显示为加载状态 | _boolean_ | `false` | +| loading-text | 加载状态提示文字 | _string_ | - | +| loading-type | [加载图标类型](#/zh-CN/loading),可选值为`spinner` | _string_ | `circular` | +| loading-size | 加载图标大小 | _string_ | `20px` | +| url | 点击后跳转的链接地址 | _string_ | - | +| to | 点击后跳转的目标路由对象,同 vue-router 的 [to 属性](https://router.vuejs.org/zh/api/#to) | _string \| object_ | - | +| replace | 是否在跳转时替换当前页面历史 | _boolean_ | `false` | + +### Events + +| 事件名 | 说明 | 回调参数 | +| ---------- | ---------------------------------------- | ------------------- | +| click | 点击按钮,且按钮状态不为加载或禁用时触发 | _event: Event_ | +| touchstart | 开始触摸按钮时触发 | _event: TouchEvent_ | diff --git a/src/components/Cell/README.zh-CN.md b/src/components/Cell/README.zh-CN.md new file mode 100644 index 000000000..e956ba282 --- /dev/null +++ b/src/components/Cell/README.zh-CN.md @@ -0,0 +1 @@ +# Cell 单元格 \ No newline at end of file diff --git a/src/components/Field/README.zh-CN.md b/src/components/Field/README.zh-CN.md new file mode 100644 index 000000000..0eeea5d5e --- /dev/null +++ b/src/components/Field/README.zh-CN.md @@ -0,0 +1 @@ +# Field 输入框 \ No newline at end of file diff --git a/src/components/Icons/README.zh-CN.md b/src/components/Icons/README.zh-CN.md new file mode 100644 index 000000000..ae377af89 --- /dev/null +++ b/src/components/Icons/README.zh-CN.md @@ -0,0 +1 @@ +# Icon 图标 \ No newline at end of file diff --git a/src/components/Navbar/README.zh-CN.md b/src/components/Navbar/README.zh-CN.md new file mode 100644 index 000000000..99b99cb0e --- /dev/null +++ b/src/components/Navbar/README.zh-CN.md @@ -0,0 +1 @@ +# Navbar 导航栏 \ No newline at end of file diff --git a/src/components/Popup/README.zh-CN.md b/src/components/Popup/README.zh-CN.md new file mode 100644 index 000000000..23d8a72c2 --- /dev/null +++ b/src/components/Popup/README.zh-CN.md @@ -0,0 +1 @@ +# Popup 弹出层 \ No newline at end of file diff --git a/src/components/Rate/README.zh-CN.md b/src/components/Rate/README.zh-CN.md new file mode 100644 index 000000000..0593d74da --- /dev/null +++ b/src/components/Rate/README.zh-CN.md @@ -0,0 +1 @@ +# Rate 评分 \ No newline at end of file diff --git a/src/components/Search/README.zh-CN.md b/src/components/Search/README.zh-CN.md new file mode 100644 index 000000000..03502e87e --- /dev/null +++ b/src/components/Search/README.zh-CN.md @@ -0,0 +1 @@ +# Search 搜索 diff --git a/src/components/Tag/README.zh-CN.md b/src/components/Tag/README.zh-CN.md new file mode 100644 index 000000000..e2b417eed --- /dev/null +++ b/src/components/Tag/README.zh-CN.md @@ -0,0 +1 @@ +# Tag 标签 diff --git a/tsconfig.json b/tsconfig.json index c079083e9..90d6838cd 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -34,6 +34,7 @@ "exclude": [ "node_modules", "dist", - "demo" + "demo", + "site" ] }