Skip to content

Commit 84604d8

Browse files
committed
Improve the landing
1 parent 11bb166 commit 84604d8

File tree

6 files changed

+92
-86
lines changed

6 files changed

+92
-86
lines changed

src/_design-system/syntax/light.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
"diffEditor.insertedTextBackground": "#b7e7a44b",
2828
"diffEditor.removedTextBackground": "#e597af52",
2929
"editor.background": "#ffffff",
30-
"editor.foreground": "#6E7557",
30+
"editor.foreground": "#4f533f",
3131
"editor.lineHighlightBorder": "#f2f2f2",
3232
"editorBracketMatch.background": "#E7F3FF",
3333
"editorBracketMatch.border": "#c8e1ff",
@@ -193,7 +193,6 @@
193193
"entity.name.tag.yaml",
194194
"support.function.node",
195195
"support.type.property-name.json",
196-
"punctuation.separator.key-value",
197196
"punctuation.definition.template-expression"
198197
],
199198
"settings": {
@@ -270,7 +269,6 @@
270269
"scope": [
271270
"punctuation.definition.arguments",
272271
"punctuation.definition.dict",
273-
"punctuation.separator",
274272
"meta.function-call.arguments"
275273
],
276274
"settings": {

src/components/code-blocks/index.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ import _V2 from "./v2.mdx"
1515
import _V3 from "./v3.mdx"
1616
import _V4 from "./v4.mdx"
1717
import _V5 from "./v5.mdx"
18-
import _Query from "./query.mdx"
19-
import _Schema from "./schema.mdx"
18+
export { default as Query } from "./query.mdx"
19+
export { default as Schema } from "./schema.mdx"
2020
import _QueryHeroFriends from "./query.hero-friends.mdx"
2121
import _ResponseHeroFriends from "./response.hero-friends.mdx"
2222
import _PredictableResult from "./predictable-result.mdx"
@@ -35,8 +35,6 @@ export const Code2 = () => <_Code2 components={components} />
3535
export const Code3 = () => <_Code3 components={components} />
3636
export const Code4 = () => <_Code4 components={components} />
3737

38-
export const Query = () => <_Query components={components} />
39-
export const Schema = () => <_Schema components={components} />
4038
export const CodeA = () => <_CodeA components={components} />
4139
export const CodeB = () => <_CodeB components={components} />
4240
export const CodeC = () => <_CodeC components={components} />
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
import { ComponentPropsWithoutRef, useEffect, useRef } from "react"
2+
import { clsx } from "clsx"
3+
import { Code } from "nextra/components"
4+
5+
import { Pre } from "@/components/pre"
6+
7+
import { Query, Schema } from "../../code-blocks"
8+
9+
const components = {
10+
pre: (props: ComponentPropsWithoutRef<typeof Pre>) => (
11+
<Pre
12+
{...props}
13+
// todo: this bg style might need to become global for all code blocks
14+
className={clsx(
15+
props.className,
16+
"!bg-neu-0/[.48] backdrop-blur-[6px] max-xs:[&_span]:!text-xs",
17+
)}
18+
tabIndex={-1}
19+
/>
20+
),
21+
code: Code,
22+
}
23+
24+
export function ConsistencyFigure() {
25+
const queryRef = useRef<HTMLDivElement>(null)
26+
useEffect(() => {
27+
const [queryCode, responseCode] = queryRef.current!.querySelectorAll(
28+
"code",
29+
) as unknown as HTMLElement[]
30+
let line = 0
31+
const typeLines = [1, 5, 6, 5, 7, 12, 13, 8, 17, 18, 19, 12]
32+
const queryLines = [1, 2, 3, 4, 5, 6, 7, 9, 10, 11, 12, 13]
33+
let timer: any
34+
35+
const highlightLine = () => {
36+
// Reset previous line
37+
queryCode.children[queryLines.at(line - 1)!].classList.remove(
38+
"highlighted",
39+
)
40+
responseCode.children[typeLines.at(line - 1)!].classList.remove(
41+
"highlighted",
42+
)
43+
44+
// TODO: Whenever we're adding .highlighted, we should also ensure it's visible on screen.
45+
// We can simplify this by scrolling to bottom in last 3 steps.
46+
queryCode.children[queryLines.at(line)!].classList.add("highlighted")
47+
responseCode.children[typeLines.at(line)!].classList.add("highlighted")
48+
line = (line + 1) % typeLines.length
49+
50+
timer = setTimeout(highlightLine, 1_000 + Math.random() * 200)
51+
}
52+
highlightLine()
53+
return () => clearTimeout(timer)
54+
}, [])
55+
56+
return (
57+
<section
58+
id="type-system"
59+
className="nextra-codeblocks flex w-full bg-gradient-to-b from-transparent to-sec-lighter px-[14px] py-[30px] dark:to-sec-darker/25 xl:px-[46px] [&_pre]:!h-[420px]"
60+
>
61+
<div
62+
className="nextra-codeblocks grid w-full grid-cols-2 [&_.highlighted]:!bg-pri-lighter/50 dark:[&_.highlighted]:!bg-neu-200/10"
63+
aria-hidden
64+
ref={queryRef}
65+
>
66+
<Query components={components} />
67+
<Schema components={components} />
68+
</div>
69+
</section>
70+
)
71+
}

src/components/index-page/graphql-advantages/index.tsx

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
import { Button } from "@/app/conf/_design-system/button"
22
import { SectionLabel } from "@/app/conf/_design-system/section-label"
33
import { ReactNode } from "react"
4+
import { clsx } from "clsx"
45

56
import { PrecisionFigure } from "./precision"
67
import { OptimizationFigure } from "./optimization"
78
import { ProductivityFigure } from "./productivity"
9+
import { ConsistencyFigure } from "./consistency"
810

911
export function GraphQLAdvantages() {
1012
return (
@@ -48,8 +50,8 @@ export function GraphQLAdvantages() {
4850
<Subsection
4951
name="Consistency"
5052
bigText="Build confidently with a type-safe schema"
51-
text="GraphQL APIs are structured around types and fields, not rigid endpoints. This ensures data consistency, self-documentation, and clear, actionable errors. Apps can use types to avoid writing manual parsing code."
52-
figure={null}
53+
text="GraphQL APIs are structured around types and fields, not endpoints. This ensures data consistency, self-documentation, and clear, actionable errors. Apps can use types to avoid writing manual parsing code."
54+
figure={<ConsistencyFigure />}
5355
cta={
5456
<Button href="/learn/schema" variant="secondary">
5557
Learn more about GraphQL schemas
@@ -93,26 +95,35 @@ function Subsection({
9395
cta,
9496
figure,
9597
text,
98+
className,
9699
}: {
97100
name: string
98101
bigText: ReactNode
99102
cta: ReactNode
100103
figure: ReactNode
101104
text: ReactNode
105+
className?: string
102106
}) {
103107
return (
104-
<article className="grid gap-x-4 lg:grid-cols-2 lg:*:[grid-column:1] xl:gap-x-12">
108+
<article
109+
className={clsx(
110+
"grid gap-x-4 lg:grid-cols-2 lg:*:[grid-column:1] xl:gap-x-16 2xl:gap-x-24",
111+
className,
112+
)}
113+
>
105114
<h3 className="typography-body-sm size-min items-center justify-center bg-sec-light px-1 py-[1.5px] font-normal dark:bg-sec-darker">
106115
{name}
107116
</h3>
108-
<strong className="typography-h3 mt-4 font-normal lg:mt-8">
117+
<strong className="typography-h3 mt-4 text-balance font-normal lg:mt-8">
109118
{bigText}
110119
</strong>
111-
<div className="flex max-lg:mt-6 max-sm:-mx-4 lg:row-start-1 lg:row-end-5 lg:![grid-column:2]">
120+
<div className="flex max-lg:mt-6 max-sm:-mx-4 lg:row-start-1 lg:row-end-6 lg:![grid-column:2]">
112121
{figure}
113122
</div>
114-
<p className="typography-body-lg my-6 lg:mb-4 lg:mt-8">{text}</p>
115-
<div className="self-end lg:justify-self-start">{cta}</div>
123+
<p className="typography-body-lg my-6 text-pretty lg:mb-4 lg:mt-8">
124+
{text}
125+
</p>
126+
<div className="self-end lg:justify-self-start xl:mt-2">{cta}</div>
116127
</article>
117128
)
118129
}

src/components/index-page/index.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { Hero } from "./hero"
22
import { TrustedBy } from "./trusted-by"
33
import { SingleRequest } from "./single-request"
4-
import { TypeSystem } from "./type-system"
54
import { WithoutVersion } from "./without-version"
65
import { BringYourOwnCode } from "./bring-your-own-code"
76
import { WhoIsUsing } from "./who-is-using"
@@ -32,7 +31,6 @@ export function IndexPage() {
3231
</p>
3332
</section>
3433
<SingleRequest />
35-
<TypeSystem />
3634
<WithoutVersion />
3735
<BringYourOwnCode />
3836
<WhoIsUsing />

src/components/index-page/type-system.tsx

Lines changed: 0 additions & 70 deletions
This file was deleted.

0 commit comments

Comments
 (0)