UNPKG

@gitlab/ui

Version:
106 lines (91 loc) 3.24 kB
import __vue_normalize__ from 'vue-runtime-helpers/dist/normalize-component.js'; var makePathRect = function makePathRect(startX, startY, width, height) { return "M".concat(startX, ",").concat(startY, "H").concat(startX + width, "V").concat(startY + height, "H").concat(startX, "Z"); }; var script = { props: { color: { type: String, required: true }, type: { type: String, required: false, default: 'solid' } }, data: function data() { return { labelLineHeight: 0 }; }, computed: { pathContent: function pathContent() { var width = this.$options.svgWidth; var height = this.$options.svgHeight; if (this.type === 'dashed') { var dashWidth = Math.ceil(width / 3); var firstDash = makePathRect(0, 0, dashWidth, height); var secondDash = makePathRect(width - dashWidth, 0, dashWidth, height); return "".concat(firstDash).concat(secondDash); } return makePathRect(0, 0, width, height); }, svgStyles: function svgStyles() { return { fill: this.color, transform: "translateY(".concat(this.formatPixelDimension(this.svgYTranslationValue), ")"), width: 'auto' }; }, svgYTranslationValue: function svgYTranslationValue() { var value = this.labelLineHeight / 2 - this.$options.svgHeight / 2; return Math.round(value) || 0; } }, mounted: function mounted() { if (getComputedStyle && this.$refs.label) { var computedStyle = getComputedStyle(this.$refs.label); var lineHeight = computedStyle['line-height'].match(/(\d+)px/); if (lineHeight !== null) { this.labelLineHeight = parseFloat(lineHeight[1]); } } }, methods: { formatPixelDimension: function formatPixelDimension(dimension) { return "".concat(dimension, "px"); } }, svgWidth: 16, svgHeight: 4 }; /* script */ const __vue_script__ = script; /* template */ var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{staticClass:"gl-series-label-container"},[(_vm.color.length)?_c('div',{staticClass:"gl-series-label"},[_c('svg',{style:(_vm.svgStyles),attrs:{"width":_vm.formatPixelDimension(_vm.$options.svgWidth),"height":_vm.formatPixelDimension(_vm.$options.svgHeight)}},[_c('path',{attrs:{"d":_vm.pathContent}})])]):_vm._e(),_vm._v(" "),_c('div',{ref:"label",staticClass:"gl-series-label"},[_vm._t("default")],2)])}; var __vue_staticRenderFns__ = []; /* style */ const __vue_inject_styles__ = undefined; /* scoped */ const __vue_scope_id__ = undefined; /* module identifier */ const __vue_module_identifier__ = undefined; /* functional template */ const __vue_is_functional_template__ = false; /* style inject */ /* style inject SSR */ /* style inject shadow dom */ const __vue_component__ = __vue_normalize__( { render: __vue_render__, staticRenderFns: __vue_staticRenderFns__ }, __vue_inject_styles__, __vue_script__, __vue_scope_id__, __vue_is_functional_template__, __vue_module_identifier__, false, undefined, undefined, undefined ); export default __vue_component__;