Skip to content

Commit f39da91

Browse files
committed
feat: update slider
1 parent 4efc509 commit f39da91

File tree

21 files changed

+372
-187
lines changed

21 files changed

+372
-187
lines changed

build/config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module.exports = {
22
dev: {
3-
componentName: 'icon', // dev components
3+
componentName: 'slider', // dev components
44
},
55
};

components/icon/index.en-US.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ module.exports = {
101101
```
102102

103103
```jsx
104-
import { Icon } from 'antd';
104+
import { Icon } from 'ant-design-vue';
105105
import MessageSvg from 'path/to/message.svg'; // path to your '*.svg' file.
106106

107107
new Vue({

components/icon/index.zh-CN.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
更多讨论可参考:[#10353](https://github.com/ant-design/ant-design/issues/10353)
2525

26-
> ⚠️ 1.2.0 之后我们全量引入了所有图标,导致 antd 默认的包体积有一定增加,我们会在不远的未来增加新的 API 来实现图标的按需使用,更多相关讨论可关注:[#12011](https://github.com/ant-design/ant-design/issues/12011)。在此之前,你可以通过来自社区同学的 [webpack 插件](https://github.com/Beven91/webpack-ant-icon-loader)将图标文件拆分。
26+
> ⚠️ 1.2.0 之后我们全量引入了所有图标,导致 ant-design-vue 默认的包体积有一定增加,我们会在不远的未来增加新的 API 来实现图标的按需使用,更多相关讨论可关注:[#12011](https://github.com/ant-design/ant-design/issues/12011)。在此之前,你可以通过来自社区同学的 [webpack 插件](https://github.com/Beven91/webpack-ant-icon-loader)将图标文件拆分。
2727
2828
其中 `theme`, `component`, `twoToneColor``1.2.x` 版本新增加的属性。最佳实践是给使用的 `<Icon />` 组件传入属性 `theme` 以明确图标的主题风格。例如:
2929

components/slider/__tests__/__snapshots__/demo.test.js.snap

Lines changed: 57 additions & 36 deletions
Large diffs are not rendered by default.

components/slider/__tests__/__snapshots__/index.test.js.snap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
exports[`Slider should show tooltip when hovering slider handler 1`] = `
44
<div>
5-
<div class="ant-tooltip ant-tooltip-placement-top" style="left: -999px; top: -1003px; transform-origin: 50% 4px;">
5+
<div class="ant-tooltip ant-slider-tooltip ant-tooltip-placement-top" style="left: -999px; top: -1003px; transform-origin: 50% 4px;">
66
<div class="ant-tooltip-content">
77
<div class="ant-tooltip-arrow"></div>
88
<div role="tooltip" class="ant-tooltip-inner">30</div>
@@ -13,7 +13,7 @@ exports[`Slider should show tooltip when hovering slider handler 1`] = `
1313

1414
exports[`Slider should show tooltip when hovering slider handler 2`] = `
1515
<div>
16-
<div class="ant-tooltip ant-tooltip-placement-top" style="display: none;">
16+
<div class="ant-tooltip ant-slider-tooltip ant-tooltip-placement-top" style="display: none;">
1717
<div class="ant-tooltip-content">
1818
<div class="ant-tooltip-arrow"></div>
1919
<div role="tooltip" class="ant-tooltip-inner">30</div>

components/slider/__tests__/index.test.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
import { mount } from '@vue/test-utils';
22
import { asyncExpect } from '@/tests/utils';
33
import Slider from '..';
4+
import mountTest from '../../../tests/shared/mountTest';
45

56
describe('Slider', () => {
7+
mountTest(Slider);
68
it('should show tooltip when hovering slider handler', async () => {
79
const wrapper = mount(Slider, {
810
propsData: {

components/slider/demo/index.vue

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import Event from './event.md';
77
import Mark from './mark.md';
88
import Vertical from './vertical.md';
99
import ShowTooltip from './show-tooltip.md';
10+
import Reverse from './reverse';
1011
import CN from '../index.zh-CN.md';
1112
import US from '../index.en-US.md';
1213
@@ -40,6 +41,7 @@ export default {
4041
<Mark />
4142
<Vertical />
4243
<ShowTooltip />
44+
<Reverse />
4345
<api>
4446
<template slot="cn">
4547
<CN />

components/slider/demo/reverse.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<cn>
2+
#### 反向
3+
设置 `reverse` 可以将滑动条置反。
4+
</cn>
5+
6+
<us>
7+
#### Reverse
8+
Using `reverse` to render slider reversely.
9+
</us>
10+
11+
```tpl
12+
<template>
13+
<div>
14+
<a-slider :defaultValue="30" :reverse="reverse" />
15+
<a-slider range :defaultValue="[20, 50]" :reverse="reverse" />
16+
Reversed: <a-switch size="small" :checked="reverse" @change="handleReverseChange" />
17+
</div>
18+
</template>
19+
<script>
20+
export default {
21+
data() {
22+
return {
23+
reverse: true,
24+
};
25+
},
26+
methods: {
27+
handleReverseChange(reverse) {
28+
this.reverse = reverse;
29+
},
30+
},
31+
};
32+
</script>
33+
```

components/slider/demo/vertical.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ The vertical Slider.
1111
```tpl
1212
<template>
1313
<div style="height: 300px">
14-
<div style="float:left;height: 300px;marginLeft: 70px">
14+
<div style="display: inline-block;height: 300px;marginLeft: 70px">
1515
<a-slider vertical :defaultValue="30" />
1616
</div>
17-
<div style="float:left;height: 300px;marginLeft: 70px">
17+
<div style="display: inline-block;height: 300px;marginLeft: 70px">
1818
<a-slider vertical range :step="10" :defaultValue="[20, 50]" />
1919
</div>
20-
<div style="float:left;height: 300px;marginLeft: 70px">
20+
<div style="display: inline-block;height: 300px;marginLeft: 70px">
2121
<a-slider vertical range :marks="marks" :defaultValue="[26, 37]" />
2222
</div>
2323
</div>

components/slider/index.en-US.md

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,24 @@
11
## API
22

3-
| Property | Description | Type | Default |
4-
| --- | --- | --- | --- |
5-
| autoFocus | get focus when component mounted | boolean | false |
6-
| defaultValue | The default value of slider. When `range` is `false`, use `number`, otherwise, use `[number, number]` | number\|number\[] | 0 or \[0, 0] |
7-
| disabled | If true, the slider will not be interactable. | boolean | false |
8-
| dots | Whether the thumb can drag over tick only. | boolean | false |
9-
| included | Make effect when `marks` not null,`true` means containment and `false` means coordinative | boolean | true |
10-
| marks | Tick mark of Slider, type of key must be `number`, and must in closed interval \[min, max], each mark can declare its own style. | object | { number: string\|VNode } or { number: { style: object, label: string\|VNode } } or { number: () => VNode } |
11-
| max | The maximum value the slider can slide to | number | 100 |
12-
| min | The minimum value the slider can slide to. | number | 0 |
13-
| range | dual thumb mode | boolean | false |
14-
| step | The granularity the slider can step through values. Must greater than 0, and be divided by (max - min) . When `marks` no null, `step` can be `null`. | number\|null | 1 |
15-
| tipFormatter | Slider will pass its value to `tipFormatter`, and display its value in Tooltip, and hide Tooltip when return value is null. | Function\|null | IDENTITY |
16-
| value(v-model) | The value of slider. When `range` is `false`, use `number`, otherwise, use `[number, number]` | number\|number\[] | |
3+
| Property | Description | Type | Default | Version |
4+
| --- | --- | --- | --- | --- |
5+
| autoFocus | get focus when component mounted | boolean | false | |
6+
| defaultValue | The default value of slider. When `range` is `false`, use `number`, otherwise, use `[number, number]` | number\|number\[] | 0 or \[0, 0] | |
7+
| disabled | If true, the slider will not be interactable. | boolean | false | |
8+
| dots | Whether the thumb can drag over tick only. | boolean | false | |
9+
| included | Make effect when `marks` not null,`true` means containment and `false` means coordinative | boolean | true | |
10+
| marks | Tick mark of Slider, type of key must be `number`, and must in closed interval \[min, max], each mark can declare its own style. | object | { number: string\|VNode } or { number: { style: object, label: string\|VNode } } or { number: () => VNode } | |
11+
| max | The maximum value the slider can slide to | number | 100 | |
12+
| min | The minimum value the slider can slide to. | number | 0 | |
13+
| range | dual thumb mode | boolean | false | |
14+
| reverse | reverse the component | boolean | false | 1.5.0 |
15+
| step | The granularity the slider can step through values. Must greater than 0, and be divided by (max - min) . When `marks` no null, `step` can be `null`. | number\|null | 1 | |
16+
| tipFormatter | Slider will pass its value to `tipFormatter`, and display its value in Tooltip, and hide Tooltip when return value is null. | Function\|null | IDENTITY | |
17+
| value(v-model) | The value of slider. When `range` is `false`, use `number`, otherwise, use `[number, number]` | number\|number\[] | | |
1718
| vertical | If true, the slider will be vertical. | Boolean | false |
18-
| tooltipVisible | If true, Tooltip will show always, or it will not show anyway, even if dragging or hovering. | Boolean | |
19+
| tooltipPlacement | Set Tooltip display position. Ref [`Tooltip`](/components/tooltip/). | string | | 1.5.0 |
20+
| tooltipVisible | If true, Tooltip will show always, or it will not show anyway, even if dragging or hovering. | Boolean | | |
21+
| getTooltipPopupContainer | The DOM container of the Tooltip, the default behavior is to create a div element in body. | Function | () => document.body | 1.5.0 |
1922

2023
### events
2124

0 commit comments

Comments
 (0)