11import CardLink from 'src/components/CardLink'
22import CardItemWithActions from 'src/components/CardItemWithActions'
33import { Attributes } from 'src/lib/analytics'
4- import { ArticleItemPropsType } from 'src/types'
4+ import { RepoItemPropsType } from 'src/types'
55import ColoredLanguagesBadge from 'src/components/ColoredLanguagesBadge'
66import { VscRepo , VscRepoForked , VscStarFull } from 'react-icons/vsc'
77
88const sourceName = 'github'
99
10- const ArticleItem = ( props : ArticleItemPropsType ) => {
11- const { item, index, listingMode, selectedTag } = props
10+ function numberWithCommas ( x :number | string ) {
11+ return x . toString ( ) . replace ( / \B (? = ( \d { 3 } ) + (? ! \d ) ) / g, "," ) ;
12+ }
1213
14+ const RepoItem = ( props : RepoItemPropsType ) => {
15+ const { item, index, listingMode, selectedTag } = props
16+
1317 return (
1418 < CardItemWithActions
1519 source = { sourceName }
@@ -22,7 +26,7 @@ const ArticleItem = (props: ArticleItemPropsType) => {
2226 className = "githubTitle"
2327 link = { item . url }
2428 analyticsAttributes = { {
25- [ Attributes . POINTS ] : item . reactions ,
29+ [ Attributes . POINTS ] : numberWithCommas ( item . stars ) ,
2630 [ Attributes . TRIGERED_FROM ] : 'card' ,
2731 [ Attributes . TITLE ] : item . title ,
2832 [ Attributes . LINK ] : item . url ,
@@ -35,15 +39,15 @@ const ArticleItem = (props: ArticleItemPropsType) => {
3539 < p className = "rowDescription" > { item . description } </ p >
3640 { listingMode === 'normal' && (
3741 < div className = "rowDetails" >
38- < ColoredLanguagesBadge languages = { item . tags } />
39- { item . reactions && (
42+ < ColoredLanguagesBadge languages = { [ item . programmingLanguage ] } />
43+ { numberWithCommas ( item . stars ) && (
4044 < span className = "rowItem" >
41- < VscStarFull className = "rowItemIcon" /> { item . reactions } stars
45+ < VscStarFull className = "rowItemIcon" /> { numberWithCommas ( item . stars ) } stars
4246 </ span >
4347 ) }
4448 { item . forks && (
4549 < span className = "rowItem" >
46- < VscRepoForked className = "rowItemIcon" /> { item . forks } forks
50+ < VscRepoForked className = "rowItemIcon" /> { numberWithCommas ( item . forks ) } forks
4751 </ span >
4852 ) }
4953 </ div >
@@ -54,4 +58,4 @@ const ArticleItem = (props: ArticleItemPropsType) => {
5458 )
5559}
5660
57- export default ArticleItem
61+ export default RepoItem
0 commit comments