Skip to content

Commit 96f51ca

Browse files
committed
Merge branch 'refactor/typescript-cards' of github.com:medyo/hackertab.dev into refactor/typescript-cards
2 parents 942047e + 3109fb0 commit 96f51ca

3 files changed

Lines changed: 14 additions & 4 deletions

File tree

src/components/List/ListComponent.tsx

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { ReactNode } from 'react'
22
import { Placeholder } from 'src/components/placeholders'
3+
import { MAX_ITEMS_PER_CARD } from 'src/config'
34
import { CarbonAd } from 'src/features/carbonAds'
45
import { BaseEntry } from 'src/types'
56

@@ -11,10 +12,19 @@ export type ListComponentPropsType<T extends BaseEntry> = {
1112
placeholder?: React.ReactNode
1213
refresh?: boolean
1314
error?: any
15+
limit?: number
1416
}
1517

1618
export function ListComponent<T extends BaseEntry>(props: ListComponentPropsType<T>) {
17-
const { items, isLoading, error, renderItem, withAds, placeholder = <Placeholder /> } = props
19+
const {
20+
items,
21+
isLoading,
22+
error,
23+
renderItem,
24+
withAds,
25+
placeholder = <Placeholder />,
26+
limit = MAX_ITEMS_PER_CARD,
27+
} = props
1828

1929
if (error) {
2030
return <p className="errorMsg">{error?.message || error}</p>
@@ -25,7 +35,7 @@ export function ListComponent<T extends BaseEntry>(props: ListComponentPropsType
2535
return
2636
}
2737

28-
return items.map((item, index) => {
38+
return items.slice(0, limit).map((item, index) => {
2939
let content: ReactNode[] = [renderItem(item, index)]
3040
if (withAds && index === 0) {
3141
content.unshift(<CarbonAd key={'carbonAd0'} />)

src/config/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,4 +188,4 @@ export const MY_LANGUAGES_TAG = {
188188
mediumValues: ['myLangs'],
189189
freecodecampValues: ['myLangs'],
190190
}
191-
export const MAX_MERGED_ITEMS_PER_LANGUAGE = 10
191+
export const MAX_ITEMS_PER_CARD = 50

src/features/githubCard/components/RepoItem.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ const RepoItem = (props: RepoItemPropsType) => {
2626
className="githubTitle"
2727
link={item.url}
2828
analyticsAttributes={{
29-
[Attributes.POINTS]: numberWithCommas(item.stars),
29+
[Attributes.POINTS]: item.stars,
3030
[Attributes.TRIGERED_FROM]: 'card',
3131
[Attributes.TITLE]: item.title,
3232
[Attributes.LINK]: item.url,

0 commit comments

Comments
 (0)