2023-03-17 16:20:25 +05:30
|
|
|
<script>
|
|
|
|
import { GlIcon } from '@gitlab/ui';
|
2023-07-09 08:55:56 +05:30
|
|
|
import { highCountTrim } from '~/lib/utils/text_utility';
|
2023-03-17 16:20:25 +05:30
|
|
|
|
|
|
|
export default {
|
|
|
|
components: {
|
|
|
|
GlIcon,
|
|
|
|
},
|
|
|
|
props: {
|
|
|
|
count: {
|
2023-06-20 00:43:36 +05:30
|
|
|
type: [Number, String],
|
2023-03-17 16:20:25 +05:30
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
href: {
|
|
|
|
type: String,
|
|
|
|
required: false,
|
|
|
|
default: '',
|
|
|
|
},
|
|
|
|
icon: {
|
|
|
|
type: String,
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
label: {
|
|
|
|
type: String,
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
ariaLabel() {
|
|
|
|
return `${this.label} ${this.count}`;
|
|
|
|
},
|
|
|
|
component() {
|
|
|
|
return this.href ? 'a' : 'button';
|
|
|
|
},
|
2023-07-09 08:55:56 +05:30
|
|
|
formattedCount() {
|
|
|
|
if (Number.isFinite(this.count)) {
|
|
|
|
return highCountTrim(this.count);
|
|
|
|
}
|
|
|
|
return this.count;
|
|
|
|
},
|
2023-03-17 16:20:25 +05:30
|
|
|
},
|
|
|
|
};
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
|
|
|
<component
|
|
|
|
:is="component"
|
|
|
|
:aria-label="ariaLabel"
|
|
|
|
:href="href"
|
2023-07-09 08:55:56 +05:30
|
|
|
class="counter gl-display-block gl-flex-grow-1 gl-text-center gl-py-3 gl-bg-gray-10 gl-rounded-base gl-text-gray-900 gl-border-none gl-inset-border-1-gray-a-08 gl-line-height-1 gl-font-sm gl-hover-text-gray-900 gl-hover-text-decoration-none gl-focus--focus"
|
2023-03-17 16:20:25 +05:30
|
|
|
>
|
|
|
|
<gl-icon aria-hidden="true" :name="icon" />
|
2023-07-09 08:55:56 +05:30
|
|
|
<span v-if="count" aria-hidden="true" class="gl-ml-1">{{ formattedCount }}</span>
|
2023-03-17 16:20:25 +05:30
|
|
|
</component>
|
|
|
|
</template>
|