From 356981f5c4a84565a951c060b3049e596ecf87ee Mon Sep 17 00:00:00 2001 From: Piotr Monwid-Olechnowicz Date: Thu, 14 Aug 2025 20:32:34 +0200 Subject: [PATCH 1/7] Extract edges and boxes out from the components. --- .../index-page/data-colocation/index.tsx | 4 +- .../index-page/what-is-graphql/wires.tsx | 153 +++++++++++------- 2 files changed, 96 insertions(+), 61 deletions(-) diff --git a/src/components/index-page/data-colocation/index.tsx b/src/components/index-page/data-colocation/index.tsx index 90514228d9..1f54f51de2 100644 --- a/src/components/index-page/data-colocation/index.tsx +++ b/src/components/index-page/data-colocation/index.tsx @@ -11,6 +11,8 @@ import { import { Pre } from "@/components/pre" import { SectionLabel } from "@/app/conf/_design-system/section-label" import InfoIcon from "@/app/conf/_design-system/pixelarticons/info.svg?svgr" +import { useOnClickOutside } from "@/app/conf/_design-system/utils/useOnClickOutside" +import { isSpanElement } from "@/app/conf/_design-system/utils/isSpanElement" import { ComponentTree } from "./component-tree" import { FriendList } from "./friend-list" @@ -18,8 +20,6 @@ import { FriendList } from "./friend-list" import json from "./data-colocation.json" import Query from "./data-colocation.mdx" import "./data-colocation.css" -import { useOnClickOutside } from "@/app/conf/_design-system/utils/useOnClickOutside" -import { isSpanElement } from "@/app/conf/_design-system/utils/isSpanElement" const highlightedFragments = { GetFriendList: 1, diff --git a/src/components/index-page/what-is-graphql/wires.tsx b/src/components/index-page/what-is-graphql/wires.tsx index ff17025579..f895ab90de 100644 --- a/src/components/index-page/what-is-graphql/wires.tsx +++ b/src/components/index-page/what-is-graphql/wires.tsx @@ -8,6 +8,7 @@ import { useReducer, useRef, } from "react" +import { throttle } from "@/app/conf/_design-system/utils/throttle" import { Code } from "nextra/components" @@ -27,32 +28,33 @@ import { import QueryMdx from "./api-gateway-query.mdx" import ResponseMdx from "./api-gateway-response.mdx" import styles from "./wires.module.css" -import { throttle } from "@/app/conf/_design-system/utils/throttle" + +const bigScreenClientEdges = [ + "M514.5 220H424.5V76H72", + "M446 220H424.5V112H144", + "M446 220H424.5V147H72", + "M446 220H424.5V184H144", + "M528 220H514.206L72 220", + "M528 220L424.866 220V256H144", + "M446 220L424.5 220V291.75H72", + "M528.5 220H424.5V328H144", + "M528 220H424.772V365H72", +] function ClientEdges({ highlightedEdge, highlightedVisible, + edges, }: { highlightedEdge?: number highlightedVisible: boolean + edges: string[] }) { - const paths = [ - "M514.5 220H424.5V76H72", - "M446 220H424.5V112H144", - "M446 220H424.5V147H72", - "M446 220H424.5V184H144", - "M528 220H514.206L72 220", - "M528 220L424.866 220V256H144", - "M446 220L424.5 220V291.75H72", - "M528.5 220H424.5V328H144", - "M528 220H424.772V365H72", - ] - return ( <> {moveHighlightedToTop( highlightedEdge, - paths.map((path, index) => ( + edges.map((path, index) => ( - {paths.map((d, index) => { + {edges.map((d, index) => { const isHighlighted = highlighted?.includes(index) return ( @@ -147,21 +151,27 @@ function Box({ ) } -function ClientBoxes({ highlighted }: { highlighted?: number }) { - /* eslint-disable react/jsx-key */ - const boxes = [ - ["translate(16, 48)", ], - ["translate(88, 84)", ], - ["translate(16, 120)", ], - ["translate(88, 156)", ], - ["translate(16, 192)", ], - ["translate(88, 228)", ], - ["translate(16, 264)", ], - ["translate(88, 300)", ], - ["translate(16, 336)", ], - ] as const - /* eslint-enable react/jsx-key */ +/* eslint-disable react/jsx-key */ +const bigScreenClientBoxes: Array<[string, React.ReactNode]> = [ + ["translate(16, 48)", ], + ["translate(88, 84)", ], + ["translate(16, 120)", ], + ["translate(88, 156)", ], + ["translate(16, 192)", ], + ["translate(88, 228)", ], + ["translate(16, 264)", ], + ["translate(88, 300)", ], + ["translate(16, 336)", ], +] +/* eslint-enable react/jsx-key */ +function ClientBoxes({ + highlighted, + boxes, +}: { + highlighted?: number + boxes: Array<[string, React.ReactNode]> +}) { return ( <> {boxes.map(([transform, children], index) => { @@ -184,21 +194,27 @@ function ClientBoxes({ highlighted }: { highlighted?: number }) { ) } -function ServerBoxes({ highlighted }: { highlighted: number[] }) { - /* eslint-disable react/jsx-key */ - const boxes = [ - ["translate(1176, 48)", ], - ["translate(1104, 84)", ], - ["translate(1176, 120)", ], - ["translate(1104, 156)", ], - ["translate(1176, 192)", ], - ["translate(1104, 228)", ], - ["translate(1176, 264)", ], - ["translate(1104, 300)", ], - ["translate(1176, 336)", ], - ] as const - /* eslint-enable react/jsx-key */ +/* eslint-disable react/jsx-key */ +const bigScreenServerBoxes: Array<[string, React.ReactNode]> = [ + ["translate(1176, 48)", ], + ["translate(1104, 84)", ], + ["translate(1176, 120)", ], + ["translate(1104, 156)", ], + ["translate(1176, 192)", ], + ["translate(1104, 228)", ], + ["translate(1176, 264)", ], + ["translate(1104, 300)", ], + ["translate(1176, 336)", ], +] +/* eslint-enable react/jsx-key */ +function ServerBoxes({ + highlighted, + boxes, +}: { + highlighted: number[] + boxes: Array<[string, React.ReactNode]> +}) { return ( <> {boxes.map(([transform, children], index) => { @@ -520,6 +536,7 @@ export function Wires({ className }: { className?: string }) { styles.wires, )} > + - - - 0} /> - 0 ? [1, 6] : []} /> + + + 0} + edges={bigScreenServerEdges} + /> + 0 ? [1, 6] : []} + boxes={bigScreenServerBoxes} + />