UNPKG

vuetify

Version:

Vue.js 2 Semantic Component Framework

147 lines (126 loc) 3.78 kB
'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); require('../../../src/stylus/components/_progress-linear.styl'); var _colorable = require('../../mixins/colorable'); var _colorable2 = _interopRequireDefault(_colorable); var _transitions = require('../transitions'); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } exports.default = { name: 'v-progress-linear', components: { VFadeTransition: _transitions.VFadeTransition, VSlideXTransition: _transitions.VSlideXTransition }, mixins: [_colorable2.default], props: { active: { type: Boolean, default: true }, backgroundColor: { type: String, default: null }, backgroundOpacity: { type: [Number, String], default: null }, bufferValue: { type: [Number, String], default: 100 }, color: { type: String, default: 'primary' }, height: { type: [Number, String], default: 7 }, indeterminate: Boolean, query: Boolean, value: { type: [Number, String], default: 0 } }, computed: { styles: function styles() { var styles = {}; if (!this.active) { styles.height = 0; } if (!this.indeterminate && parseInt(this.bufferValue, 10) !== 100) { styles.width = this.bufferValue + '%'; } return styles; }, effectiveWidth: function effectiveWidth() { if (!this.bufferValue) { return 0; } return this.value * 100 / this.bufferValue; }, backgroundStyle: function backgroundStyle() { var backgroundOpacity = this.backgroundOpacity == null ? this.backgroundColor ? 1 : 0.3 : parseFloat(this.backgroundOpacity); return { height: this.active ? this.height + 'px' : 0, opacity: backgroundOpacity, width: this.bufferValue + '%' }; } }, methods: { genDeterminate: function genDeterminate(h) { return h('div', { ref: 'front', staticClass: 'progress-linear__bar__determinate', class: this.addBackgroundColorClassChecks(), style: { width: this.effectiveWidth + '%' } }); }, genBar: function genBar(h, name) { return h('div', { staticClass: 'progress-linear__bar__indeterminate', class: this.addBackgroundColorClassChecks(_defineProperty({}, name, true)) }); }, genIndeterminate: function genIndeterminate(h) { return h('div', { ref: 'front', staticClass: 'progress-linear__bar__indeterminate', class: { 'progress-linear__bar__indeterminate--active': this.active } }, [this.genBar(h, 'long'), this.genBar(h, 'short')]); } }, render: function render(h) { var fade = h('v-fade-transition', [this.indeterminate && this.genIndeterminate(h)]); var slide = h('v-slide-x-transition', [!this.indeterminate && this.genDeterminate(h)]); var bar = h('div', { staticClass: 'progress-linear__bar', style: this.styles }, [fade, slide]); var background = h('div', { staticClass: 'progress-linear__background', class: [this.backgroundColor || this.color], style: this.backgroundStyle }); return h('div', { staticClass: 'progress-linear', class: { 'progress-linear--query': this.query }, style: { height: this.height + 'px' }, on: this.$listeners }, [background, bar]); } };