Skip to content

Commit 2f0e2be

Browse files
authored
feat: enhance PartnersLogoList to filter partners by category and allow unlimited items
1 parent 8302e8a commit 2f0e2be

File tree

3 files changed

+18
-10
lines changed

3 files changed

+18
-10
lines changed

apps/site/components/Common/Partners/PartnersLogoList/index.tsx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,14 @@ const PartnersLogoList: FC<PartnersLogoListProps> = ({
2020
}) => {
2121
const initialRenderer = useRef(true);
2222

23-
const [seedList, setSeedList] = useState<Array<Partners>>(
24-
LOGO_PARTNERS.slice(0, maxLength)
25-
);
23+
const [seedList, setSeedList] = useState<Array<Partners>>(() => {
24+
if (maxLength === null) {
25+
return LOGO_PARTNERS.filter(
26+
partner => !categories || partner.categories.includes(categories)
27+
);
28+
}
29+
return LOGO_PARTNERS.slice(0, maxLength);
30+
});
2631

2732
useEffect(() => {
2833
// We intentionally render the initial default "mock" list of sponsors

apps/site/components/Common/Partners/utils.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { PartnerCategory, Partners } from '#site/types/partners.js';
22

33
// TODO: Implement no random list
4-
// TODO: Implement no limit items
4+
// TODO: Implement no importance of partner
55
function randomPartnerList(
66
partners: Array<Partners>,
77
pick = 4,
@@ -28,12 +28,15 @@ function randomPartnerList(
2828
const rng = mulberry32(seed);
2929

3030
// Create a copy of the array to avoid modifying the original
31-
const shuffled = partners
31+
let shuffled = [...partners]
3232
.filter(partner => !category || partner.categories.includes(category))
33-
.slice()
3433
.sort(() => rng() - 0.5);
3534

36-
return shuffled.slice(0, pick);
35+
if (pick !== null) {
36+
shuffled = shuffled.slice(0, pick);
37+
}
38+
39+
return shuffled;
3740
}
3841

3942
// This function returns a random list of partners based on a fixed time seed

apps/site/pages/en/about/partners.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,19 @@ Importance of partners and their role and explains our partner categories (Ecosy
1111

1212
Projects with their logo, name, tier, the description and a CTA button
1313

14-
<PartnersLogoList categories="infrastructure" />
14+
<PartnersLogoList categories="infrastructure" maxLength={null} />
1515

1616
## Security
1717

1818
Projects with their logo, name, tier, the description and a CTA button
1919

20-
<PartnersLogoList categories="security" />
20+
<PartnersLogoList categories="security" maxLength={null} />
2121

2222
## Ecosystem Sustainability Program (ESP)
2323

2424
Projects with their logo, name, tier, the description and a CTA button
2525

26-
<PartnersLogoList categories="esp" />
26+
<PartnersLogoList categories="esp" maxLength={null} />
2727

2828
## Backers (Open Collective and GitHub Sponsors)
2929

0 commit comments

Comments
 (0)