vuetify
Version:
Vue.js 2 Semantic Component Framework
68 lines (57 loc) • 1.58 kB
JavaScript
require('../../../src/stylus/components/_breadcrumbs.styl');
export default {
name: 'v-breadcrumbs',
props: {
divider: {
type: String,
default: '/'
},
large: Boolean,
justifyCenter: Boolean,
justifyEnd: Boolean
},
computed: {
classes: function classes() {
return {
'breadcrumbs--large': this.large
};
},
computedDivider: function computedDivider() {
return this.$slots.divider ? this.$slots.divider : this.divider;
},
styles: function styles() {
var justify = this.justifyCenter ? 'center' : this.justifyEnd ? 'flex-end' : 'flex-start';
return {
'justify-content': justify
};
}
},
methods: {
/**
* Add dividers between
* v-breadcrumbs-item
*
* @return {array}
*/
genChildren: function genChildren() {
if (!this.$slots.default) return null;
var children = [];
var dividerData = { staticClass: 'breadcrumbs__divider' };
var length = this.$slots.default.length;
for (var i = 0; i < length; i++) {
var elm = this.$slots.default[i];
children.push(elm);
if (!elm.componentOptions || elm.componentOptions.tag !== 'v-breadcrumbs-item' || i === length - 1) continue;
children.push(this.$createElement('li', dividerData, this.computedDivider));
}
return children;
}
},
render: function render(h) {
return h('ul', {
staticClass: 'breadcrumbs',
'class': this.classes,
style: this.styles
}, this.genChildren());
}
};