Skip to content

Commit

Permalink
feat(Sku): add disable-soldout-sku prop
Browse files Browse the repository at this point in the history
  • Loading branch information
zhanglin_0715 committed Dec 17, 2020
2 parents 28fc22f + 4af658e commit 261ceba
Show file tree
Hide file tree
Showing 451 changed files with 13,218 additions and 3,906 deletions.
10 changes: 0 additions & 10 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,3 @@ npm run dev

# open http://localhost:8080
```

## Contribute online with a single click

You can use Gitpod (A free online VS Code-like IDE) for contributing, With a single click it will launch a workspace and automatically:

- clone the vant repo.
- run `npm run bootstrap`.
- run `npm run dev`.

[![Open in Gitpod](https://gitpod.io/button/open-in-gitpod.svg)](https://gitpod.io/#https://github.com/youzan/vant)
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
你好,请使用下面的链接创建 issue 以帮助我们更快的排查问题,不规范的 issue 会被关闭,感谢配合。

https://youzan.github.io/vant-issue-generater
http://vant-contrib.gitee.io/vant-issue-generater

---

Expand Down
19 changes: 19 additions & 0 deletions .github/workflows/preview.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: 🔂 Surge PR Preview

on: [push, pull_request_target]

jobs:
preview:
runs-on: ubuntu-latest
env:
PUBLIC_PATH: '/'
steps:
- uses: actions/checkout@v2
- uses: afc163/surge-preview@v1
with:
surge_token: ${{ secrets.SURGE_TOKEN }}
github_token: ${{ secrets.GITHUB_TOKEN }}
build: |
yarn
./node_modules/.bin/vant-cli build-site
dist: site
6 changes: 4 additions & 2 deletions .github/workflows/sync.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ jobs:
SSH_PRIVATE_KEY: ${{ secrets.GITEE_RSA_PRIVATE_KEY }}
with:
# 注意替换为你的 GitHub 源仓库地址
source-repo: 'git@github.com:youzan/vant.git'
source-repo: git@github.com:youzan/vant.git
# 注意替换为你的 Gitee 目标仓库地址
destination-repo: 'git@gitee.com:vant-contrib/vant.git'
destination-repo: git@gitee.com:vant-contrib/vant.git

- name: Build Gitee Pages
uses: yanglbme/gitee-pages-action@master
Expand All @@ -28,3 +28,5 @@ jobs:
gitee-password: ${{ secrets.GITEE_PASSWORD }}
# 注意替换为你的 Gitee 仓库
gitee-repo: vant-contrib/vant
# 要部署的分支
branch: gh-pages
6 changes: 0 additions & 6 deletions .gitpod.yml

This file was deleted.

14 changes: 0 additions & 14 deletions .ls-lint.yml

This file was deleted.

25 changes: 9 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,7 @@
</p>

<p align="center">
🔥 <a href="https://youzan.github.io/vant">文档网站</a>
&nbsp;
&nbsp;
💡 <a href="https://vant-contrib.gitee.io/vant">国内镜像文档</a>
🔥 <a href="https://vant-contrib.gitee.io/vant">文档网站</a>
&nbsp;
&nbsp;
🇨🇳 <a href="./README.zh-CN.md">中文版介绍</a>
Expand All @@ -32,10 +29,12 @@

## Features

- 60+ Reusable components
- 90% Unit test coverage
- 65+ Reusable components
- 1kb Component average size (min+gzip)
- 90%+ Unit test coverage
- Extensive documentation and demos
- Support [babel-plugin-import](https://github.com/ant-design/babel-plugin-import)
- Support Vue 2 & Vue 3
- Support Tree Shaking
- Support Custom Theme
- Support i18n
- Support TS
Expand All @@ -44,11 +43,11 @@
## Install

```bash
# Using npm
# Install vant 2.x for Vue 2 project
npm i vant -S

# Using yarn
yarn add vant
# Install vant 3.x for Vue 3 project
npm i vant@next -S
```

## Quickstart
Expand Down Expand Up @@ -94,12 +93,6 @@ You can scan the following QR code to access the demo:

<img src="https://img.yzcdn.cn/vant/preview_qrcode_20180528.png" width="220" height="220" >

## Wechat Group

Scan the qrcode to join our wechat discussion group, please note that you want to join Vant discussion group.

<img src="https://img.yzcdn.cn/vant/wechat_20180606.png" width="220" height="292" >

## LICENSE

[MIT](https://en.wikipedia.org/wiki/MIT_License)
36 changes: 20 additions & 16 deletions README.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,36 +16,41 @@
</p>

<p align="center">
🔥 <a href="https://youzan.github.io/vant">文档网站</a>
&nbsp;
&nbsp;
💡 <a href="https://vant-contrib.gitee.io/vant">国内镜像文档</a>
🔥 <a href="https://vant-contrib.gitee.io/vant">文档网站</a>
&nbsp;
&nbsp;
🚀 <a href="https://github.com/youzan/vant-weapp" target="_blank">小程序版</a>
</p>

---

### 介绍

Vant 是**有赞前端团队**开源的移动端组件库,于 2017 年开源,已持续维护 4 年时间。Vant 对内承载了有赞所有核心业务,对外服务十多万开发者,是业界主流的移动端组件库之一。

目前 Vant 官方提供了 [Vue 2 版本](https://vant-contrib.gitee.io/vant)[Vue 3 版本](https://vant-contrib.gitee.io/vant/next)[微信小程序版本](http://vant-contrib.gitee.io/vant-weapp),并由社区团队维护 [React 版本](https://github.com/mxdi9i7/vant-react)

## 特性

- 60+ 高质量组件
- 90% 单元测试覆盖率
- 提供 60 多个高质量组件,覆盖移动端各类场景
- 性能极佳,组件平均体积不到 1kb(min+gzip)
- 单元测试覆盖率 90%+,提供稳定性保障
- 完善的中英文文档和示例
- 支持 Vue 2 & Vue 3
- 支持按需引入
- 支持主题定制
- 支持国际化
- 支持 TS
- 支持 TypeScript
- 支持 SSR

## 安装

```bash
# 通过 npm 安装
# Vue 2 项目,安装 Vant 2.x 版本:
npm i vant -S

# 通过 yarn 安装
yarn add vant
# Vue 3 项目,安装 Vant 3.x 版本:
npm i vant@next -S
```

## 快速上手
Expand All @@ -58,11 +63,11 @@ import 'vant/lib/index.css';
Vue.use(Button);
```

vant 也支持按需引入、CDN 引入等方式,详细说明见 [快速上手](https://youzan.github.io/vant#/zh-CN/quickstart).
vant 也支持按需引入、CDN 引入等方式,详细说明见 [快速上手](https://vant-contrib.gitee.io/vant#/zh-CN/quickstart).

## 贡献代码

修改代码请阅读我们的 [开发指南](https://youzan.github.io/vant/#/zh-CN/contribution)
修改代码请阅读我们的 [开发指南](https://vant-contrib.gitee.io/vant/#/zh-CN/contribution)

使用过程中发现任何问题都可以提 [Issue](https://github.com/youzan/vant/issues) 给我们,当然,我们也非常欢迎你给我们发 [PR](https://github.com/youzan/vant/pulls)

Expand All @@ -72,7 +77,7 @@ vant 也支持按需引入、CDN 引入等方式,详细说明见 [快速上手

## 加入我们

**有赞前端团队**是由一群年轻、皮实、对技术饱含热情的小伙伴组成的,目前共有 100 多名前端工程师,分布在业务中台、电商、零售、美业、资产、赋能等业务线
**有赞前端团队**是由一群年轻、皮实、对技术饱含热情的小伙伴组成的,目前共有 100 多名前端工程师,分布在业务中台、电商、零售、美业、资产、有赞云、赋能平台、增长中心等业务线

我们热爱分享和开源,崇尚用工程师的方式解决问题,因此造了很多工具来解决我们遇到的问题,目前我们维护的开源产品有:

Expand All @@ -97,9 +102,8 @@ vant 也支持按需引入、CDN 引入等方式,详细说明见 [快速上手

## 链接

- [详细文档](https://youzan.github.io/vant)
- [更新日志](https://youzan.github.io/vant#/zh-CN/changelog)
- [码云镜像](https://vant-contrib.gitee.io/vant)
- [详细文档](https://vant-contrib.gitee.io/vant)
- [更新日志](https://vant-contrib.gitee.io/vant#/zh-CN/changelog)
- [Gitter 讨论组](https://gitter.im/vant-contrib/discuss?utm_source=share-link&utm_medium=link&utm_campaign=share-link)

## 手机预览
Expand Down
Binary file modified docs/assets/design.sketch
100644 → 100755
Binary file not shown.
Binary file added docs/assets/vant-axure.rp
Binary file not shown.
Binary file added docs/assets/vant-axure.rplib
Binary file not shown.
42 changes: 42 additions & 0 deletions docs/markdown/advanced-usage.en-US.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Advanced Usage

## Browser adaptation

### Rem Units

Vant uses `px` unit by default,you can use tools such as `postcss-pxtorem` to transform units to `rem`.

- [postcss-pxtorem](https://github.com/cuth/postcss-pxtorem)
- [lib-flexible](https://github.com/amfe/lib-flexible)

#### PostCSS Config

Postcss config example:

```js
module.exports = {
plugins: {
autoprefixer: {
browsers: ['Android >= 4.0', 'iOS >= 8'],
},
'postcss-pxtorem': {
rootValue: 37.5,
propList: ['*'],
},
},
};
```

### Adapt to PC Browsers

Vant is a mobile-first component library, if you want to use Vant in PC browsers, you can use the [@vant/touch-emulator](https://github.com/youzan/vant/tree/dev/packages/vant-touch-emulator) module. This module will automatically convert the mouse events of the PC browser into the touch events of the mobile browser.

```bash
# Install
npm i @vant/touch-emulator -S
```

```js
// Just import this module, then Vant works in PC browser
import '@vant/touch-emulator';
```
123 changes: 123 additions & 0 deletions docs/markdown/advanced-usage.zh-CN.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
# 进阶用法

### 介绍

通过本章节你可以了解到 Vant 的一些进阶用法,比如组件插槽用法、多种浏览器适配方式。

## 组件用法

### 组件插槽

Vant 提供了丰富的组件插槽,通过插槽可以对组件的某一部分进行个性化定制。如果你对 Vue 的插槽不太熟悉,可以阅读 Vue 官方文档中的[插槽章节](https://cn.vuejs.org/v2/guide/components-slots.html)。下面是通过插槽来定制 Checkbox 图标的示例:

```html
<van-checkbox v-model="checked">
<!-- 使用组件提供的 icon 插槽 -->
<!-- 将默认图标替换为个性化图片 -->
<template #icon="props">
<img :src="props.checked ? activeIcon : inactiveIcon" />
</template>
</van-checkbox>
```

```js
export default {
data() {
return {
checked: true,
activeIcon: 'https://img.yzcdn.cn/vant/user-active.png',
inactiveIcon: 'https://img.yzcdn.cn/vant/user-inactive.png',
};
},
};
```

### 组件实例方法

Vant 中的许多组件提供了实例方法,调用实例方法时,我们需要通过 [ref](https://cn.vuejs.org/v2/api/#ref) 来注册组件引用信息,引用信息将会注册在父组件的`$refs`对象上。注册完成后,我们可以通过`this.$refs.xxx`访问到对应的组件实例,并调用上面的实例方法。

```html
<!-- 通过 ref 属性将组件绑定到 this.$refs.checkbox 上 -->
<van-checkbox v-model="checked" ref="checkbox">
复选框
</van-checkbox>
```

```js
export default {
data() {
return {
checked: false,
};
},
// 注意:组件挂载后才能访问到 ref 对象
mounted() {
this.$refs.checkbox.toggle();
},
};
```

## 浏览器适配

### Rem 布局适配

Vant 中的样式默认使用 `px` 作为单位,如果需要使用 `rem` 单位,推荐使用以下两个工具:

- [postcss-pxtorem](https://github.com/cuth/postcss-pxtorem) 是一款 postcss 插件,用于将单位转化为 rem
- [lib-flexible](https://github.com/amfe/lib-flexible) 用于设置 rem 基准值

#### PostCSS 配置

下面提供了一份基本的 postcss 配置,可以在此配置的基础上根据项目需求进行修改。

```js
module.exports = {
plugins: {
autoprefixer: {
browsers: ['Android >= 4.0', 'iOS >= 8'],
},
'postcss-pxtorem': {
rootValue: 37.5,
propList: ['*'],
},
},
};
```

> Tips: 在配置 postcss-loader 时,应避免 ignore node_modules 目录,否则将导致 Vant 样式无法被编译。
### 桌面端适配

Vant 是一个面向移动端的组件库,因此默认只适配了移动端设备,这意味着组件只监听了移动端的 `touch` 事件,没有监听桌面端的 `mouse` 事件。

如果你需要在桌面端使用 Vant,可以引入我们提供的 [@vant/touch-emulator](https://github.com/youzan/vant/tree/dev/packages/vant-touch-emulator),这个库会在桌面端自动将 `mouse` 事件转换成对应的 `touch` 事件,使得组件能够在桌面端使用。

```bash
# 安装模块
npm i @vant/touch-emulator -S
```

```js
// 引入模块后自动生效
import '@vant/touch-emulator';
```

### 底部安全区适配

iPhone X 等机型底部存在底部指示条,指示条的操作区域与页面底部存在重合,容易导致用户误操作,因此我们需要针对这些机型进行安全区适配。Vant 中部分组件提供了 `safe-area-inset-top``safe-area-inset-bottom` 属性,设置该属性后,即可在对应的机型上开启适配,如下示例:

```html
<!-- 在 head 标签中添加 meta 标签,并设置 viewport-fit=cover 值 -->
<meta
name="viewport"
content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, viewport-fit=cover"
/>

<!-- 开启顶部安全区适配 -->
<van-nav-bar safe-area-inset-top />

<!-- 开启底部安全区适配 -->
<van-number-keyboard safe-area-inset-bottom />
```

<img src="https://img.yzcdn.cn/vant/safearea.png">

0 comments on commit 261ceba

Please sign in to comment.