11import type { FC } from 'react' ;
22
33import { SmileyIcon } from '@primer/octicons-react' ;
4+ import { IssueLabelToken , LabelGroup } from '@primer/react' ;
45
56import { type GitifyReactionGroup , IconColor } from '../../types' ;
67
7- import { formatMetricDescription } from '../../utils/notifications/formatters' ;
8+ // import { formatMetricDescription } from '../../utils/notifications/formatters';
89import { MetricPill } from './MetricPill' ;
910
1011export interface ReactionsPillProps {
@@ -31,33 +32,34 @@ export const ReactionsPill: FC<ReactionsPillProps> = ({
3132 return null ;
3233 }
3334
34- const hasMultipleReactions =
35- reactionGroups . filter ( ( rg ) => rg . reactors . totalCount > 0 ) . length > 1 ;
36-
37- const description = formatMetricDescription (
38- reactionsCount ,
39- 'reaction' ,
40- ( count , noun ) => {
41- const formatted = reactionGroups
42- . map ( ( rg ) => {
43- const emoji = reactionEmojiMap [ rg . content ] ;
44- if ( ! emoji || ! rg . reactors . totalCount ) {
45- return '' ;
46- }
47- return `${ emoji } ${ hasMultipleReactions ? rg . reactors . totalCount : '' } ` . trim ( ) ;
48- } )
49- . filter ( Boolean )
50- . join ( ' ' ) ;
51- return `${ count } ${ noun } : ${ formatted } ` ;
52- } ,
35+ const visibleReactionGroups = reactionGroups . filter (
36+ ( rg ) => ! ! rg . reactors && rg . reactors . totalCount > 0 ,
37+ ) ;
38+
39+ const reactionsContent = (
40+ < LabelGroup >
41+ { visibleReactionGroups . map ( ( rg ) => {
42+ const emoji = reactionEmojiMap [ rg . content ] ;
43+ const total = rg . reactors . totalCount ;
44+
45+ return (
46+ < IssueLabelToken
47+ fillColor = "#24292e" // Same as sidebar color from tailwind config
48+ key = { rg . content }
49+ size = "small"
50+ text = { `${ emoji } ${ total } ` }
51+ />
52+ ) ;
53+ } ) }
54+ </ LabelGroup >
5355 ) ;
5456
5557 return (
5658 < MetricPill
5759 color = { IconColor . GRAY }
60+ contents = { reactionsContent }
5861 icon = { SmileyIcon }
5962 metric = { reactionsCount }
60- title = { description }
6163 />
6264 ) ;
6365} ;
0 commit comments