@@ -17,7 +17,11 @@ import QueryMdx from "./api-gateway-query.mdx"
1717import clsx from "clsx"
1818import { ComponentPropsWithoutRef , useReducer } from "react"
1919
20- function ClientEdges ( { pathHighlighted } : { pathHighlighted : number } ) {
20+ function ClientEdges ( {
21+ highlighted : pathHighlighted ,
22+ } : {
23+ highlighted ?: number
24+ } ) {
2125 const paths = [
2226 "M514.5 220H424.5V76H72" ,
2327 "M446 220H424.5V112H144" ,
@@ -92,60 +96,65 @@ function Box({
9296 transform,
9397 fill = "hsl(var(--color-neu-100))" ,
9498 children,
99+ className,
95100} : {
96101 transform : string
97102 fill ?: string
98103 children : React . ReactNode
104+ className ?: string
99105} ) {
100106 return (
101107 < g
102108 transform = { transform }
103- className = "[&>path]:translate-x-4 [&>path]:translate-y-4 [:where(&>path:not([fill]))]:fill-neu-600"
109+ className = { clsx (
110+ "[&>path]:translate-x-4 [&>path]:translate-y-4 [:where(&>path:not([fill]))]:fill-neu-600" ,
111+ className ,
112+ ) }
104113 >
105114 < rect width = "56" height = "56" fill = { fill } />
106115 { children }
107116 </ g >
108117 )
109118}
110119
111- function ClientBoxes ( ) {
120+ function ClientBoxes ( { highlighted } : { highlighted ?: number } ) {
121+ /* eslint-disable react/jsx-key */
122+ const boxes = [
123+ [ "translate(16, 48)" , < DesktopIcon /> ] ,
124+ [ "translate(88, 84)" , < PhoneIcon /> ] ,
125+ [ "translate(16, 120)" , < PhoneIcon /> ] ,
126+ [ "translate(88, 156)" , < WristwatchIcon /> ] ,
127+ [ "translate(16, 192)" , < TelevisionIcon /> ] ,
128+ [ "translate(88, 228)" , < DesktopIcon /> ] ,
129+ [ "translate(16, 264)" , < TabletIcon /> ] ,
130+ [ "translate(88, 300)" , < PhoneIcon /> ] ,
131+ [ "translate(16, 336)" , < WristwatchIcon /> ] ,
132+ ] as const
133+ /* eslint-enable react/jsx-key */
134+
112135 return (
113136 < >
114- < Box transform = "translate(16, 48)" fill = "hsl(var(--color-neu-300))" >
115- < DesktopIcon className = "fill-neu-800 dark:fill-neu-0" />
116- </ Box >
117-
118- < Box transform = "translate(88, 84)" >
119- < PhoneIcon />
120- </ Box >
121-
122- < Box transform = "translate(16, 120)" >
123- < PhoneIcon />
124- </ Box >
125-
126- < Box transform = "translate(88, 156)" >
127- < WristwatchIcon />
128- </ Box >
129-
130- < Box transform = "translate(16, 192)" >
131- < TelevisionIcon />
132- </ Box >
133-
134- < Box transform = "translate(88, 228)" >
135- < DesktopIcon />
136- </ Box >
137-
138- < Box transform = "translate(16, 264)" >
139- < TabletIcon />
140- </ Box >
141-
142- < Box transform = "translate(88, 300)" >
143- < PhoneIcon />
144- </ Box >
145-
146- < Box transform = "translate(16, 336)" >
147- < WristwatchIcon />
148- </ Box >
137+ { boxes . map ( ( [ transform , children ] , index ) => {
138+ const isHighlighted = index === highlighted
139+ return (
140+ < Box
141+ key = { index }
142+ transform = { transform }
143+ fill = {
144+ isHighlighted
145+ ? "hsl(var(--color-neu-300))"
146+ : "hsl(var(--color-neu-100))"
147+ }
148+ className = {
149+ isHighlighted
150+ ? "[&_path]:fill-neu-800 dark:[&_path]:fill-neu-0"
151+ : undefined
152+ }
153+ >
154+ { children }
155+ </ Box >
156+ )
157+ } ) }
149158 </ >
150159 )
151160}
@@ -341,7 +350,7 @@ const components = {
341350export function Wires ( { className } : { className ?: string } ) {
342351 // 1: Query visible, first client wire selected.
343352 const STEPS = 3
344- const [ step , inc ] = useReducer ( x => ( x + 1 ) % STEPS , 0 )
353+ const [ step , inc ] = useReducer ( x => ( x + 1 ) % STEPS , 1 )
345354
346355 return (
347356 < div className = { clsx ( className , "relative" ) } >
@@ -355,13 +364,13 @@ export function Wires({ className }: { className?: string }) {
355364 aria-label = "GraphQL allows you to build API Gateways to bring data from multiple sources to your clients in a single query"
356365 className = "relative h-auto w-full"
357366 >
358- < ClientEdges pathHighlighted = { step === 0 ? 0 : 0 } />
359- < ClientBoxes />
367+ < ClientEdges highlighted = { step === 0 ? 0 : undefined } />
368+ < ClientBoxes highlighted = { step === 0 ? 0 : undefined } />
360369 < ServerEdges />
361370 < ServerBoxes />
362371 < SVGDefinitions />
363372 </ svg >
364- { /* <QueryMdx components={components} /> */ }
373+ < QueryMdx components = { components } />
365374 </ div >
366375 )
367376}
0 commit comments