@gitlab/ui
Version:
GitLab UI Components
123 lines (112 loc) • 5.63 kB
JavaScript
import GlAnimatedChevronRightDownIcon from '../animated_icon/animated_chevron_right_down_icon';
import GlIcon from '../icon/icon';
import __vue_normalize__ from 'vue-runtime-helpers/dist/normalize-component.js';
var script = {
name: 'GlNavItem',
components: {
GlAnimatedChevronRightDownIcon,
GlIcon
},
props: {
/**
* Link href attribute
*/
href: {
type: String,
required: false,
default: null
},
/**
* Icon name
*/
icon: {
type: String,
required: false,
default: null
},
/**
* Is icon only
*/
isIconOnly: {
type: Boolean,
required: false,
default: false
},
/**
* Is parent
*/
isParent: {
type: Boolean,
required: false,
default: false
},
/**
* Expanded
*/
expanded: {
type: Boolean,
required: false,
default: false
},
/**
* Is currently selected
*/
selected: {
type: Boolean,
required: false,
default: false
},
/**
* Router link to property
*/
to: {
type: [String, Object],
required: false,
default: null
}
},
computed: {
ariaExpanded() {
return this.isParent ? String(this.expanded) : null;
},
classes() {
return ['gl-nav-item', {
'gl-nav-item-is-icon-only': this.isIconOnly,
'gl-nav-item-has-start-slot': this.icon || Boolean(this.$scopedSlots.icon),
'gl-nav-item-has-end-slot': Boolean(this.$scopedSlots.end) || this.isParent,
selected: this.selected
}];
}
}
};
/* script */
const __vue_script__ = script;
/* template */
var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return (_vm.to)?_c('router-link',{attrs:{"to":_vm.to,"active-class":"selected","custom":""},scopedSlots:_vm._u([{key:"default",fn:function(ref){
var navigate = ref.navigate;
return [_c('a',{class:_vm.classes,attrs:{"aria-current":_vm.selected ? 'page' : null},on:{"click":navigate}},[(_vm.icon || _vm.$scopedSlots.icon)?_c('span',{staticClass:"gl-nav-item-slot",attrs:{"data-testid":"nav-item-start"}},[_vm._t("icon",function(){return [_c('gl-icon',{attrs:{"name":_vm.icon}})]})],2):_vm._e(),_vm._v(" "),(!_vm.isIconOnly)?[(_vm.$scopedSlots.default)?_c('span',{staticClass:"gl-nav-item-label",attrs:{"data-testid":"nav-item-label"}},[_vm._t("default",null,{"isActive":_vm.selected})],2):_vm._e(),_vm._v(" "),(_vm.$scopedSlots.end)?_c('span',{staticClass:"gl-nav-item-slot",attrs:{"data-testid":"nav-item-end"}},[_vm._t("end")],2):_vm._e()]:_vm._e()],2)]}}],null,true)}):(_vm.href)?_c('a',{class:_vm.classes,attrs:{"href":_vm.href,"aria-current":_vm.selected ? 'page' : null},on:{"click":function($event){return _vm.$emit('click')},"keydown":function($event){if(!$event.type.indexOf('key')&&_vm._k($event.keyCode,"escape",undefined,$event.key,undefined)){ return null; }return _vm.$emit('escape')},"pointerover":function($event){return _vm.$emit('pointerover', $event)},"pointerleave":function($event){return _vm.$emit('pointerleave', $event)}}},[(_vm.icon || _vm.$scopedSlots.icon)?_c('span',{staticClass:"gl-nav-item-slot",attrs:{"data-testid":"nav-item-start"}},[_vm._t("icon",function(){return [_c('gl-icon',{attrs:{"name":_vm.icon}})]})],2):_vm._e(),_vm._v(" "),(!_vm.isIconOnly)?[(_vm.$scopedSlots.default)?_c('span',{staticClass:"gl-nav-item-label",attrs:{"data-testid":"nav-item-label"}},[_vm._t("default")],2):_vm._e(),_vm._v(" "),(_vm.$scopedSlots.end)?_c('span',{staticClass:"gl-nav-item-slot",attrs:{"data-testid":"nav-item-end"}},[_vm._t("end")],2):_vm._e()]:_vm._e()],2):_c('button',{class:_vm.classes,attrs:{"aria-expanded":_vm.ariaExpanded},on:{"click":function($event){return _vm.$emit('click')},"keydown":function($event){if(!$event.type.indexOf('key')&&_vm._k($event.keyCode,"escape",undefined,$event.key,undefined)){ return null; }return _vm.$emit('escape')},"pointerover":function($event){return _vm.$emit('pointerover', $event)},"pointerleave":function($event){return _vm.$emit('pointerleave', $event)}}},[(_vm.icon || _vm.$scopedSlots.icon)?_c('span',{staticClass:"gl-nav-item-slot",attrs:{"data-testid":"nav-item-start"}},[_vm._t("icon",function(){return [_c('gl-icon',{attrs:{"name":_vm.icon}})]})],2):_vm._e(),_vm._v(" "),(!_vm.isIconOnly)?[(_vm.$scopedSlots.default)?_c('span',{staticClass:"gl-nav-item-label",attrs:{"data-testid":"nav-item-label"}},[_vm._t("default")],2):_vm._e(),_vm._v(" "),(_vm.$scopedSlots.end)?_c('span',{staticClass:"gl-nav-item-slot",attrs:{"data-testid":"nav-item-end"}},[_vm._t("end")],2):(_vm.isParent)?_c('span',{staticClass:"gl-nav-item-slot",attrs:{"data-testid":"nav-item-chevron"}},[_c('gl-animated-chevron-right-down-icon',{staticClass:"gl-nav-item-chevron",attrs:{"is-on":_vm.expanded}})],1):_vm._e()]:_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__ = /*#__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 };