-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
chore: server-side render partners #8431
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
apps/site/components/Common/Partners/PartnerButton/index.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| import Button from '#site/components/Common/Button'; | ||
|
|
||
| import type { AnchorHTMLAttributes, FC } from 'react'; | ||
|
|
||
| import style from './index.module.css'; | ||
|
|
||
| type PartnerProps = AnchorHTMLAttributes<HTMLAnchorElement> & { | ||
| size?: 'large' | 'small'; | ||
| }; | ||
|
|
||
| const PartnerButton: FC<PartnerProps> = ({ | ||
| href, | ||
| size = 'small', | ||
| ...props | ||
| }) => ( | ||
| <Button | ||
| kind="secondary" | ||
| href={`${href}/?utm_source=nodejs-website&utm_medium=Link`} | ||
| rel="sponsored noopener" | ||
| target="_blank" | ||
| className={style[size]} | ||
| {...props} | ||
| /> | ||
| ); | ||
|
|
||
| export default PartnerButton; | ||
13 changes: 0 additions & 13 deletions
13
apps/site/components/Common/Partners/PartnerIcon/index.module.css
This file was deleted.
Oops, something went wrong.
37 changes: 0 additions & 37 deletions
37
apps/site/components/Common/Partners/PartnerIcon/index.tsx
This file was deleted.
Oops, something went wrong.
30 changes: 0 additions & 30 deletions
30
apps/site/components/Common/Partners/PartnerLogo/index.tsx
This file was deleted.
Oops, something went wrong.
9 changes: 0 additions & 9 deletions
9
apps/site/components/Common/Partners/PartnersIconList/index.module.css
This file was deleted.
Oops, something went wrong.
41 changes: 0 additions & 41 deletions
41
apps/site/components/Common/Partners/PartnersIconList/index.tsx
This file was deleted.
Oops, something went wrong.
8 changes: 0 additions & 8 deletions
8
apps/site/components/Common/Partners/PartnersLogoList/index.module.css
This file was deleted.
Oops, something went wrong.
44 changes: 0 additions & 44 deletions
44
apps/site/components/Common/Partners/PartnersLogoList/index.tsx
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| @reference "../../../styles/index.css"; | ||
|
|
||
| .small { | ||
| @apply flex | ||
| flex-row | ||
| flex-wrap | ||
| items-center | ||
| gap-2; | ||
| } | ||
|
|
||
| .large { | ||
| @apply grid | ||
| w-full | ||
| grid-cols-[repeat(auto-fill,minmax(240px,1fr))] | ||
| gap-4; | ||
| } | ||
|
|
||
| .tooltip { | ||
| @apply p-2 | ||
| text-neutral-900 | ||
| dark:text-neutral-200; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,83 @@ | ||
| import Tooltip from '@node-core/ui-components/Common/Tooltip'; | ||
| import * as PartnerLogos from '@node-core/ui-components/Icons/PartnerLogos'; | ||
|
|
||
| import providePartners from '#site/next-data/providers/partners'; | ||
| import { partners } from '#site/next.json.mjs'; | ||
|
|
||
| import type { Partner, PartnerCategory } from '#site/types'; | ||
| import type { FC } from 'react'; | ||
|
|
||
| import PartnerButton from './PartnerButton'; | ||
|
|
||
| import style from './index.module.css'; | ||
|
|
||
| type PartnersListProps = { | ||
| size?: 'large' | 'small'; | ||
| category?: PartnerCategory; | ||
| sort?: 'name' | 'weight'; | ||
| length?: number; | ||
| }; | ||
|
|
||
| const getPartners = async ( | ||
| length?: number, | ||
| category?: PartnerCategory, | ||
| sort?: 'name' | 'weight' | ||
| ) => { | ||
| let result = sort === 'name' ? partners : await providePartners(); | ||
|
|
||
| result = category | ||
| ? result.filter(p => p.categories.includes(category)) | ||
| : result; | ||
|
|
||
| return length ? result.slice(0, length) : result; | ||
| }; | ||
|
|
||
| const renderSmallPartner = (partner: Partner) => { | ||
| const Logo = PartnerLogos[partner.id]; | ||
|
|
||
| return ( | ||
| <Tooltip | ||
| key={partner.id} | ||
| content={<div className={style.tooltip}>{partner.name}</div>} | ||
| > | ||
| <PartnerButton size="small" href={partner.href}> | ||
| <Logo.Favicon /> | ||
| </PartnerButton> | ||
| </Tooltip> | ||
| ); | ||
| }; | ||
|
|
||
| const renderLargePartner = (partner: Partner) => { | ||
| const Logo = PartnerLogos[partner.id]; | ||
|
|
||
| return ( | ||
| <PartnerButton key={partner.id} size="large" href={partner.href}> | ||
| <Logo.Logo /> | ||
| </PartnerButton> | ||
| ); | ||
| }; | ||
|
|
||
| const PartnersList: FC<PartnersListProps> = async ({ | ||
| size = 'small', | ||
| category, | ||
avivkeller marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| sort = 'name', | ||
| length, | ||
| }) => { | ||
| const isSmall = size === 'small'; | ||
|
|
||
| const SMALL_PARTNER_LIMIT = 6; | ||
|
|
||
| const partners = await getPartners( | ||
| length ?? (isSmall ? SMALL_PARTNER_LIMIT : undefined), | ||
| category, | ||
| sort | ||
| ); | ||
|
|
||
| return ( | ||
| <div className={style[size]}> | ||
| {partners.map(isSmall ? renderSmallPartner : renderLargePartner)} | ||
| </div> | ||
| ); | ||
| }; | ||
|
|
||
| export default PartnersList; | ||
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.