Skip to content

Commit e646e29

Browse files
authored
chore: implement list of logos on download and partners page
1 parent 6a5568c commit e646e29

File tree

39 files changed

+603
-22
lines changed

39 files changed

+603
-22
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
@reference "../../../../styles/index.css";
2+
3+
.partnerIcon {
4+
@apply flex
5+
h-[114px]
6+
max-h-[130px]
7+
w-auto
8+
min-w-12
9+
items-center
10+
justify-center
11+
rounded-lg
12+
p-6
13+
sm:p-10;
14+
15+
svg {
16+
@apply !h-12
17+
!w-auto;
18+
}
19+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import Skeleton from '@node-core/ui-components/Common/Skeleton';
2+
import type { ComponentProps, FC } from 'react';
3+
import { cloneElement } from 'react';
4+
5+
import type { Partners } from '#site/types';
6+
7+
import style from './index.module.css';
8+
import Button from '../../Button';
9+
10+
type ParnetsIconProps = Partners & ComponentProps<typeof Skeleton>;
11+
12+
const PartnersIcon: FC<ParnetsIconProps> = ({ href, logo, loading }) => {
13+
return (
14+
<Skeleton loading={loading} className="h-[114px] w-full p-2">
15+
<Button kind="secondary" href={href} className={style.partnerIcon}>
16+
{cloneElement(logo, {
17+
className: 'h-4 w-auto',
18+
width: 'auto',
19+
height: '16px',
20+
})}
21+
</Button>
22+
</Skeleton>
23+
);
24+
};
25+
26+
export default PartnersIcon;

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import { useEffect, useRef, useState, type FC } from 'react';
44

5-
import PARTNERS from '#site/next.partners.constants';
5+
import { ICON_PARTNERS } from '#site/next.partners.constants';
66
import type { PartnerCategory, Partners } from '#site/types';
77

88
import PartnerIcon from '../PartnerIcon';
@@ -21,7 +21,7 @@ const PartnersIconList: FC<PartnersIconListProps> = ({
2121
const initialRenderer = useRef(true);
2222

2323
const [seedList, setSeedList] = useState<Array<Partners>>(
24-
PARTNERS.slice(0, maxLength)
24+
ICON_PARTNERS.slice(0, maxLength)
2525
);
2626

2727
useEffect(() => {
@@ -37,7 +37,7 @@ const PartnersIconList: FC<PartnersIconListProps> = ({
3737
const renderSponsorsAnimation = setTimeout(() => {
3838
initialRenderer.current = false;
3939

40-
setSeedList(randomPartnerList(PARTNERS, maxLength, 1, categories));
40+
setSeedList(randomPartnerList(ICON_PARTNERS, maxLength, 1, categories));
4141
}, 0);
4242

4343
return () => clearTimeout(renderSponsorsAnimation);
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
@reference "../../../../styles/index.css";
2+
3+
.partnersLogoList {
4+
display: grid;
5+
gap: 16px;
6+
grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
7+
}
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
'use client';
2+
3+
import { useEffect, useRef, useState, type FC } from 'react';
4+
5+
import { LOGO_PARTNERS } from '#site/next.partners.constants';
6+
import type { PartnerCategory, Partners } from '#site/types';
7+
8+
import PartnerLogo from '../PartnerLogo';
9+
import style from './index.module.css';
10+
import { randomPartnerList } from '../utils';
11+
12+
type PartnersLogoListProps = {
13+
maxLength?: number;
14+
categories?: PartnerCategory;
15+
};
16+
17+
const PartnersLogoList: FC<PartnersLogoListProps> = ({
18+
maxLength = 3,
19+
categories,
20+
}) => {
21+
const initialRenderer = useRef(true);
22+
23+
const [seedList, setSeedList] = useState<Array<Partners>>(
24+
LOGO_PARTNERS.slice(0, maxLength)
25+
);
26+
27+
useEffect(() => {
28+
// We intentionally render the initial default "mock" list of sponsors
29+
// to have the Skeletons loading, and then we render the actual list
30+
// after an enough amount of time has passed to give a proper sense of Animation
31+
// We do this client-side effect, to ensure that a random-amount of sponsors is renderered
32+
// on every page load. Since our page is natively static, we need to ensure that
33+
// on the client-side we have a random amount of sponsors rendered.
34+
// Although whilst we are deployed on Vercel or other environment that supports ISR
35+
// (Incremental Static Generation) whose would invalidate the cache every 5 minutes
36+
// We want to ensure that this feature is compatible on a full-static environment
37+
const renderSponsorsAnimation = setTimeout(() => {
38+
initialRenderer.current = false;
39+
40+
setSeedList(randomPartnerList(LOGO_PARTNERS, maxLength, 1, categories));
41+
}, 0);
42+
43+
return () => clearTimeout(renderSponsorsAnimation);
44+
// We only want this to run once on initial render
45+
// We don't really care if the props change as realistically they shouldn't ever
46+
// eslint-disable-next-line react-hooks/exhaustive-deps
47+
}, []);
48+
49+
return (
50+
<div className={style.partnersLogoList}>
51+
{seedList.map((partner, index) => (
52+
<PartnerLogo
53+
{...partner}
54+
key={index}
55+
loading={initialRenderer.current}
56+
/>
57+
))}
58+
</div>
59+
);
60+
};
61+
62+
export default PartnersLogoList;

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

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

3+
// TODO: Implement no random list
4+
// TODO: Implement no limit items
35
function randomPartnerList(
46
partners: Array<Partners>,
57
pick = 4,

apps/site/next.mdx.use.mjs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import BadgeGroup from '@node-core/ui-components/Common/BadgeGroup';
44

55
import Button from './components/Common/Button';
66
import PartnersIconList from './components/Common/Partners/PartnersIconList';
7+
import PartnersLogoList from './components/Common/Partners/PartnersLogoList';
78
import DownloadReleasesTable from './components/Downloads/DownloadReleasesTable';
89
import Link from './components/Link';
910
import LinkWithArrow from './components/LinkWithArrow';
@@ -25,8 +26,10 @@ export const mdxComponents = {
2526
WithBanner,
2627
// HOC for providing Badge Data
2728
WithBadgeGroup,
28-
// Shows a list of Node.js Partners
29+
// Shows a list of Node.js Partners with Icons
2930
PartnersIconList,
31+
// Shows a list of Node.js Partners with Logos
32+
PartnersLogoList,
3033
// Standalone Badge Group
3134
BadgeGroup,
3235
// Renders an container for Upcoming Node.js Meetings

apps/site/next.partners.constants.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ import type { Partners } from '#site/types';
22
import { partnersList } from '#site/util/partners';
33
import partners from '#site/util/partners/constants.json' with { type: 'json' };
44

5-
const PARTNERS = partnersList(partners as Array<Omit<Partners, 'logo'>>);
5+
const PARTNERS = (type?: 'Logo' | 'Favicon') =>
6+
partnersList(partners as Array<Omit<Partners, 'logo'>>, type);
67

7-
export default PARTNERS as Array<Partners>;
8+
const ICON_PARTNERS = PARTNERS('Favicon');
9+
const LOGO_PARTNERS = PARTNERS('Logo');
10+
11+
export { ICON_PARTNERS, LOGO_PARTNERS };

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,20 @@ 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" />
15+
1416
## Security
1517

1618
Projects with their logo, name, tier, the description and a CTA button
1719

20+
<PartnersLogoList categories="security" />
21+
1822
## Ecosystem Sustainability Program (ESP)
1923

2024
Projects with their logo, name, tier, the description and a CTA button
2125

26+
<PartnersLogoList categories="esp" />
27+
2228
## Backers (Open Collective and GitHub Sponsors)
2329

2430
Show a list of lists direct individual or organizational support that can be done through OpenCollective and GitHub Sponsors

apps/site/pages/en/download/current.mdx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,15 @@ all <LinkWithArrow href="https://nodejs.org/download/release/">previous releases
3434
or the <LinkWithArrow href="https://unofficial-builds.nodejs.org/download/">unofficial</LinkWithArrow> binaries for other platforms.
3535

3636
</section>
37+
38+
<section>
39+
<h2 className='text-center'>Thanks by Our Partners</h2>
40+
41+
<span className="text-center">
42+
We are able to serve Node.js downloads and maintain our infrastructure thanks
43+
to our <Link href="/about/partners">amazing partners</Link>.
44+
</span>
45+
<div className='mt-4'>
46+
<PartnersLogoList categories="infrastructure"/>
47+
</div>
48+
</section>

0 commit comments

Comments
 (0)