Skip to content

Commit a82b544

Browse files
committed
Make diagram boxes and edges responsive
1 parent 356981f commit a82b544

File tree

1 file changed

+138
-4
lines changed
  • src/components/index-page/what-is-graphql

1 file changed

+138
-4
lines changed

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

Lines changed: 138 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -141,11 +141,11 @@ function Box({
141141
<g
142142
transform={transform}
143143
className={clsx(
144-
"fill-neu-100 [&>path]:translate-x-4 [&>path]:translate-y-4 [:where(&>path:not([fill]))]:fill-neu-600",
144+
"fill-neu-100 [&>path]:translate-x-3 [&>path]:translate-y-3 sm:[&>path]:translate-x-4 sm:[&>path]:translate-y-4 [:where(&>path:not([fill]))]:fill-neu-600",
145145
className,
146146
)}
147147
>
148-
<rect width="56" height="56" />
148+
<rect className="size-[48px] sm:size-[56px]" />
149149
{children}
150150
</g>
151151
)
@@ -545,7 +545,7 @@ export function Wires({ className }: { className?: string }) {
545545
fill="none"
546546
xmlns="http://www.w3.org/2000/svg"
547547
aria-label="GraphQL allows you to build API Gateways to bring data from multiple sources to your clients in a single query"
548-
className="relative h-auto w-full"
548+
className="relative h-auto w-full max-sm:hidden"
549549
ref={ref}
550550
>
551551
<ClientEdges
@@ -634,6 +634,140 @@ function Curtain() {
634634
)
635635
}
636636

637+
// Mobile diagram data
638+
/* eslint-disable react/jsx-key */
639+
const mobileClientBoxes: Array<[string, React.ReactNode]> = [
640+
["translate(0, 0)", <DesktopIcon />],
641+
["translate(65, 0)", <PhoneIcon />],
642+
["translate(130, 0)", <PhoneIcon />],
643+
["translate(195, 0)", <WristwatchIcon />],
644+
["translate(260, 0)", <TelevisionIcon />],
645+
]
646+
647+
const mobileServerBoxes: Array<[string, React.ReactNode]> = [
648+
["translate(2, 454)", <LabirynthIcon />],
649+
["translate(67, 454)", <ServerIcon />],
650+
["translate(132, 454)", <ModemIcon />],
651+
["translate(197, 454)", <CloudIcon />],
652+
["translate(262, 454)", <CloudIcon />],
653+
]
654+
/* eslint-enable react/jsx-key */
655+
656+
function MobileClientEdges() {
657+
return (
658+
<>
659+
<path
660+
d="M154 157L154 85L219 85L219 48"
661+
stroke="url(#smallscreen_linear1)"
662+
/>
663+
<path
664+
d="M154 157L154 84.9209L88 84.9209L88 48"
665+
stroke="url(#smallscreen_linear1)"
666+
/>
667+
<path
668+
d="M154 107.855L154 157L155 48"
669+
stroke="url(#smallscreen_linear1)"
670+
/>
671+
<path
672+
d="M154 157L154.002 85L284 85L284 48"
673+
stroke="url(#smallscreen_linear1)"
674+
/>
675+
<path
676+
d="M154 158L154 136.031L154 85L24 84.8443L24 48"
677+
stroke="url(#smallscreen_linear1)"
678+
strokeWidth="2"
679+
/>
680+
</>
681+
)
682+
}
683+
684+
function MobileServerEdges() {
685+
return (
686+
<>
687+
<path
688+
d="M130.094 344L130.094 426L91.6745 426L91.6745 454"
689+
stroke="url(#smallscrean_linear2)"
690+
/>
691+
<path
692+
d="M156.002 344L156.002 345.948L156.002 454"
693+
stroke="url(#smallscrean_linear2)"
694+
/>
695+
<path
696+
d="M101.504 344L101.504 398.5L26.0075 398.5L26.0075 454"
697+
stroke="url(#smallscrean_linear2)"
698+
/>
699+
<path
700+
d="M181.918 344L181.916 426L220.335 426L220.337 454"
701+
stroke="url(#smallscrean_linear2)"
702+
/>
703+
<path
704+
d="M210.512 344L210.512 398L286.008 398L286.008 454"
705+
stroke="url(#smallscrean_linear2)"
706+
/>
707+
</>
708+
)
709+
}
710+
711+
function MobileSVGDefinitions() {
712+
return (
713+
<defs>
714+
<linearGradient
715+
id="smallscreen_linear1"
716+
x1="0.142323"
717+
y1="124.751"
718+
x2="0.142321"
719+
y2="-122.582"
720+
gradientUnits="userSpaceOnUse"
721+
>
722+
<stop
723+
stopColor="hsl(var(--color-neu-100))"
724+
className="dark:[stop-color:hsl(var(--color-neu-50))]"
725+
/>
726+
<stop
727+
offset="1"
728+
stopColor="hsl(var(--color-neu-600))"
729+
className="dark:[stop-color:hsl(var(--color-neu-100))]"
730+
/>
731+
</linearGradient>
732+
<linearGradient
733+
id="smallscrean_linear2"
734+
x1="66.6927"
735+
y1="344"
736+
x2="66.6927"
737+
y2="399.436"
738+
gradientUnits="userSpaceOnUse"
739+
>
740+
<stop
741+
stopColor="hsl(var(--color-neu-100))"
742+
className="dark:[stop-color:hsl(var(--color-neu-50))]"
743+
/>
744+
<stop
745+
offset="1"
746+
stopColor="hsl(var(--color-neu-600))"
747+
className="dark:[stop-color:hsl(var(--color-neu-100))]"
748+
/>
749+
</linearGradient>
750+
</defs>
751+
)
752+
}
753+
637754
function MobileDiagram() {
638-
return <svg>{/* HERE */}</svg>
755+
return (
756+
<svg
757+
width="310"
758+
height="502"
759+
viewBox="0 0 310 502"
760+
fill="none"
761+
preserveAspectRatio="xMidYMid"
762+
xmlns="http://www.w3.org/2000/svg"
763+
className="mx-auto sm:hidden"
764+
aria-label="GraphQL allows you to build API Gateways to bring data from multiple sources to your clients in a single query"
765+
>
766+
<MobileClientEdges />
767+
<ClientBoxes boxes={mobileClientBoxes} />
768+
<MobileServerEdges />
769+
<ServerBoxes highlighted={[]} boxes={mobileServerBoxes} />
770+
<MobileSVGDefinitions />
771+
</svg>
772+
)
639773
}

0 commit comments

Comments
 (0)