Skip to content

Commit d9945d8

Browse files
committed
Fix Safari
1 parent 67ca7c8 commit d9945d8

File tree

4 files changed

+38
-17
lines changed

4 files changed

+38
-17
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
"dependencies": {
2323
"@graphql-tools/schema": "10.0.23",
2424
"@headlessui/react": "^2.2.4",
25+
"@igorkowalczyk/is-browser": "^5.1.0",
2526
"@radix-ui/react-radio-group": "^1.2.2",
2627
"@tailwindcss/container-queries": "^0.1.1",
2728
"@tailwindcss/nesting": "0.0.0-insiders.565cd3e",

pnpm-lock.yaml

Lines changed: 13 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

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

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,7 @@ const components = {
470470
{...props}
471471
containerClassName="!absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2 max-sm:scale-75"
472472
// the border color on white and black backgrounds blends into border-neu-200 (and border-neu-50 in dark mode)
473-
className="overflow-hidden border-none !bg-transparent before:absolute before:inset-0 before:-z-10 before:rounded-md before:border before:border-transparent before:bg-[rgba(55,72,13,0.12)] before:bg-clip-border before:[backdrop-filter:url(#what-is-graphql--code-backdrop)] after:absolute after:inset-[1.5px] after:z-[-9] after:rounded-[5px] after:bg-[linear-gradient(to_right,transparent,hsl(var(--color-neu-0))_15%,hsl(var(--color-neu-0))_85%,transparent)] after:[backdrop-filter:url(#what-is-graphql--code-backdrop-2)] dark:before:border-[rgba(235,252,191,0.2)] dark:before:bg-none dark:before:backdrop-blur-xl dark:before:[backdrop-filter:url(#what-is-graphql--code-backdrop-2-dark)] dark:after:bg-[linear-gradient(to_right,hsl(var(--color-neu-0)/0.5),hsl(var(--color-neu-0)/.8)_10%,hsl(var(--color-neu-0)/.8)_83%,hsl(var(--color-neu-0)/0.4))] dark:after:[backdrop-filter:blur(24px)]"
473+
className="safari:after:[backdrop-filter:blur(12px)] overflow-hidden border-none !bg-transparent before:absolute before:inset-0 before:-z-10 before:rounded-md before:border before:border-transparent before:bg-[rgba(55,72,13,0.12)] before:bg-clip-border before:[backdrop-filter:url(#what-is-graphql--code-backdrop)] after:absolute after:inset-[1.5px] after:z-[-9] after:rounded-[5px] after:bg-[linear-gradient(to_right,transparent,hsl(var(--color-neu-0))_15%,hsl(var(--color-neu-0))_85%,transparent)] after:[backdrop-filter:url(#what-is-graphql--code-backdrop-2)] dark:before:border-[rgba(235,252,191,0.2)] dark:before:bg-none dark:before:backdrop-blur-xl dark:before:[backdrop-filter:url(#what-is-graphql--code-backdrop-2-dark)] dark:after:bg-[linear-gradient(to_right,hsl(var(--color-neu-0)/0.5),hsl(var(--color-neu-0)/.8)_10%,hsl(var(--color-neu-0)/.8)_83%,hsl(var(--color-neu-0)/0.4))] dark:after:[backdrop-filter:blur(24px)]"
474474
>
475475
{props.children}
476476
</Pre>
@@ -480,7 +480,7 @@ const components = {
480480

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

485485
const ref = useRef<SVGSVGElement>(null)
486486

@@ -497,9 +497,19 @@ export function Wires({ className }: { className?: string }) {
497497
}, [])
498498

499499
useEffect(() => {
500-
document.addEventListener("click", inc)
500+
const handleKeyDown = (e: KeyboardEvent) => {
501+
console.log(e.key)
502+
if (e.key === "x") {
503+
inc()
504+
}
505+
}
506+
507+
document.addEventListener("keydown", handleKeyDown)
508+
return () => document.removeEventListener("keydown", handleKeyDown)
501509
}, [])
502510

511+
console.log({ step })
512+
503513
return (
504514
<div className={clsx(className, "relative isolate", classes.wires)}>
505515
<svg
@@ -520,27 +530,22 @@ export function Wires({ className }: { className?: string }) {
520530
<SVGDefinitions />
521531
</svg>
522532
<div
523-
className={clsx(
524-
"absolute inset-0 transition duration-[5s]",
525-
classes.highlightsQuery,
526-
)}
527-
style={{
528-
transform: step < 2 ? "translateY(0)" : "translateY(-100%)",
529-
...(step === 1 && {
530-
"--highlight-opacity": 1,
531-
}),
532-
}}
533+
aria-hidden={step === 2}
534+
className={clsx("absolute inset-0 transition", classes.highlightsQuery)}
535+
style={
536+
{
537+
"--highlight-opacity": step === 1 ? 1 : 0,
538+
} as React.CSSProperties
539+
}
533540
>
534541
<QueryMdx components={components} />
535542
</div>
536543
<div
544+
aria-hidden={step !== 2}
537545
className={clsx(
538-
"absolute inset-0 transition duration-[5s] [&>pre]:bg-neu-0",
546+
"absolute inset-0 translate-y-full",
539547
classes.highlightsResponse,
540548
)}
541-
style={{
542-
transform: step === 2 ? "translateY(0)" : "translateY(100%)",
543-
}}
544549
>
545550
<ResponseMdx components={components} />
546551
</div>

tailwind.config.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import type { Config } from "tailwindcss"
33
import typography from "@tailwindcss/typography"
44
import plugin from "tailwindcss/plugin"
55
import containerQueries from "@tailwindcss/container-queries"
6+
import browserPlugin from "@igorkowalczyk/is-browser"
67

78
const config: Config = {
89
content: ["./src/**/*.{js,ts,jsx,tsx,mdx}", "./theme.config.tsx"],
@@ -200,6 +201,7 @@ const config: Config = {
200201
})
201202
}),
202203
tailwindMediaHover(),
204+
browserPlugin,
203205
],
204206
darkMode: ["class", 'html[class~="dark"]'],
205207
}

0 commit comments

Comments
 (0)