-
Notifications
You must be signed in to change notification settings - Fork 115
Comparison Pages (WIP: Needs content) #6717
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
Draft
hasparus
wants to merge
9
commits into
main
Choose a base branch
from
comparison-pages
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
36cfebc
Draft a comparison page
hasparus 3a4aac5
Make the table look good
hasparus 06fdb40
Add "." to "vs"
hasparus de42471
Put the comparison in .json file
hasparus 3bd84c4
Move to the path pattern Saihaj proposed in Figma
hasparus 1019718
Merge branch 'main' into comparison-pages
hasparus 13b4a03
Format
hasparus 078d879
Add missing React key
hasparus 84fef15
Replace URL-encoded characters in dirname
hasparus 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
There are no files selected for viewing
22 changes: 22 additions & 0 deletions
22
packages/web/docs/src/app/compare/gateway/[comparison]/apollo-router.json
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 @@ | ||
{ | ||
"name": "Apollo Router", | ||
"logo": "apollo", | ||
"sections": [ | ||
{ | ||
"title": "Features Set 1", | ||
"description": "Lorem ipsum dolor sit amet, consectetur adipiscing elit.", | ||
"rows": [ | ||
{ "feature": "Feature 1", "values": [false, true] }, | ||
{ "feature": "Feature 2", "values": [false, true] }, | ||
{ "feature": "Feature 3", "values": [false, true] }, | ||
{ "feature": "Feature 4", "values": [true, false] }, | ||
{ "feature": "Feature ...", "values": [true, false] } | ||
] | ||
}, | ||
{ | ||
"title": "Features Set 2", | ||
"description": "Lorem ipsum dolor sit amet, consectetur adipiscing elit.", | ||
"rows": [{ "feature": "Feature 1", "values": [false, true] }] | ||
} | ||
] | ||
} |
141 changes: 141 additions & 0 deletions
141
packages/web/docs/src/app/compare/gateway/[comparison]/page.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,141 @@ | ||
import { readdir, readFile } from 'node:fs/promises'; | ||
import { dirname, join } from 'node:path'; | ||
import { CommunitySection } from '#components/community-section'; | ||
import { CompanyTestimonialsSection } from '#components/company-testimonials'; | ||
import { ErrorBoundary } from '#components/error-boundary'; | ||
import { LandingPageContainer } from '#components/landing-page-container'; | ||
import { TrustedBySection } from '#components/trusted-by-section'; | ||
import { | ||
CallToAction, | ||
GetYourAPIGameRightSection, | ||
Hero, | ||
HeroLogo, | ||
HiveGatewayIcon, | ||
NextPageProps, | ||
} from '@theguild/components'; | ||
import { FederationCompatibleBenchmarksSection } from '../../../gateway/federation-compatible-benchmarks'; | ||
import { GatewayHeroDecoration } from '../../../gateway/gateway-hero-decoration'; | ||
import { otherLogos } from '../../../gateway/other-logos'; | ||
import { metadata as rootMetadata } from '../../../layout'; | ||
import { ComparisonSection, ComparisonTable } from '../comparison-table'; | ||
|
||
const __dirname = dirname(new URL(import.meta.url).pathname) | ||
.replace('%5B', '[') | ||
.replace('%5D', ']'); | ||
|
||
|
||
const DESCRIPTION = | ||
'See why teams choose a fully open-source gateway instead of other closed solutions'; | ||
|
||
export default async function ComparisonPage(props: NextPageProps<'comparison'>) { | ||
const comparison = JSON.parse( | ||
await readFile(join(__dirname, `${(await props.params).comparison}.json`), 'utf-8'), | ||
) as Comparison; /* we don't really need to parse this because it's a static build */ | ||
|
||
const Logo = otherLogos[comparison.logo as keyof typeof otherLogos]; | ||
|
||
return ( | ||
<LandingPageContainer className="text-green-1000 light mx-auto max-w-[90rem] overflow-hidden"> | ||
<Hero | ||
top={ | ||
<HeroLogo> | ||
<HiveGatewayIcon /> | ||
</HeroLogo> | ||
} | ||
className="bg-beige-100 mx-4 max-sm:mt-2 md:mx-6" | ||
heading={`Hive Gateway vs. ${comparison.name}`} | ||
checkmarks={['Fully open source', 'No vendor lock-in', 'Can be self-hosted!']} | ||
text={DESCRIPTION} | ||
> | ||
<CallToAction variant="primary-inverted" href="/docs/gateway"> | ||
Get Started | ||
</CallToAction> | ||
<CallToAction variant="secondary-inverted" href="https://github.com/graphql-hive/gateway"> | ||
GitHub | ||
</CallToAction> | ||
<GatewayHeroDecoration> | ||
<defs> | ||
<linearGradient | ||
id="gateway-hero-gradient" | ||
x1="-188.558" | ||
y1="63.4883" | ||
x2="118.605" | ||
y2="411.163" | ||
gradientUnits="userSpaceOnUse" | ||
> | ||
<stop stopColor="white" stopOpacity="0.5" /> | ||
<stop offset="1" stopColor="white" /> | ||
</linearGradient> | ||
<linearGradient | ||
id="gateway-hero-gradient-mobile" | ||
x1="-188.558" | ||
y1="63.4883" | ||
x2="118.605" | ||
y2="411.163" | ||
gradientUnits="userSpaceOnUse" | ||
> | ||
<stop stopColor="white" stopOpacity="0.3" /> | ||
<stop offset="1" stopColor="white" /> | ||
</linearGradient> | ||
</defs> | ||
</GatewayHeroDecoration> | ||
</Hero> | ||
<TrustedBySection className="mx-auto my-8 md:my-16 lg:my-24" /> | ||
<ComparisonTable | ||
// We assume Hive Gateway is always the second column. | ||
columns={[ | ||
{ | ||
name: comparison.name, | ||
icon: <Logo className="text-green-800" />, | ||
}, | ||
{ | ||
name: 'Hive Gateway', | ||
icon: <HiveGatewayIcon className="text-green-800" />, | ||
}, | ||
]} | ||
sections={comparison.sections} | ||
/> | ||
<CompanyTestimonialsSection className="mx-4 mt-6 md:mx-6" /> | ||
<ErrorBoundary | ||
fallback={ | ||
// this section doesn't make sense if data didn't load, so we just unmount | ||
null | ||
} | ||
> | ||
<FederationCompatibleBenchmarksSection /> | ||
</ErrorBoundary> | ||
{/* todo: smaller Community-driven open-source section */} | ||
<CommunitySection className="mx-4 mt-6 md:mx-6" /> | ||
<GetYourAPIGameRightSection className="mx-4 mt-6 sm:mb-6 md:mx-6 lg:mt-[64px]" /> | ||
</LandingPageContainer> | ||
); | ||
} | ||
|
||
export async function generateStaticParams() { | ||
const dir = await readdir(__dirname); | ||
const jsonFiles = dir.filter(file => file.endsWith('.json')); | ||
return jsonFiles.map(file => ({ comparison: file.replace('.json', '') })); | ||
} | ||
|
||
export async function generateMetadata({ params }: NextPageProps<'comparison'>) { | ||
const file = join(__dirname, `${(await params).comparison}.json`); | ||
|
||
const comparison = JSON.parse( | ||
await readFile(file, 'utf-8'), | ||
) as Comparison; /* we don't really need to parse this because it's a static build */ | ||
|
||
return { | ||
title: `Hive Gateway vs. ${comparison.name}`, | ||
description: DESCRIPTION, | ||
alternates: { | ||
// to remove leading slash | ||
canonical: '.', | ||
}, | ||
openGraph: rootMetadata!.openGraph, | ||
}; | ||
} | ||
|
||
interface Comparison { | ||
name: string; | ||
logo: string; | ||
sections: ComparisonSection[]; | ||
} |
118 changes: 118 additions & 0 deletions
118
packages/web/docs/src/app/compare/gateway/comparison-table.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,118 @@ | ||
'use client'; | ||
|
||
import { Fragment, ReactNode } from 'react'; | ||
import { cn, Heading, ComparisonTable as Table } from '@theguild/components'; | ||
import { CheckmarkIcon, XIcon } from '../../../components/icons'; | ||
import { NestedSticky } from '../../../components/nested-sticky'; | ||
import { TableSubheaderRow } from '../../../components/pricing/table-subheader-row'; | ||
|
||
const NO = <XIcon className="text-critical-dark mx-auto size-6" />; | ||
const YES = <CheckmarkIcon className="text-positive-dark mx-auto size-6" />; | ||
|
||
export type ComparisonColumn = { | ||
name: string; | ||
icon?: ReactNode; | ||
}; | ||
|
||
export type ComparisonSection = { | ||
title: string; | ||
description: ReactNode; | ||
icon?: ReactNode; | ||
rows: ComparisonRow[]; | ||
}; | ||
|
||
export type ComparisonRow = { | ||
feature: string; | ||
values: (ReactNode | boolean)[]; | ||
}; | ||
|
||
export type ComparisonTableProps = { | ||
className?: string; | ||
columns: ComparisonColumn[]; | ||
sections: ComparisonSection[]; | ||
}; | ||
|
||
export function ComparisonTable({ className, columns, sections }: ComparisonTableProps) { | ||
return ( | ||
<section className={cn('relative p-4 py-12', className)}> | ||
<Heading size="md" as="h2" className="mx-auto w-[940px] max-w-full text-pretty text-center"> | ||
Hive Gateway allows you to do so much more. On your own terms. | ||
</Heading> | ||
<p className="mt-4 text-center text-green-800"> | ||
Part of the Hive ecosystem, Hive Gateway is a fully-fledged solution that you can easily | ||
tailor to your needs. | ||
</p> | ||
|
||
<div className="md:nextra-scrollbar mt-16 md:-mx-6 md:overflow-x-auto md:px-6"> | ||
<NestedSticky offsetTop={80} offsetBottom={90}> | ||
<div | ||
aria-hidden | ||
className="bg-beige-100 [[data-sticky]>&]:border-beige-200 relative flex items-center rounded-3xl border border-transparent *:text-left max-sm:-translate-y-4 sm:*:w-1/3 [[data-sticky]>&]:rounded-t-none [[data-sticky]>&]:shadow-sm" | ||
> | ||
<div className="z-10 flex-1 rounded-l-3xl p-6 text-xl/6 font-normal"> | ||
Compare features | ||
</div> | ||
{columns.map(column => ( | ||
<div className="py-6 last:rounded-r-3xl" key={column.name}> | ||
<div className="border-beige-400 flex items-center justify-center gap-4 border-l px-6"> | ||
{column.icon && <div className="mr-2 *:size-10">{column.icon}</div>} | ||
<div className="text-xl/6 font-medium max-sm:sr-only">{column.name}</div> | ||
</div> | ||
</div> | ||
))} | ||
</div> | ||
</NestedSticky> | ||
|
||
<Table | ||
scheme="green" | ||
className="table w-full border-separate border-spacing-0 border-none [&_tbody_tr>:last-child:not(:first-child)]:bg-green-100" | ||
> | ||
<thead className="sr-only"> | ||
<tr> | ||
<th>Compare features</th> | ||
{columns.map((column, i) => ( | ||
<th key={i}>{column.name}</th> | ||
))} | ||
</tr> | ||
</thead> | ||
<tbody> | ||
{sections.map((section, sectionIndex) => ( | ||
<Fragment key={sectionIndex}> | ||
<TableSubheaderRow | ||
icon={section.icon} | ||
title={section.title} | ||
description={section.description} | ||
/> | ||
{section.rows.map((row, rowIndex) => ( | ||
<tr key={rowIndex}> | ||
<ComparisonTableCell className="whitespace-pre"> | ||
{row.feature} | ||
</ComparisonTableCell> | ||
{row.values.map((value, columnIndex) => ( | ||
<ComparisonTableCell key={columnIndex}> | ||
{typeof value === 'boolean' ? (value ? YES : NO) : value} | ||
</ComparisonTableCell> | ||
))} | ||
</tr> | ||
))} | ||
</Fragment> | ||
))} | ||
</tbody> | ||
</Table> | ||
</div> | ||
</section> | ||
); | ||
} | ||
|
||
function ComparisonTableCell({ children, className }: { children: ReactNode; className?: string }) { | ||
return ( | ||
<td | ||
className={cn( | ||
'border-beige-400 border-b border-r p-4 first:border-l first:font-medium max-sm:min-w-[97px] max-sm:text-sm max-sm:first:w-full sm:w-1/3 sm:py-6 [&:not(:first-child)]:border-l-0 [&:not(:first-child)]:text-center [&:not(:first-child)]:text-sm [&:not(:first-child)]:text-green-800 [.subheader+tr>&:last-child]:rounded-tr-3xl [.subheader+tr>&]:border-t [.subheader+tr>&]:first:rounded-tl-3xl [tr:is(:has(+.subheader),:last-child)>&:last-child]:rounded-br-3xl [tr:is(:last-child,:has(+.subheader))>&]:first:rounded-bl-3xl', | ||
className, | ||
)} | ||
> | ||
{children} | ||
</td> | ||
); | ||
} |
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
19 changes: 19 additions & 0 deletions
19
packages/web/docs/src/app/gateway/gateway-hero-decoration.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,19 @@ | ||
import { ReactNode } from 'react'; | ||
import { DecorationIsolation, HiveGatewayIcon } from '@theguild/components'; | ||
|
||
export function GatewayHeroDecoration({ children }: { children: ReactNode }) { | ||
return ( | ||
<DecorationIsolation className="-z-10"> | ||
<HiveGatewayIcon className="absolute left-[-268px] top-[-8px] size-[520px] fill-[url(#gateway-hero-gradient)] max-lg:hidden" /> | ||
<HiveGatewayIcon className="absolute right-[-144px] top-[-64px] size-[320px] fill-[url(#gateway-hero-gradient-mobile)] md:bottom-[-64px] md:right-[-268px] md:top-auto md:size-[520px] md:fill-[url(#gateway-hero-gradient)] lg:bottom-[-8px]" /> | ||
<svg | ||
className="pointer-events-none -z-50 size-0" | ||
width="192" | ||
height="296" | ||
viewBox="0 0 192 296" | ||
> | ||
{children} | ||
</svg> | ||
</DecorationIsolation> | ||
); | ||
} |
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.