Skip to content

Commit 0c4ea61

Browse files
committed
wip
1 parent f26d592 commit 0c4ea61

File tree

1 file changed

+33
-29
lines changed
  • src/components/index-page/what-is-graphql

1 file changed

+33
-29
lines changed

src/components/index-page/what-is-graphql/wires.tsx

Lines changed: 33 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -15,33 +15,35 @@ import {
1515

1616
import QueryMdx from "./api-gateway-query.mdx"
1717
import clsx from "clsx"
18-
import { ComponentPropsWithoutRef } from "react"
18+
import { ComponentPropsWithoutRef, useReducer } from "react"
19+
20+
function ClientEdges({ pathHighlighted }: { pathHighlighted: number }) {
21+
const paths = [
22+
"M514.5 220H424.5V76H72",
23+
"M446 220H424.5V112H144",
24+
"M446 220H424.5V147H72",
25+
"M446 220H424.5V184H144",
26+
"M528 220H514.206L72 220",
27+
"M528 220L424.866 220V256H144",
28+
"M446 220L424.5 220V291.75H72",
29+
"M528.5 220H424.5V328H144",
30+
"M528 220H424.772V365H72",
31+
]
1932

20-
function ClientEdges() {
2133
return (
2234
<>
23-
<path
24-
d="M446 220L424.5 220V291.75H72"
25-
stroke="url(#paint4_linear_671_9150)"
26-
/>
27-
<path d="M446 220H424.5V147H72" stroke="url(#paint4_linear_671_9150)" />
28-
<path d="M528 220H514.206L72 220" stroke="url(#paint4_linear_671_9150)" />
29-
<path d="M528 220H424.772V365H72" stroke="url(#paint4_linear_671_9150)" />
30-
<path d="M446 220H424.5V112H144" stroke="url(#paint4_linear_671_9150)" />
31-
<path
32-
d="M528.5 220H424.5V328H144"
33-
stroke="url(#paint4_linear_671_9150)"
34-
/>
35-
<path d="M446 220H424.5V184H144" stroke="url(#paint4_linear_671_9150)" />
36-
<path
37-
d="M528 220L424.866 220V256H144"
38-
stroke="url(#paint4_linear_671_9150)"
39-
/>
40-
<path
41-
d="M514.5 220H424.5V76H72"
42-
stroke="url(#paint8_linear_671_9150)"
43-
stroke-width="2"
44-
/>
35+
{paths.map((path, index) => (
36+
<path
37+
key={index}
38+
d={path}
39+
stroke={
40+
pathHighlighted === index
41+
? `url(#paint_lr_dark_linear_671_9150)`
42+
: `url(#paint_lr_light_linear_671_9150)`
43+
}
44+
strokeWidth={pathHighlighted === index ? "2" : "1"}
45+
/>
46+
))}
4547
</>
4648
)
4749
}
@@ -195,7 +197,7 @@ function SVGDefinitions() {
195197
return (
196198
<defs>
197199
<linearGradient
198-
id="paint4_linear_671_9150"
200+
id="paint_lr_light_linear_671_9150"
199201
x1="446"
200202
y1="41.7739"
201203
x2="266.078"
@@ -206,7 +208,7 @@ function SVGDefinitions() {
206208
<stop offset="1" stopColor="#A0A88A" />
207209
</linearGradient>
208210
<linearGradient
209-
id="paint8_linear_671_9150"
211+
id="paint_lr_dark_linear_671_9150"
210212
x1="446"
211213
y1="-17.6347"
212214
x2="204.096"
@@ -337,12 +339,14 @@ const components = {
337339
}
338340

339341
export function Wires({ className }: { className?: string }) {
340-
// Step 1 in the demonstration:
341-
// Query visible, first client wire selected.
342+
// 1: Query visible, first client wire selected.
343+
const STEPS = 3
344+
const [step, inc] = useReducer(x => (x + 1) % STEPS, 0)
342345

343346
return (
344347
<div className={clsx(className, "relative")}>
345348
<svg
349+
id="what-is-graphql--wires"
346350
width="1248"
347351
height="448"
348352
viewBox="0 0 1248 448"
@@ -351,7 +355,7 @@ export function Wires({ className }: { className?: string }) {
351355
aria-label="GraphQL allows you to build API Gateways to bring data from multiple sources to your clients in a single query"
352356
className="relative h-auto w-full"
353357
>
354-
<ClientEdges />
358+
<ClientEdges pathHighlighted={step === 0 ? 0 : 0} />
355359
<ClientBoxes />
356360
<ServerEdges />
357361
<ServerBoxes />

0 commit comments

Comments
 (0)