UNPKG

@gitlab/ui

Version:
127 lines (115 loc) 4.32 kB
import GlButton from '../../base/button/button'; import __vue_normalize__ from 'vue-runtime-helpers/dist/normalize-component.js'; var textBreaks = function textBreaks(el) { var originalWhiteSpace = el.style.whiteSpace; var blockHeight = el.offsetHeight; el.style.whiteSpace = 'nowrap'; var lineHeight = el.offsetHeight; el.style.whiteSpace = originalWhiteSpace; return blockHeight > lineHeight; }; var script = { components: { GlButton: GlButton }, props: { title: { type: String, required: true }, svgPath: { type: String, required: false, default: null }, description: { type: String, required: false, default: null }, primaryButtonLink: { type: String, required: false, default: null }, primaryButtonText: { type: String, required: false, default: null }, secondaryButtonLink: { type: String, required: false, default: null }, secondaryButtonText: { type: String, required: false, default: null }, compact: { type: Boolean, required: false, default: false } }, data: function data() { return { titleBreaks: false, descriptionBreaks: false }; }, computed: { fullscreen: function fullscreen() { return !this.compact; }, centerTitle: function centerTitle() { return !this.compact && !this.titleBreaks; }, centerDescription: function centerDescription() { return this.centerTitle && !this.descriptionBreaks; }, shouldRenderPrimaryButton: function shouldRenderPrimaryButton() { return Boolean(this.primaryButtonLink && this.primaryButtonText); }, shouldRenderSecondaryButton: function shouldRenderSecondaryButton() { return Boolean(this.shouldRenderPrimaryButton && this.secondaryButtonLink && this.secondaryButtonText); } }, mounted: function mounted() { var _this$$refs = this.$refs, title = _this$$refs.title, description = _this$$refs.description; this.titleBreaks = title && textBreaks(title); this.descriptionBreaks = description && textBreaks(description); } }; /* 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:"row",class:{ 'empty-state': _vm.fullscreen }},[_c('div',{class:_vm.fullscreen ? 'col-12' : 'col-3 d-none d-sm-block'},[(_vm.svgPath)?_c('div',{staticClass:"svg-250",class:{ 'svg-content': _vm.fullscreen }},[_c('img',{class:{ 'mw-100': _vm.compact },attrs:{"src":_vm.svgPath,"alt":_vm.title}})]):_vm._e()]),_vm._v(" "),_c('div',{class:_vm.fullscreen ? 'col-12' : 'col-sm-9'},[_c('div',{staticClass:"text-content"},[_c('h4',{ref:"title",class:{ center: _vm.centerTitle, h5: _vm.compact }},[_vm._v(_vm._s(_vm.title))]),_vm._v(" "),(_vm.description || _vm.$slots.description)?_c('p',{ref:"description",class:{ center: _vm.centerDescription }},[_vm._t("description",[_vm._v("\n "+_vm._s(_vm.description)+"\n ")])],2):_vm._e(),_vm._v(" "),_c('div',{class:{ 'text-center': _vm.fullscreen }},[_vm._t("actions",[(_vm.shouldRenderPrimaryButton)?_c('gl-button',{attrs:{"variant":"success","href":_vm.primaryButtonLink}},[_vm._v(_vm._s(_vm.primaryButtonText))]):_vm._e(),_vm._v(" "),(_vm.shouldRenderSecondaryButton)?_c('gl-button',{attrs:{"variant":"outline-success","href":_vm.secondaryButtonLink}},[_vm._v(_vm._s(_vm.secondaryButtonText))]):_vm._e()])],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__;