diff --git a/src-next/divider/README.md b/src-next/divider/README.md new file mode 100644 index 000000000..78274ffcb --- /dev/null +++ b/src-next/divider/README.md @@ -0,0 +1,63 @@ +# Divider + +### Install + +```js +import Vue from 'vue'; +import { Divider } from 'vant'; + +Vue.use(Divider); +``` + +## Usage + +### Basic Usage + +```html + +``` + +### With Text + +```html +Text +``` + +### Content Position + +```html +Text +Text +``` + +### Dashed + +```html +Text +``` + +### Custom Style + +```html + + Text + +``` + +## API + +### Props + +| Attribute | Description | Type | Default | +| --- | --- | --- | --- | +| dashed | Whether to use dashed border | _boolean_ | `false` | +| hairline | Whether to use hairline | _boolean_ | `true` | +| content-position | Content position,can be set to `left` `right` | _string_ | `center` | + +### Slots + +| Name | Description | +| ------- | ----------- | +| default | content | diff --git a/src-next/divider/README.zh-CN.md b/src-next/divider/README.zh-CN.md new file mode 100644 index 000000000..0a6b265b1 --- /dev/null +++ b/src-next/divider/README.zh-CN.md @@ -0,0 +1,73 @@ +# Divider 分割线 + +### 引入 + +```js +import Vue from 'vue'; +import { Divider } from 'vant'; + +Vue.use(Divider); +``` + +## 代码演示 + +### 基础用法 + +默认渲染一条水平分割线 + +```html + +``` + +### 展示文字 + +通过插槽在可以分割线中间插入内容 + +```html +文字 +``` + +### 内容位置 + +通过`content-position`指定内容所在位置 + +```html +文字 +文字 +``` + +### 虚线 + +添加`dashed`属性使分割线渲染为虚线 + +```html +文字 +``` + +### 自定义样式 + +可以直接通过`style`属性设置分割线的样式 + +```html + + 文字 + +``` + +## API + +### Props + +| 参数 | 说明 | 类型 | 默认值 | +| ---------------- | -------------------------------- | --------- | -------- | +| dashed | 是否使用虚线 | _boolean_ | `false` | +| hairline | 是否使用 0.5px 线 | _boolean_ | `true` | +| content-position | 内容位置,可选值为`left` `right` | _string_ | `center` | + +### Slots + +| 名称 | 说明 | +| ------- | ---- | +| default | 内容 | diff --git a/src-next/divider/demo/index.vue b/src-next/divider/demo/index.vue new file mode 100644 index 000000000..c1ab46bc8 --- /dev/null +++ b/src-next/divider/demo/index.vue @@ -0,0 +1,78 @@ + + + + + diff --git a/src-next/divider/index.js b/src-next/divider/index.js new file mode 100644 index 000000000..f304818f3 --- /dev/null +++ b/src-next/divider/index.js @@ -0,0 +1,33 @@ +import { createNamespace } from '../utils'; + +const [createComponent, bem] = createNamespace('divider'); + +export default createComponent({ + props: { + dashed: Boolean, + hairline: { + type: Boolean, + default: true, + }, + contentPosition: { + type: String, + default: 'center', + }, + }, + + render() { + const Content = this.$slots.default?.(); + return ( + + ); + }, +}); diff --git a/src-next/divider/index.less b/src-next/divider/index.less new file mode 100644 index 000000000..962964c45 --- /dev/null +++ b/src-next/divider/index.less @@ -0,0 +1,64 @@ +@import '../style/var'; + +.van-divider { + display: flex; + align-items: center; + margin: @divider-margin; + color: @divider-text-color; + font-size: @divider-font-size; + line-height: @divider-line-height; + border-color: @divider-border-color; + border-style: solid; + border-width: 0; + + &::before, + &::after { + display: block; + flex: 1; + box-sizing: border-box; + height: 1px; + border-color: inherit; + border-style: inherit; + border-width: @border-width-base 0 0; + } + + &::before { + content: ''; + } + + &--hairline { + &::before, + &::after { + transform: scaleY(0.5); + } + } + + &--dashed { + border-style: dashed; + } + + &--content-center, + &--content-left, + &--content-right { + &::before { + margin-right: @divider-content-padding; + } + + &::after { + margin-left: @divider-content-padding; + content: ''; + } + } + + &--content-left { + &::before { + max-width: @divider-content-left-width; + } + } + + &--content-right { + &::after { + max-width: @divider-content-right-width; + } + } +} diff --git a/src-next/divider/test/__snapshots__/demo.spec.js.snap b/src-next/divider/test/__snapshots__/demo.spec.js.snap new file mode 100644 index 000000000..1ea4ff2d6 --- /dev/null +++ b/src-next/divider/test/__snapshots__/demo.spec.js.snap @@ -0,0 +1,32 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`renders demo correctly 1`] = ` +
+
+ +
+
+ +
+
+ + +
+
+ +
+
+ +
+
+`; diff --git a/src-next/divider/test/demo.spec.js b/src-next/divider/test/demo.spec.js new file mode 100644 index 000000000..5c70922b5 --- /dev/null +++ b/src-next/divider/test/demo.spec.js @@ -0,0 +1,4 @@ +import Demo from '../demo'; +import { snapshotDemo } from '../../../test/demo'; + +snapshotDemo(Demo); diff --git a/vant.config.js b/vant.config.js index 26f7e0aaa..71e7cf38f 100644 --- a/vant.config.js +++ b/vant.config.js @@ -233,10 +233,10 @@ module.exports = { // path: 'count-down', // title: 'CountDown 倒计时', // }, - // { - // path: 'divider', - // title: 'Divider 分割线', - // }, + { + path: 'divider', + title: 'Divider 分割线', + }, { path: 'empty', title: 'Empty 空状态', @@ -567,10 +567,10 @@ module.exports = { // path: 'count-down', // title: 'CountDown', // }, - // { - // path: 'divider', - // title: 'Divider', - // }, + { + path: 'divider', + title: 'Divider', + }, { path: 'empty', title: 'Empty',