Skip to content

Commit a1eb809

Browse files
committed
docs: update
1 parent be58bbd commit a1eb809

File tree

12 files changed

+228
-20
lines changed

12 files changed

+228
-20
lines changed

src/examples/color.ts

+94
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
export default {
2+
example1: `
3+
<template>
4+
<div>
5+
<vue-slider
6+
v-model="value"
7+
class="color-slider"
8+
:process="false"
9+
:tooltip="'always'"
10+
>
11+
<template v-slot:dot>
12+
<div class="custom-dot" :style="{ borderColor: color }"></div>
13+
</template>
14+
<template v-slot:tooltip>
15+
<div class="custom-tooltip" :style="{ backgroundColor: color }"></div>
16+
</template>
17+
</vue-slider>
18+
</div>
19+
</template>
20+
21+
<style>
22+
.color-slider .vue-slider-rail {
23+
background: linear-gradient(to right,
24+
rgb(255,0,0),
25+
rgb(255,255,0),
26+
rgb(0,255,0),
27+
rgb(0,255,255),
28+
rgb(0,0,255),
29+
rgb(255,0,255),
30+
rgb(255,0,0)
31+
);
32+
}
33+
.color-slider .custom-dot {
34+
width: 100%;
35+
color: 100%;
36+
background-color: #fff;
37+
border: 2px solid #fff;
38+
}
39+
.color-slider .custom-tooltip {
40+
width: 24px;
41+
color: 24px;
42+
border-radius: 50%;
43+
}
44+
</style>
45+
46+
<script>
47+
module.exports = {
48+
components: {
49+
VueSlider
50+
},
51+
data: function () {
52+
return {
53+
value: 0
54+
}
55+
},
56+
computed: {
57+
color () {
58+
var hue = ((this.value / 100) * 360).toFixed(0)
59+
var hex = this.hsl2Hex(hue, 100, 50)
60+
return hex
61+
}
62+
},
63+
methods: {
64+
hsl2Rgb(h, s, l) {
65+
s = s / 100
66+
l = l / 100
67+
var c, x, m, rgb
68+
c = (1 - Math.abs(2 * l - 1)) * s
69+
x = c * (1 - Math.abs(((h / 60) % 2) - 1))
70+
m = l - c / 2
71+
if (h >= 0 && h < 60) rgb = [c, x, 0]
72+
if (h >= 60 && h < 120) rgb = [x, c, 0]
73+
if (h >= 120 && h < 180) rgb = [0, c, x]
74+
if (h >= 180 && h < 240) rgb = [0, x, c]
75+
if (h >= 240 && h < 300) rgb = [x, 0, c]
76+
if (h >= 300 && h <= 360) rgb = [c, 0, x]
77+
78+
return rgb.map(function (v) {
79+
return 255 * (v + m) | 0
80+
})
81+
},
82+
rgb2Hex(r, g, b) {
83+
var rgb = b | (g << 8) | (r << 16)
84+
return '#' + (0x1000000 + rgb).toString(16).slice(1)
85+
},
86+
hsl2Hex(h, s, l) {
87+
var rgb = this.hsl2Rgb(h, s, l)
88+
return this.rgb2Hex(rgb[0], rgb[1], rgb[2])
89+
}
90+
}
91+
}
92+
</script>
93+
`,
94+
}

src/examples/components-slots.ts

+31-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,12 @@ export default {
22
example1: `
33
<template>
44
<div>
5-
<vue-slider v-model="value" :process-style="{ backgroundColor: 'pink' }">
5+
<vue-slider
6+
v-model="value"
7+
:tooltip="'none'"
8+
:process-style="{ backgroundColor: 'pink' }"
9+
:tooltip-style="{ backgroundColor: 'pink', borderColor: 'pink' }"
10+
>
611
<template v-slot:dot="{ value, focus }">
712
<div :class="['custom-dot', { focus }]"></div>
813
</template>
@@ -38,5 +43,29 @@ export default {
3843
}
3944
}
4045
</script>
41-
`,
46+
`,
47+
example2: `
48+
<template>
49+
<div>
50+
<vue-slider v-model="value" :tooltip="'always'">
51+
</vue-slider>
52+
</div>
53+
</template>
54+
55+
<style>
56+
</style>
57+
58+
<script>
59+
module.exports = {
60+
components: {
61+
VueSlider
62+
},
63+
data: function () {
64+
return {
65+
value: 0
66+
}
67+
}
68+
}
69+
</script>
70+
`,
4271
}

src/nav/nav.json

+5
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@
2424
"name": "Slots",
2525
"route": "api/slots",
2626
"component": "Api/Slots.md"
27+
},
28+
{
29+
"name": "Methods",
30+
"route": "api/methods",
31+
"component": "Api/Methods.md"
2732
}
2833
],
2934
"Simple Example": [

src/nav/zh-CN.nav.json

+10
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@
2424
"name": "插槽",
2525
"route": "api/slots",
2626
"component": "Api/Slots.md"
27+
},
28+
{
29+
"name": "方法",
30+
"route": "api/methods",
31+
"component": "Api/Methods.md"
2732
}
2833
],
2934
"基础用例": [
@@ -78,6 +83,11 @@
7883
"name": "使用插槽",
7984
"route": "advanced/components-slots",
8085
"component": "Advanced/ComponentsSlots.md"
86+
},
87+
{
88+
"name": "颜色选择器",
89+
"route": "advanced/color",
90+
"component": "Advanced/Colors.md"
8191
}
8292
]
8393
}

src/pages/Api/Methods.md

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Methods
2+
3+
### focus([index])
4+
5+
- **Arguments**:
6+
7+
- `{number} index` Slider index
8+
9+
- **Usage**
10+
11+
get focus
12+
13+
```html
14+
<vue-slider
15+
ref="slider"
16+
v-model="value"
17+
:use-keyboard="true"
18+
/>
19+
20+
this.$refs.slider.focus()
21+
```
22+
23+
### blur()
24+
25+
- **Usage**
26+
27+
remove focus
28+
29+
```html
30+
<vue-slider
31+
ref="slider"
32+
v-model="value"
33+
:use-keyboard="true"
34+
/>
35+
36+
this.$refs.slider.blur()
37+
```

src/pages/zh-CN/Advanced/Color.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# 颜色选择器
2+
3+
<example :value="example1"></example>
4+
5+
::: example color :::

src/pages/zh-CN/Advanced/ComponentsSlots.md

+4
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,9 @@
88

99
<example :value="example1"></example>
1010

11+
### 工具提示插槽
12+
13+
<example :value="example2"></example>
14+
1115
::: example components-slots :::
1216

src/pages/zh-CN/Advanced/SyncSlider.md~HEAD

-5
This file was deleted.

src/pages/zh-CN/Api/Methods.md

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# 方法
2+
3+
### focus([index])
4+
5+
- **参数**
6+
7+
- `{number} index` 滑块的索引
8+
9+
- **用法**
10+
11+
滑块获取焦点
12+
13+
```html
14+
<vue-slider
15+
ref="slider"
16+
v-model="value"
17+
:use-keyboard="true"
18+
/>
19+
20+
this.$refs.slider.focus()
21+
```
22+
23+
### blur()
24+
25+
- **用法**
26+
27+
失去焦点
28+
29+
```html
30+
<vue-slider
31+
ref="slider"
32+
v-model="value"
33+
:use-keyboard="true"
34+
/>
35+
36+
this.$refs.slider.blur()
37+
```

tests/unit/example.spec.ts

-12
This file was deleted.

tsconfig.json

+3
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919
"paths": {
2020
"@/*": [
2121
"src/*"
22+
],
23+
"~/*": [
24+
"*"
2225
]
2326
},
2427
"lib": [

vue.config.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ module.exports = {
4040
outputDir: process.env.VUE_APP_BUILD_MODE === 'package' ? 'dist' : 'docs',
4141
chainWebpack: config => {
4242
if (process.env.VUE_APP_BUILD_MODE !== 'package') {
43-
config.resolve.alias.set('vue$', 'vue/dist/vue.common')
43+
config.resolve.alias.set('vue$', 'vue/dist/vue.common').set('~', __dirname)
44+
4445
config.module
4546
.rule('md')
4647
.test(/\.md/)

0 commit comments

Comments
 (0)