diff --git a/docs/demos/index.js b/docs/demos/index.js index 741a1a801..df3094043 100644 --- a/docs/demos/index.js +++ b/docs/demos/index.js @@ -59,6 +59,7 @@ export default { 'radio': asyncWrapper(r => require.ensure([], () => r(componentWrapper(require('./views/radio'), 'radio')), 'radio')), 'search': asyncWrapper(r => require.ensure([], () => r(componentWrapper(require('./views/search'), 'search')), 'search')), 'sku': asyncWrapper(r => require.ensure([], () => r(componentWrapper(require('./views/sku'), 'sku')), 'sku')), + 'star-rate': asyncWrapper(r => require.ensure([], () => r(componentWrapper(require('./views/star-rate'), 'star-rate')), 'star-rate')), 'slider': asyncWrapper(r => require.ensure([], () => r(componentWrapper(require('./views/slider'), 'slider')), 'slider')), 'stepper': asyncWrapper(r => require.ensure([], () => r(componentWrapper(require('./views/stepper'), 'stepper')), 'stepper')), 'steps': asyncWrapper(r => require.ensure([], () => r(componentWrapper(require('./views/steps'), 'steps')), 'steps')), diff --git a/docs/demos/views/star-rate.vue b/docs/demos/views/star-rate.vue new file mode 100644 index 000000000..582a1014f --- /dev/null +++ b/docs/demos/views/star-rate.vue @@ -0,0 +1,83 @@ + + + + + diff --git a/docs/markdown/zh-CN/star-rate.md b/docs/markdown/zh-CN/star-rate.md new file mode 100644 index 000000000..808282985 --- /dev/null +++ b/docs/markdown/zh-CN/star-rate.md @@ -0,0 +1,92 @@ +## StarRate 评分 + +### 使用指南 +``` javascript +import { StarRate } from 'vant'; + +Vue.use(StarRate); +``` + +### 代码演示 + +#### 基础用法 + +```html + +``` + +```javascript +export default { + data() { + return { + size: 30, + value: 3, + total: 6 + }; + } +} +``` + +#### 自定义颜色 + +```html + +``` + +```javascript +export default { + data() { + return { + size: 24, + value: 5, + total: 7, + color: '#2ba', + defaultColor: '#ceefe8' + }; + } +} +``` + + +#### 竖向步骤条 +```html + +``` + +```javascript +export default { + data() { + return { + value: 2, + total: 6 + }; + } +} +``` + +### StarRate API + +| 参数 | 说明 | 类型 | 默认值 | 可选值 | +|-----------|-----------|-----------|-------------|-------------| +| size | 星标大小,单位为`px` | `Number` | 20 | - | +| total | 总分,默认为5 | `Number` | 5 | - | +| value | 分数 | `Number` | 0 | - | +| color | 选中时的星标颜色 | `String` | `#ffd21e` | - | +| default-color | 未选中时的星标颜色 | `String` | `#c7c7c7` | - | +| disabled-color | 不可选时的星标颜色 | `String` | `bdbdbd` | - | +| disabled | 是否可修改 | `Boolean` | false | - | + diff --git a/docs/src/doc.config.js b/docs/src/doc.config.js index 4154a7e0b..de516bd3d 100644 --- a/docs/src/doc.config.js +++ b/docs/src/doc.config.js @@ -136,6 +136,10 @@ module.exports = { path: '/progress', title: 'Progress - 进度条' }, + { + path: '/star-rate', + title: 'StarRate - 评分' + }, { path: '/slider', title: 'Slider - 滑块' diff --git a/packages/index.js b/packages/index.js index ac04882ff..045fc1278 100644 --- a/packages/index.js +++ b/packages/index.js @@ -48,6 +48,7 @@ import RadioGroup from './radio-group'; import Row from './row'; import Search from './search'; import Sku from './sku'; +import StarRate from './star-rate'; import Slider from './slider'; import Step from './step'; import Stepper from './stepper'; @@ -117,6 +118,7 @@ const components = [ Row, Search, Sku, + StarRate, Slider, Step, Stepper, @@ -198,6 +200,7 @@ export { Row, Search, Sku, + StarRate, Slider, Step, Stepper, diff --git a/packages/star-rate/index.vue b/packages/star-rate/index.vue new file mode 100644 index 000000000..423ce6482 --- /dev/null +++ b/packages/star-rate/index.vue @@ -0,0 +1,83 @@ + + + diff --git a/packages/vant-css/src/index.css b/packages/vant-css/src/index.css index 269044633..49f171ff0 100644 --- a/packages/vant-css/src/index.css +++ b/packages/vant-css/src/index.css @@ -24,6 +24,7 @@ @import './tabbar.css'; @import './image-preview.css'; @import './stepper.css'; +@import './star-rate.css'; @import './progress.css'; @import './swipe.css'; @import './slider.css'; diff --git a/packages/vant-css/src/star-rate.css b/packages/vant-css/src/star-rate.css new file mode 100644 index 000000000..e572574f7 --- /dev/null +++ b/packages/vant-css/src/star-rate.css @@ -0,0 +1,8 @@ +.van-star { + user-select: none; +} + +.van-star-item { + margin: 0 2px; + display: inline-block; +}