@@ -15,33 +15,35 @@ import {
15
15
16
16
import QueryMdx from "./api-gateway-query.mdx"
17
17
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
+ ]
19
32
20
- function ClientEdges ( ) {
21
33
return (
22
34
< >
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
+ ) ) }
45
47
</ >
46
48
)
47
49
}
@@ -195,7 +197,7 @@ function SVGDefinitions() {
195
197
return (
196
198
< defs >
197
199
< linearGradient
198
- id = "paint4_linear_671_9150 "
200
+ id = "paint_lr_light_linear_671_9150 "
199
201
x1 = "446"
200
202
y1 = "41.7739"
201
203
x2 = "266.078"
@@ -206,7 +208,7 @@ function SVGDefinitions() {
206
208
< stop offset = "1" stopColor = "#A0A88A" />
207
209
</ linearGradient >
208
210
< linearGradient
209
- id = "paint8_linear_671_9150 "
211
+ id = "paint_lr_dark_linear_671_9150 "
210
212
x1 = "446"
211
213
y1 = "-17.6347"
212
214
x2 = "204.096"
@@ -337,12 +339,14 @@ const components = {
337
339
}
338
340
339
341
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 )
342
345
343
346
return (
344
347
< div className = { clsx ( className , "relative" ) } >
345
348
< svg
349
+ id = "what-is-graphql--wires"
346
350
width = "1248"
347
351
height = "448"
348
352
viewBox = "0 0 1248 448"
@@ -351,7 +355,7 @@ export function Wires({ className }: { className?: string }) {
351
355
aria-label = "GraphQL allows you to build API Gateways to bring data from multiple sources to your clients in a single query"
352
356
className = "relative h-auto w-full"
353
357
>
354
- < ClientEdges />
358
+ < ClientEdges pathHighlighted = { step === 0 ? 0 : 0 } />
355
359
< ClientBoxes />
356
360
< ServerEdges />
357
361
< ServerBoxes />
0 commit comments