@gitlab/ui
Version:
GitLab UI Components
199 lines (188 loc) • 5.45 kB
JavaScript
import GlAvatar from '../avatar/avatar';
import GlLink from '../link/link';
import { avatarSizeOptions, avatarShapeOptions } from '../../../utils/constants';
import { avatarSizeValidator } from '../avatar/utils';
import __vue_normalize__ from 'vue-runtime-helpers/dist/normalize-component.js';
var script = {
name: 'GlAvatarLabeled',
components: {
GlAvatar,
GlLink
},
inheritAttrs: false,
props: {
/**
* Label displayed to the right of the avatar.
*/
label: {
type: String,
required: true
},
/**
* Sub-label displayed below the label when inlineLabels is false.
* Displayed to the right of label when inlineLabels is true.
*/
subLabel: {
type: String,
required: false,
default: ''
},
/**
* Link for the label.
*/
labelLink: {
type: String,
required: false,
default: ''
},
/**
* Attributes to pass to the label link.
*/
labelLinkAttrs: {
type: Object,
required: false,
default() {
return {};
}
},
/**
* Link for the sub-label.
*/
subLabelLink: {
type: String,
required: false,
default: ''
},
/**
* Display label and sub-label inline.
*/
inlineLabels: {
type: Boolean,
required: false,
default: false
},
/**
* ID of the entity, used to generate a unique placeholder avatar.
*/
entityId: {
type: Number,
required: false,
default: 0
},
/**
* Name of the entity, used to generate a unique placeholder avatar.
*/
entityName: {
type: String,
required: false,
default: ''
},
/**
* Avatar image src.
*/
src: {
type: String,
required: false,
default: ''
},
/**
* Show fallback identicon when image fails to load
*/
fallbackOnError: {
type: Boolean,
required: false,
default: false
},
/**
* Size of the avatar.
* Available sizes are 96, 64, 48, 32, 24, 16.
*/
size: {
type: [Number, Object],
required: false,
default: avatarSizeOptions[1],
validator: avatarSizeValidator
},
/**
* Shape of the avatar.
* Available shapes are `circle` and `rect`.
*/
shape: {
type: String,
required: false,
default: avatarShapeOptions.circle
}
},
computed: {
hasLabelLink() {
return Boolean(this.labelLink);
},
hasSubLabelLink() {
return Boolean(this.subLabelLink);
},
avatarListeners() {
if (this.hasLabelLink) {
return {
...this.$listeners,
click: this.onAvatarClick
};
}
return this.$listeners;
},
avatarCssClasses() {
return {
'gl-cursor-pointer': this.hasLabelLink
};
},
avatarRowLayoutClass() {
return {
'inline-labels': this.inlineLabels
};
},
avatarPropsAndAttrs() {
return {
...this.$attrs,
entityId: this.entityId,
entityName: this.entityName,
src: this.src,
fallbackOnError: this.fallbackOnError,
size: this.size,
shape: this.shape
};
}
},
methods: {
onAvatarClick() {
this.$refs.labelLink.$el.click();
}
}
};
/* 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-avatar-labeled"},[_c('gl-avatar',_vm._g(_vm._b({class:_vm.avatarCssClasses,attrs:{"alt":""}},'gl-avatar',_vm.avatarPropsAndAttrs,false),_vm.avatarListeners)),_vm._v(" "),_c('div',{staticClass:"gl-avatar-labeled-labels !gl-text-left",class:_vm.avatarRowLayoutClass},[_c('div',{staticClass:"-gl-mx-1 -gl-my-1 gl-flex gl-flex-wrap gl-items-center !gl-text-left"},[(_vm.hasLabelLink)?_c('gl-link',_vm._b({ref:"labelLink",staticClass:"gl-avatar-link",attrs:{"href":_vm.labelLink,"variant":"meta"},on:{"click":function($event){return _vm.$emit('label-link-click', $event)}}},'gl-link',_vm.labelLinkAttrs,false),[_c('span',{staticClass:"gl-avatar-labeled-label"},[_vm._v(_vm._s(_vm.label))])]):_c('span',{staticClass:"gl-avatar-labeled-label"},[_vm._v(_vm._s(_vm.label))]),_vm._v(" "),_vm._t("meta")],2),_vm._v(" "),(_vm.hasSubLabelLink)?_c('gl-link',{staticClass:"gl-avatar-link",attrs:{"href":_vm.subLabelLink,"variant":"meta"}},[_c('span',{staticClass:"gl-avatar-labeled-sublabel"},[_vm._v(_vm._s(_vm.subLabel))])]):_c('span',{staticClass:"gl-avatar-labeled-sublabel"},[_vm._v(_vm._s(_vm.subLabel))]),_vm._v(" "),_vm._t("default")],2)],1)};
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 };