diff --git a/scripts/check-wall.html b/scripts/check-wall.html new file mode 100644 index 0000000..b100b37 --- /dev/null +++ b/scripts/check-wall.html @@ -0,0 +1,156 @@ + + + + + + Wall behavior check + + + +
+

Wall behavior check

+
Running…
+ +
+ + + diff --git a/src/home/wall.tsx b/src/home/wall.tsx index fadf474..36d381a 100644 --- a/src/home/wall.tsx +++ b/src/home/wall.tsx @@ -25,6 +25,7 @@ import { import { Bar, BarChart, XAxis } from "recharts" import { cn } from "@/lib/utils" +import { useMediaQuery } from "@/hooks/use-media-query" import { AskCard } from "@/components/ui/ask-card" import { Avatar, AvatarFallback } from "@/components/ui/avatar" import { Badge } from "@/components/ui/badge" @@ -708,6 +709,10 @@ function Background() { * the home page it is cut off at a height and fades out; `full` shows all of it. */ export function Wall({ full = false }: { full?: boolean }) { + // Match the CSS breakpoints so hidden examples do not mount or run effects. + const showSecondColumn = useMediaQuery("(min-width: 48rem)") + const showThirdColumn = useMediaQuery("(min-width: 64rem)") + const showFourthColumn = useMediaQuery("(min-width: 1400px)") const column = "min-w-0 flex-col gap-(--gap)" return (
@@ -724,26 +729,32 @@ export function Wall({ full = false }: { full?: boolean }) {
-
- - - - -
-
- - - - - -
-
- - - - - -
+ {showSecondColumn && ( +
+ + + + +
+ )} + {showThirdColumn && ( +
+ + + + + +
+ )} + {showFourthColumn && ( +
+ + + + + +
+ )} {!full &&
}
diff --git a/src/hooks/use-media-query.ts b/src/hooks/use-media-query.ts index 889bc5c..7c70e3b 100644 --- a/src/hooks/use-media-query.ts +++ b/src/hooks/use-media-query.ts @@ -1,7 +1,8 @@ import * as React from "react" export function useMediaQuery(query: string) { - const [value, setValue] = React.useState(false) + // Match the first client render to the viewport instead of waiting for the effect. + const [value, setValue] = React.useState(() => typeof window !== "undefined" && window.matchMedia(query).matches) React.useEffect(() => { const result = matchMedia(query)