UNPKG

@gitlab/ui

Version:
101 lines (90 loc) 3.47 kB
import GlIcon from '../icon/icon'; import __vue_normalize__ from 'vue-runtime-helpers/dist/normalize-component.js'; var script = { name: 'GlAttributeList', components: { GlIcon }, props: { /** * Array of items to display. Each item should have `label`, `text`, and optionally `icon` properties. */ items: { type: Array, required: false, default: () => [], validator: items => { return items.every(item => item && typeof item.label === 'string' && typeof item.text === 'string'); } }, /** * CSS classes on attribute list item label contents */ labelClass: { type: String, required: false, default: '' }, /** * CSS classes on attribute list item description contents */ descriptionClass: { type: String, required: false, default: '' }, /** * Layout of label and text: 'horizontal' for inline/flex or 'vertical' for block. */ layout: { type: String, default: 'horizontal', required: false, validator: value => ['horizontal', 'vertical'].includes(value) } }, computed: { layoutClass() { return { 'gl-attribute-list-horizontal-items': this.layout === 'horizontal', 'gl-attribute-list-vertical-items': this.layout === 'vertical' }; }, rowCount() { // Calculate rows needed when there is enough space for 2 column layout const rows = Math.ceil(this.items.length / 2); return { '--attribute-list-row-count': rows }; } } }; /* 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('dl',{staticClass:"gl-attribute-list",class:_vm.layoutClass,style:(_vm.rowCount),attrs:{"data-testid":"gl-attribute-list"}},_vm._l((_vm.items),function(item,index){return _c('div',{key:index,staticClass:"gl-attribute-list-item",attrs:{"data-testid":"gl-attribute-list-item"}},[_c('dt',{staticClass:"gl-attribute-list-item-label",class:_vm.labelClass,attrs:{"data-testid":"gl-attribute-list-item-label"}},[_vm._t("label",function(){return [(item.icon)?_c('gl-icon',{staticClass:"gl-attribute-list-item-label-icon",attrs:{"name":item.icon,"variant":"strong"}}):_vm._e(),_vm._v(" "),_c('span',[_vm._v(_vm._s(item.label))])]},{"item":item,"index":index})],2),_vm._v(" "),_c('dd',{staticClass:"gl-attribute-list-item-description",class:_vm.descriptionClass,attrs:{"data-testid":"gl-attribute-list-item-description"}},[_vm._t("description",function(){return [_vm._v("\n "+_vm._s(item.text)+"\n ")]},{"item":item,"index":index})],2)])}),0)}; 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__ = /*#__PURE__*/__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 { __vue_component__ as default };