Skip to content

Commit 2ae8782

Browse files
committed
wip (transition between 2 and 3 still bad)
1 parent 353acab commit 2ae8782

File tree

3 files changed

+94
-20
lines changed

3 files changed

+94
-20
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
```json
2+
{
3+
"data": {
4+
"cities": [
5+
{
6+
"population": 8675309,
7+
"weather": {
8+
"temperature": 22.5,
9+
"precipitation": 1.2
10+
}
11+
}
12+
]
13+
}
14+
}
15+
```

src/components/index-page/what-is-graphql/wires.module.css

Lines changed: 46 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,34 @@
88
}
99
}
1010

11-
.highlightsQuery {
11+
.highlightsQuery,
12+
.highlightsResponse {
1213
& pre > code:global(.nextra-code) > span {
13-
transition: background-color 1s ease-out;
14+
position: relative;
15+
16+
&::before {
17+
transition: opacity 1s ease-out;
18+
}
19+
}
20+
}
21+
22+
.highlightsQuery {
23+
& pre > code:global(.nextra-code) > span::before {
24+
position: absolute;
25+
inset: 0;
26+
content: "";
27+
transition: opacity 1s ease-out;
1428
transition-delay: 1s;
29+
opacity: var(--highlight-opacity, 0);
1530

1631
&:nth-child(2),
1732
&:nth-child(3) {
1833
@apply bg-pri-lighter/20 dark:bg-pri-light/5;
1934
}
2035
&:nth-child(4) {
21-
@apply bg-gradient-to-b from-pri-lighter/20 to-sec-lighter/20 dark:from-pri-light/5 dark:to-sec-light/5;
36+
@apply bg-gradient-to-b from-pri-lighter/20 to-sec-light/20 dark:from-pri-light/5 dark:to-sec-light/5;
2237
background-image: linear-gradient(
23-
to bottom in oklab,
38+
to bottom in oklch,
2439
var(--tw-gradient-stops)
2540
);
2641
}
@@ -30,3 +45,30 @@
3045
}
3146
}
3247
}
48+
49+
.highlightsResponse {
50+
& pre > code:global(.nextra-code) > span::before {
51+
position: absolute;
52+
inset: 0;
53+
content: "";
54+
transition-delay: 1s;
55+
56+
&:nth-child(3),
57+
&:nth-child(4),
58+
&:nth-child(5) {
59+
@apply bg-pri-lighter/20 dark:bg-pri-light/5;
60+
}
61+
&:nth-child(6) {
62+
@apply bg-gradient-to-b from-pri-lighter/20 to-sec-lighter/20 dark:from-pri-light/5 dark:to-sec-light/5;
63+
background-image: linear-gradient(
64+
to bottom in oklch,
65+
var(--tw-gradient-stops)
66+
);
67+
}
68+
&:nth-child(7),
69+
&:nth-child(8),
70+
&:nth-child(9) {
71+
@apply bg-sec-lighter/20 dark:bg-sec-light/5;
72+
}
73+
}
74+
}

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

Lines changed: 33 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import {
2323
ServerIcon,
2424
} from "./icons"
2525
import QueryMdx from "./api-gateway-query.mdx"
26+
import ResponseMdx from "./api-gateway-response.mdx"
2627
import classes from "./wires.module.css"
2728

2829
function ClientEdges({
@@ -478,8 +479,8 @@ const components = {
478479
}
479480

480481
export function Wires({ className }: { className?: string }) {
481-
const STEPS = 2
482-
const [step, inc] = useReducer(x => (x + 1) % STEPS, 0)
482+
const STEPS = 3
483+
const [step, inc] = useReducer(x => (x + 1) % STEPS, 2)
483484

484485
const ref = useRef<SVGSVGElement>(null)
485486

@@ -495,18 +496,8 @@ export function Wires({ className }: { className?: string }) {
495496
return () => animate?.removeEventListener("repeatEvent", inc)
496497
}, [])
497498

498-
// todo: highlight the lines in step 3
499-
500499
return (
501-
<div
502-
className={clsx(
503-
className,
504-
"relative isolate",
505-
classes.wires,
506-
step === 1 && classes.highlightsQuery,
507-
step === 2 && classes.highlightsResponse,
508-
)}
509-
>
500+
<div className={clsx(className, "relative isolate", classes.wires)}>
510501
<svg
511502
id="what-is-graphql--wires"
512503
width="1248"
@@ -520,11 +511,37 @@ export function Wires({ className }: { className?: string }) {
520511
>
521512
<ClientEdges highlightedEdge={0} highlightedVisible={step === 0} />
522513
<ClientBoxes highlighted={step === 0 ? 0 : undefined} />
523-
<ServerEdges highlighted={[1, 6]} highlightedVisible={step === 1} />
524-
<ServerBoxes highlighted={step === 1 ? [1, 6] : []} />
514+
<ServerEdges highlighted={[1, 6]} highlightedVisible={step > 0} />
515+
<ServerBoxes highlighted={step > 0 ? [1, 6] : []} />
525516
<SVGDefinitions />
526517
</svg>
527-
<QueryMdx components={components} />
518+
<div
519+
className={clsx(
520+
"absolute inset-0 transition-opacity",
521+
classes.highlightsQuery,
522+
)}
523+
style={{
524+
opacity: step < 2 ? 1 : 0,
525+
transitionDelay: step < 2 ? "0s" : "0.5s",
526+
...(step === 1 && {
527+
"--highlight-opacity": 1,
528+
}),
529+
}}
530+
>
531+
<QueryMdx components={components} />
532+
</div>
533+
<div
534+
className={clsx(
535+
"absolute inset-0 transition-opacity [&>pre]:bg-neu-0",
536+
classes.highlightsResponse,
537+
)}
538+
style={{
539+
opacity: step === 2 ? 1 : 0,
540+
transitionDelay: step === 2 ? "0s" : "0.5s",
541+
}}
542+
>
543+
<ResponseMdx components={components} />
544+
</div>
528545
</div>
529546
)
530547
}

0 commit comments

Comments
 (0)