Commit 072cd25b16c307fab3c9ab6ab535637350b42ba7
Merge remote-tracking branch 'upstream/master'
Showing
10 changed files
with
171 additions
and
53 deletions
Show diff stats
src/components/modal/confirm.js
| 1 | 1 | import Vue from 'vue'; |
| 2 | 2 | import Modal from './modal.vue'; |
| 3 | 3 | import Icon from '../icon/icon.vue'; |
| 4 | -import Button from '../button/button.vue'; | |
| 4 | +import iButton from '../button/button.vue'; | |
| 5 | 5 | import { camelcaseToHyphen } from '../../utils/assist'; |
| 6 | 6 | |
| 7 | 7 | const prefixCls = 'ivu-modal-confirm'; |
| ... | ... | @@ -26,8 +26,8 @@ Modal.newInstance = properties => { |
| 26 | 26 | {{{ body }}} |
| 27 | 27 | </div> |
| 28 | 28 | <div class="${prefixCls}-footer"> |
| 29 | - <Button type="ghost" size="large" v-if="showCancel" @click="cancel">{{ cancelText }}</Button> | |
| 30 | - <Button type="primary" size="large" :loading="buttonLoading" @click="ok">{{ okText }}</Button> | |
| 29 | + <i-button type="ghost" size="large" v-if="showCancel" @click="cancel">{{ cancelText }}</i-button> | |
| 30 | + <i-button type="primary" size="large" :loading="buttonLoading" @click="ok">{{ okText }}</i-button> | |
| 31 | 31 | </div> |
| 32 | 32 | </div> |
| 33 | 33 | </Modal> |
| ... | ... | @@ -36,7 +36,7 @@ Modal.newInstance = properties => { |
| 36 | 36 | |
| 37 | 37 | const modal = new Vue({ |
| 38 | 38 | el: div, |
| 39 | - components: { Modal, Button, Icon }, | |
| 39 | + components: { Modal, iButton, Icon }, | |
| 40 | 40 | data: Object.assign(_props, { |
| 41 | 41 | visible: false, |
| 42 | 42 | width: 416, | ... | ... |
src/components/modal/modal.vue
| ... | ... | @@ -12,8 +12,8 @@ |
| 12 | 12 | <div :class="[prefixCls + '-body']"><slot></slot></div> |
| 13 | 13 | <div :class="[prefixCls + '-footer']" v-if="!footerHide"> |
| 14 | 14 | <slot name="footer"> |
| 15 | - <Button type="ghost" size="large" @click="cancel">{{ cancelText }}</Button> | |
| 16 | - <Button type="primary" size="large" :loading="buttonLoading" @click="ok">{{ okText }}</Button> | |
| 15 | + <i-button type="ghost" size="large" @click="cancel">{{ cancelText }}</i-button> | |
| 16 | + <i-button type="primary" size="large" :loading="buttonLoading" @click="ok">{{ okText }}</i-button> | |
| 17 | 17 | </slot> |
| 18 | 18 | </div> |
| 19 | 19 | </div> |
| ... | ... | @@ -22,13 +22,13 @@ |
| 22 | 22 | </template> |
| 23 | 23 | <script> |
| 24 | 24 | import Icon from '../icon'; |
| 25 | - import Button from '../button'; | |
| 25 | + import iButton from '../button/button.vue'; | |
| 26 | 26 | import { getScrollBarSize } from '../../utils/assist'; |
| 27 | 27 | |
| 28 | 28 | const prefixCls = 'ivu-modal'; |
| 29 | 29 | |
| 30 | 30 | export default { |
| 31 | - components: { Icon, Button }, | |
| 31 | + components: { Icon, iButton }, | |
| 32 | 32 | props: { |
| 33 | 33 | visible: { |
| 34 | 34 | type: Boolean, | ... | ... |
src/components/page/page.vue
| ... | ... | @@ -145,7 +145,7 @@ |
| 145 | 145 | return [ |
| 146 | 146 | `${prefixCls}-prev`, |
| 147 | 147 | { |
| 148 | - [`${prefixCls}-disabled`]: this.current == 1 | |
| 148 | + [`${prefixCls}-disabled`]: this.current === 1 | |
| 149 | 149 | } |
| 150 | 150 | ] |
| 151 | 151 | }, |
| ... | ... | @@ -153,7 +153,7 @@ |
| 153 | 153 | return [ |
| 154 | 154 | `${prefixCls}-next`, |
| 155 | 155 | { |
| 156 | - [`${prefixCls}-disabled`]: this.current == this.allPages | |
| 156 | + [`${prefixCls}-disabled`]: this.current === this.allPages | |
| 157 | 157 | } |
| 158 | 158 | ] |
| 159 | 159 | }, |
| ... | ... | @@ -161,7 +161,7 @@ |
| 161 | 161 | return [ |
| 162 | 162 | `${prefixCls}-item`, |
| 163 | 163 | { |
| 164 | - [`${prefixCls}-item-active`]: this.current == 1 | |
| 164 | + [`${prefixCls}-item-active`]: this.current === 1 | |
| 165 | 165 | } |
| 166 | 166 | ] |
| 167 | 167 | }, |
| ... | ... | @@ -169,7 +169,7 @@ |
| 169 | 169 | return [ |
| 170 | 170 | `${prefixCls}-item`, |
| 171 | 171 | { |
| 172 | - [`${prefixCls}-item-active`]: this.current == this.allPages | |
| 172 | + [`${prefixCls}-item-active`]: this.current === this.allPages | |
| 173 | 173 | } |
| 174 | 174 | ] |
| 175 | 175 | } | ... | ... |
src/components/poptip/poptip.vue
| ... | ... | @@ -37,7 +37,7 @@ |
| 37 | 37 | </template> |
| 38 | 38 | <script> |
| 39 | 39 | import Popper from '../base/popper'; |
| 40 | - import Button from '../button/button.vue'; | |
| 40 | + import iButton from '../button/button.vue'; | |
| 41 | 41 | import clickoutside from '../../directives/clickoutside'; |
| 42 | 42 | import { oneOf } from '../../utils/assist'; |
| 43 | 43 | |
| ... | ... | @@ -46,7 +46,7 @@ |
| 46 | 46 | export default { |
| 47 | 47 | mixins: [Popper], |
| 48 | 48 | directives: { clickoutside }, |
| 49 | - components: { iButton: Button }, | |
| 49 | + components: { iButton }, | |
| 50 | 50 | props: { |
| 51 | 51 | trigger: { |
| 52 | 52 | validator (value) { |
| ... | ... | @@ -92,9 +92,9 @@ |
| 92 | 92 | computed: { |
| 93 | 93 | classes () { |
| 94 | 94 | return [ |
| 95 | - prefixCls + '', | |
| 95 | + `${prefixCls}`, | |
| 96 | 96 | { |
| 97 | - [prefixCls + '-confirm']: this.confirm | |
| 97 | + [`${prefixCls}-confirm`]: this.confirm | |
| 98 | 98 | } |
| 99 | 99 | ] |
| 100 | 100 | }, |
| ... | ... | @@ -102,7 +102,7 @@ |
| 102 | 102 | let style = {}; |
| 103 | 103 | |
| 104 | 104 | if (!!this.width) { |
| 105 | - style.width = '${this.width}px'; | |
| 105 | + style.width = `${this.width}px`; | |
| 106 | 106 | } |
| 107 | 107 | return style; |
| 108 | 108 | } | ... | ... |
src/components/select/select.vue
| ... | ... | @@ -100,14 +100,14 @@ |
| 100 | 100 | computed: { |
| 101 | 101 | classes () { |
| 102 | 102 | return [ |
| 103 | - prefixCls + '', | |
| 103 | + `${prefixCls}`, | |
| 104 | 104 | { |
| 105 | - [prefixCls + '-visible']: this.visible, | |
| 106 | - [prefixCls + '-disabled']: this.disabled, | |
| 107 | - [prefixCls + '-multiple']: this.multiple, | |
| 108 | - [prefixCls + '-single']: !this.multiple, | |
| 109 | - [prefixCls + '-show-clear']: this.showCloseIcon, | |
| 110 | - [prefixCls + '-${this.size}']: !!this.size | |
| 105 | + [`${prefixCls}-visible`]: this.visible, | |
| 106 | + [`${prefixCls}-disabled`]: this.disabled, | |
| 107 | + [`${prefixCls}-multiple`]: this.multiple, | |
| 108 | + [`${prefixCls}-single`]: !this.multiple, | |
| 109 | + [`${prefixCls}-show-clear`]: this.showCloseIcon, | |
| 110 | + [`${prefixCls}-${this.size}`]: !!this.size | |
| 111 | 111 | } |
| 112 | 112 | ] |
| 113 | 113 | }, |
| ... | ... | @@ -136,7 +136,7 @@ |
| 136 | 136 | if (this.showPlaceholder) { |
| 137 | 137 | style.width = '100%'; |
| 138 | 138 | } else { |
| 139 | - style.width = '${this.inputLength}px'; | |
| 139 | + style.width = `${this.inputLength}px`; | |
| 140 | 140 | } |
| 141 | 141 | } |
| 142 | 142 | ... | ... |
| 1 | +<template> | |
| 2 | + <div :class="classes"> | |
| 3 | + <Input-number v-if="!range && showInput" :min="min" :max="max" :step="step" :value.sync="value" :disabled="disabled"></Input-number> | |
| 4 | + <div :class="[prefixCls + '-wrap']" @click="sliderClick"> | |
| 5 | + <template v-if="showStops"> | |
| 6 | + <div :class="[prefixCls + '-stop']" v-for="item in stops" :style="{ 'left': item + '%' }"></div> | |
| 7 | + </template> | |
| 8 | + <div :class="[prefixCls + '-bar']" :style="barStyle"></div> | |
| 9 | + <div :class="[prefixCls + '-button-wrap']" v-if="!range"> | |
| 10 | + <Tooltip placement="top" :content="tipFormat(value)"> | |
| 11 | + <div :class="[prefixCls + '-button']"></div> | |
| 12 | + </Tooltip> | |
| 13 | + </div> | |
| 14 | + | |
| 15 | + </div> | |
| 16 | + </div> | |
| 17 | +</template> | |
| 18 | +<script> | |
| 19 | + import InputNumber from '../../components/input-number/input-number.vue'; | |
| 20 | + import Tooltip from '../../components/tooltip/tooltip.vue'; | |
| 21 | + | |
| 22 | + const prefixCls = 'ivu-slider'; | |
| 23 | + | |
| 24 | + export default { | |
| 25 | + components: { InputNumber, Tooltip }, | |
| 26 | + props: { | |
| 27 | + min: { | |
| 28 | + type: Number, | |
| 29 | + default: 0 | |
| 30 | + }, | |
| 31 | + max: { | |
| 32 | + type: Number, | |
| 33 | + default: 100 | |
| 34 | + }, | |
| 35 | + step: { | |
| 36 | + type: Number, | |
| 37 | + default: 1 | |
| 38 | + }, | |
| 39 | + range: { | |
| 40 | + type: Boolean, | |
| 41 | + default: false | |
| 42 | + }, | |
| 43 | + value: { | |
| 44 | + type: [Number, Array], | |
| 45 | + default: 0 | |
| 46 | + }, | |
| 47 | + disabled: { | |
| 48 | + type: Boolean, | |
| 49 | + default: false | |
| 50 | + }, | |
| 51 | + showInput: { | |
| 52 | + type: Boolean, | |
| 53 | + default: false | |
| 54 | + }, | |
| 55 | + showStops: { | |
| 56 | + type: Boolean, | |
| 57 | + default: false | |
| 58 | + }, | |
| 59 | + tipFormat: { | |
| 60 | + type: Function, | |
| 61 | + default (val) { | |
| 62 | + return val; | |
| 63 | + } | |
| 64 | + } | |
| 65 | + }, | |
| 66 | + data () { | |
| 67 | + return { | |
| 68 | + prefixCls: prefixCls | |
| 69 | + } | |
| 70 | + }, | |
| 71 | + computed: { | |
| 72 | + classes () { | |
| 73 | + return [ | |
| 74 | + `${prefixCls}`, | |
| 75 | + { | |
| 76 | + [`${prefixCls}-input`]: this.showInput, | |
| 77 | + [`${prefixCls}-range`]: this.range, | |
| 78 | + [`${prefixCls}-disabled`]: this.disabled | |
| 79 | + } | |
| 80 | + ] | |
| 81 | + }, | |
| 82 | + barStyle () { | |
| 83 | + let style; | |
| 84 | + | |
| 85 | + if (this.range) { | |
| 86 | + style = { | |
| 87 | + width: (this.value[1] - this.value[0]) / (this.max - this.min) * 100 + '%', | |
| 88 | + left: (this.value[0] - this.min) / (this.max - this.min) * 100 + '%' | |
| 89 | + } | |
| 90 | + } else { | |
| 91 | + style = { | |
| 92 | + width: (this.value - this.min) / (this.max - this.min) * 100 + '%' | |
| 93 | + } | |
| 94 | + } | |
| 95 | + | |
| 96 | + return style; | |
| 97 | + }, | |
| 98 | + stops() { | |
| 99 | + return this.max / this.step; | |
| 100 | + } | |
| 101 | + }, | |
| 102 | + methods: { | |
| 103 | + sliderClick () { | |
| 104 | + | |
| 105 | + } | |
| 106 | + }, | |
| 107 | + ready () { | |
| 108 | + if (this.range) { | |
| 109 | + const isArray = Array.isArray(this.value); | |
| 110 | + if (!isArray || (isArray && this.value.length != 2) || (isArray && (!isNaN(this.value[0]) || !isNaN(this.value[1])))) { | |
| 111 | + this.value = [0, 0]; | |
| 112 | + } | |
| 113 | + } | |
| 114 | + } | |
| 115 | + } | |
| 116 | +</script> | |
| 0 | 117 | \ No newline at end of file | ... | ... |
src/components/tooltip/tooltip.vue
| 1 | 1 | <template> |
| 2 | - <div :class="[prefix]" @mouseenter="handleShowPopper" @mouseleave="handleClosePopper"> | |
| 3 | - <div :class="[prefix + '-rel']" v-el:reference> | |
| 2 | + <div :class="[prefixCls]" @mouseenter="handleShowPopper" @mouseleave="handleClosePopper"> | |
| 3 | + <div :class="[prefixCls + '-rel']" v-el:reference> | |
| 4 | 4 | <slot></slot> |
| 5 | 5 | </div> |
| 6 | - <div :class="[prefix + '-popper']" transition="fade" v-el:popper v-show="!disabled && visible"> | |
| 7 | - <div :class="[prefix + '-content']"> | |
| 8 | - <div :class="[prefix + '-arrow']"></div> | |
| 9 | - <div :class="[prefix + '-inner']"><slot name="content">{{ content }}</slot></div> | |
| 6 | + <div :class="[prefixCls + '-popper']" transition="fade" v-el:popper v-show="!disabled && visible"> | |
| 7 | + <div :class="[prefixCls + '-content']"> | |
| 8 | + <div :class="[prefixCls + '-arrow']"></div> | |
| 9 | + <div :class="[prefixCls + '-inner']"><slot name="content">{{ content }}</slot></div> | |
| 10 | 10 | </div> |
| 11 | 11 | </div> |
| 12 | 12 | </div> | ... | ... |
src/index.js
| ... | ... | @@ -27,9 +27,11 @@ import Modal from './components/modal'; |
| 27 | 27 | import { Select, Option, OptionGroup } from './components/select'; |
| 28 | 28 | import Tooltip from './components/tooltip'; |
| 29 | 29 | import Poptip from './components/poptip'; |
| 30 | +import Slider from './components/slider'; | |
| 30 | 31 | |
| 31 | 32 | const iview = { |
| 32 | 33 | Button, |
| 34 | + iButton: Button, | |
| 33 | 35 | ButtonGroup: Button.Group, |
| 34 | 36 | Icon, |
| 35 | 37 | Input, |
| ... | ... | @@ -67,7 +69,8 @@ const iview = { |
| 67 | 69 | iOption: Option, |
| 68 | 70 | iOptionGroup: OptionGroup, |
| 69 | 71 | Tooltip, |
| 70 | - Poptip | |
| 72 | + Poptip, | |
| 73 | + Slider | |
| 71 | 74 | }; |
| 72 | 75 | |
| 73 | 76 | module.exports = iview; |
| 74 | 77 | \ No newline at end of file | ... | ... |
test/routers/tag.vue
| 1 | +<style> | |
| 2 | + body{ | |
| 3 | + padding: 50px; | |
| 4 | + } | |
| 5 | +</style> | |
| 1 | 6 | <template> |
| 2 | - <Collapse active-key="1"> | |
| 3 | - <Panel key="1"> | |
| 4 | - 史蒂夫·乔布斯 | |
| 5 | - <p slot="content">史蒂夫·乔布斯(Steve Jobs),1955年2月24日生于美国加利福尼亚州旧金山,美国发明家、企业家、美国苹果公司联合创办人。</p> | |
| 6 | - </Panel> | |
| 7 | - <Panel key="2"> | |
| 8 | - 斯蒂夫·盖瑞·沃兹尼亚克 | |
| 9 | - <p slot="content">斯蒂夫·盖瑞·沃兹尼亚克(Stephen Gary Wozniak),美国电脑工程师,曾与史蒂夫·乔布斯合伙创立苹果电脑(今之苹果公司)。斯蒂夫·盖瑞·沃兹尼亚克曾就读于美国科罗拉多大学,后转学入美国著名高等学府加州大学伯克利分校(UC Berkeley)并获得电机工程及计算机(EECS)本科学位(1987年)。</p> | |
| 10 | - </Panel> | |
| 11 | - <Panel key="3"> | |
| 12 | - 乔纳森·伊夫 | |
| 13 | - <p slot="content">乔纳森·伊夫是一位工业设计师,现任Apple公司设计师兼资深副总裁,英国爵士。他曾参与设计了iPod,iMac,iPhone,iPad等众多苹果产品。除了乔布斯,他是对苹果那些著名的产品最有影响力的人。</p> | |
| 14 | - </Panel> | |
| 15 | - </Collapse> | |
| 16 | - <Input-number :max="10" :min="1" :value="1" @on-change="change"></Input-number> | |
| 17 | - <Input-number :max="10" :min="1" :step="1.2" :value="1"></Input-number> | |
| 7 | + <Slider :value="10" :tip-format="format"> | |
| 8 | + | |
| 9 | + </Slider> | |
| 18 | 10 | </template> |
| 19 | 11 | <script> |
| 20 | - import { Collapse, InputNumber } from 'iview'; | |
| 21 | - const Panel = Collapse.Panel; | |
| 12 | + import { Slider } from 'iview'; | |
| 22 | 13 | export default { |
| 23 | - components: { Collapse, Panel, InputNumber }, | |
| 14 | + components: { Slider }, | |
| 15 | + data () { | |
| 16 | + return { | |
| 17 | + | |
| 18 | + } | |
| 19 | + }, | |
| 24 | 20 | methods: { |
| 25 | - change (data) { | |
| 26 | - console.log(data); | |
| 21 | + format (val) { | |
| 22 | + return `进度:${val}%` | |
| 27 | 23 | } |
| 28 | 24 | } |
| 29 | 25 | } | ... | ... |