-
Notifications
You must be signed in to change notification settings - Fork 285
Expand file tree
/
Copy pathLabelsPill.tsx
More file actions
37 lines (29 loc) · 809 Bytes
/
LabelsPill.tsx
File metadata and controls
37 lines (29 loc) · 809 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import type { FC } from 'react';
import { TagIcon } from '@primer/octicons-react';
import { IconColor } from '../../types';
import { formatMetricDescription } from '../../utils/notifications/formatters';
import { MetricPill } from './MetricPill';
export interface LabelsPillProps {
labels: string[];
}
export const LabelsPill: FC<LabelsPillProps> = ({ labels }) => {
if (!labels?.length) {
return null;
}
const description = formatMetricDescription(
labels.length,
'label',
(count, noun) => {
const formatted = labels.map((label) => `🏷️ ${label}`).join(', ');
return `${count} ${noun}: ${formatted}`;
},
);
return (
<MetricPill
color={IconColor.GRAY}
icon={TagIcon}
metric={labels.length}
title={description}
/>
);
};