From 8e0b2e05cef15c5126d25976f5ceee3d77a6b57f Mon Sep 17 00:00:00 2001 From: admirsaheta Date: Sat, 27 Dec 2025 01:47:35 +0100 Subject: [PATCH 1/6] fix:re-render(brand-compliance-component) --- .../feature-blocks/brand-compliance.tsx | 451 +++++++++++++----- 1 file changed, 319 insertions(+), 132 deletions(-) diff --git a/apps/web/client/src/app/_components/landing-page/feature-blocks/brand-compliance.tsx b/apps/web/client/src/app/_components/landing-page/feature-blocks/brand-compliance.tsx index b79a8fa717..dc7616fec7 100644 --- a/apps/web/client/src/app/_components/landing-page/feature-blocks/brand-compliance.tsx +++ b/apps/web/client/src/app/_components/landing-page/feature-blocks/brand-compliance.tsx @@ -1,145 +1,332 @@ -import { Icons } from '@onlook/ui/icons'; -import { ColorSwatchGroup } from '../color-swatch-group'; -import React, { useRef, useState, useCallback, useEffect } from 'react'; +"use client"; -function ParallaxContainer({ children, speed = 0.1 }: { children: React.ReactNode, speed?: number }) { - const containerRef = useRef(null); - const [transform, setTransform] = useState(0); - const ticking = useRef(false); +import React, { useRef } from "react"; +import { motion, useScroll, useSpring, useTransform } from "motion/react"; - const updateTransform = useCallback(() => { - if (!containerRef.current) return; - - const rect = containerRef.current.getBoundingClientRect(); - const viewportHeight = window.innerHeight; - - // Calculate how far the element is from the center of the viewport - const distanceFromCenter = rect.top + rect.height / 2 - viewportHeight / 2; - - // Apply transform based on distance from center - setTransform(distanceFromCenter * speed); - - ticking.current = false; - }, [speed]); +import { Icons } from "@onlook/ui/icons"; - useEffect(() => { - const handleScroll = () => { - if (!ticking.current) { - window.requestAnimationFrame(() => { - updateTransform(); - }); - ticking.current = true; - } - }; +import { ColorSwatchGroup } from "../color-swatch-group"; - // Use passive scroll listener for better performance - window.addEventListener('scroll', handleScroll, { passive: true }); - updateTransform(); // Initial calculation +interface ParallaxContainerProps { + children: React.ReactNode; + speed?: number; + className?: string; +} - return () => window.removeEventListener('scroll', handleScroll); - }, [updateTransform]); +function ParallaxContainer({ + children, + speed = 0.1, + className, +}: ParallaxContainerProps) { + const containerRef = useRef(null); - return ( -
- {children} -
- ); + const { scrollYProgress } = useScroll({ + target: containerRef, + offset: ["start end", "end start"], + }); + + // Map scroll progress (0 to 1) to transform values + // When scroll is 0 (element entering from bottom), we want positive offset (pushed down) + // When scroll is 1 (element exiting at top), we want negative offset (pulled up) + // The multiplier 2000 is an approximation of the viewport height + element height range to match previous 'distanceFromCenter' logic roughly + const yRange = useTransform( + scrollYProgress, + [0, 1], + [500 * speed, -500 * speed] + ); + + const y = useSpring(yRange, { + stiffness: 100, + damping: 30, + mass: 0.1, + }); + + return ( +
+ + {children} + +
+ ); } export function BrandComplianceBlock() { - return ( -
-
- -
-

Brand Colors

-
- - - - - + return ( +
+
+ +
+

+ Brand Colors +

+
+ + + + + - - -
-
-
- -
-

Brand Colors

-
- - - - - - - -
-
-
+ +
-
- {/* Icon + Title */} -
-
- Brand compliance -
- {/* Description */} -

Make your fonts, colors, and styles all speak the same language.

+
+ + +
+

+ Brand Colors +

+
+ + + + + + +
+
+
+
+
+ {/* Icon + Title */} +
+
+ +
+ + Brand compliance +
- ); -} \ No newline at end of file + {/* Description */} +

+ Make your fonts, colors, and styles all speak the same language. +

+
+
+ ); +} From e88dab72e07910ed2ed1da1b87a9146fbbfed693 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Admir=20=C5=A0aheta?= <81534875+admirsaheta@users.noreply.github.com> Date: Sat, 27 Dec 2025 22:30:16 +0100 Subject: [PATCH 2/6] Update apps/web/client/src/app/_components/landing-page/feature-blocks/brand-compliance.tsx Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com> --- .../landing-page/feature-blocks/brand-compliance.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/web/client/src/app/_components/landing-page/feature-blocks/brand-compliance.tsx b/apps/web/client/src/app/_components/landing-page/feature-blocks/brand-compliance.tsx index dc7616fec7..68a3ca99e1 100644 --- a/apps/web/client/src/app/_components/landing-page/feature-blocks/brand-compliance.tsx +++ b/apps/web/client/src/app/_components/landing-page/feature-blocks/brand-compliance.tsx @@ -28,7 +28,7 @@ function ParallaxContainer({ // Map scroll progress (0 to 1) to transform values // When scroll is 0 (element entering from bottom), we want positive offset (pushed down) // When scroll is 1 (element exiting at top), we want negative offset (pulled up) - // The multiplier 2000 is an approximation of the viewport height + element height range to match previous 'distanceFromCenter' logic roughly + // The multiplier 500 is an approximation of the viewport height + element height range to match previous 'distanceFromCenter' logic roughly const yRange = useTransform( scrollYProgress, [0, 1], From 49653b8b027022cf9edace623b425841870a14d5 Mon Sep 17 00:00:00 2001 From: admirsaheta Date: Sun, 28 Dec 2025 14:38:02 +0100 Subject: [PATCH 3/6] coderabbit:suggestions(fixes) --- .../feature-blocks/brand-compliance.tsx | 50 ++++++++----------- 1 file changed, 20 insertions(+), 30 deletions(-) diff --git a/apps/web/client/src/app/_components/landing-page/feature-blocks/brand-compliance.tsx b/apps/web/client/src/app/_components/landing-page/feature-blocks/brand-compliance.tsx index 68a3ca99e1..76f57fe2ee 100644 --- a/apps/web/client/src/app/_components/landing-page/feature-blocks/brand-compliance.tsx +++ b/apps/web/client/src/app/_components/landing-page/feature-blocks/brand-compliance.tsx @@ -19,6 +19,10 @@ function ParallaxContainer({ className, }: ParallaxContainerProps) { const containerRef = useRef(null); + const prefersReducedMotion = + typeof window !== "undefined" + ? window.matchMedia("(prefers-reduced-motion: reduce)").matches + : false; const { scrollYProgress } = useScroll({ target: containerRef, @@ -28,11 +32,11 @@ function ParallaxContainer({ // Map scroll progress (0 to 1) to transform values // When scroll is 0 (element entering from bottom), we want positive offset (pushed down) // When scroll is 1 (element exiting at top), we want negative offset (pulled up) - // The multiplier 500 is an approximation of the viewport height + element height range to match previous 'distanceFromCenter' logic roughly + // The multiplier 2000 is an approximation of the viewport height + element height range to match previous 'distanceFromCenter' logic roughly const yRange = useTransform( scrollYProgress, [0, 1], - [500 * speed, -500 * speed] + prefersReducedMotion ? [0, 0] : [500 * speed, -500 * speed] ); const y = useSpring(yRange, { @@ -69,12 +73,11 @@ export function BrandComplianceBlock() { "bg-slate-300", "bg-slate-400", "bg-slate-500", - "bg-slate-500", "bg-slate-600", "bg-slate-700", "bg-slate-800", "bg-slate-900", - "bg-slate-900", + "bg-slate-950", ]} /> @@ -155,12 +154,11 @@ export function BrandComplianceBlock() { "bg-lime-300", "bg-lime-400", "bg-lime-500", - "bg-lime-500", "bg-lime-600", "bg-lime-700", "bg-lime-800", "bg-lime-900", - "bg-lime-900", + "bg-lime-950", ]} />
@@ -198,12 +195,11 @@ export function BrandComplianceBlock() { "bg-cyan-300", "bg-cyan-400", "bg-cyan-500", - "bg-cyan-500", "bg-cyan-600", "bg-cyan-700", "bg-cyan-800", "bg-cyan-900", - "bg-cyan-900", + "bg-cyan-950", ]} />
From 414556dc3c882203107d1a7f9840ff53466ac21a Mon Sep 17 00:00:00 2001 From: admirsaheta Date: Sun, 28 Dec 2025 14:42:40 +0100 Subject: [PATCH 4/6] coderabbit:suggestions(fixes) --- .../landing-page/feature-blocks/brand-compliance.tsx | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/apps/web/client/src/app/_components/landing-page/feature-blocks/brand-compliance.tsx b/apps/web/client/src/app/_components/landing-page/feature-blocks/brand-compliance.tsx index 76f57fe2ee..5ee5c4ca12 100644 --- a/apps/web/client/src/app/_components/landing-page/feature-blocks/brand-compliance.tsx +++ b/apps/web/client/src/app/_components/landing-page/feature-blocks/brand-compliance.tsx @@ -1,7 +1,7 @@ "use client"; import React, { useRef } from "react"; -import { motion, useScroll, useSpring, useTransform } from "motion/react"; +import { motion, useReducedMotion, useScroll, useSpring, useTransform } from "motion/react"; import { Icons } from "@onlook/ui/icons"; @@ -19,10 +19,7 @@ function ParallaxContainer({ className, }: ParallaxContainerProps) { const containerRef = useRef(null); - const prefersReducedMotion = - typeof window !== "undefined" - ? window.matchMedia("(prefers-reduced-motion: reduce)").matches - : false; + const prefersReducedMotion = useReducedMotion(); const { scrollYProgress } = useScroll({ target: containerRef, From 0ed061385d172503c7682f9f2bff9d64fa0f0610 Mon Sep 17 00:00:00 2001 From: admirsaheta Date: Tue, 30 Dec 2025 23:13:17 +0100 Subject: [PATCH 5/6] fix:coderabbit(comment) --- .../landing-page/feature-blocks/brand-compliance.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/web/client/src/app/_components/landing-page/feature-blocks/brand-compliance.tsx b/apps/web/client/src/app/_components/landing-page/feature-blocks/brand-compliance.tsx index 5ee5c4ca12..037e1d6dca 100644 --- a/apps/web/client/src/app/_components/landing-page/feature-blocks/brand-compliance.tsx +++ b/apps/web/client/src/app/_components/landing-page/feature-blocks/brand-compliance.tsx @@ -29,7 +29,7 @@ function ParallaxContainer({ // Map scroll progress (0 to 1) to transform values // When scroll is 0 (element entering from bottom), we want positive offset (pushed down) // When scroll is 1 (element exiting at top), we want negative offset (pulled up) - // The multiplier 2000 is an approximation of the viewport height + element height range to match previous 'distanceFromCenter' logic roughly + // The multiplier is an approximation of the viewport height + element height range to match previous 'distanceFromCenter' logic roughly const yRange = useTransform( scrollYProgress, [0, 1], From 4b9ca4e5aabc6a442ec81caebad38c4cf1004ed2 Mon Sep 17 00:00:00 2001 From: admirsaheta Date: Tue, 30 Dec 2025 23:24:03 +0100 Subject: [PATCH 6/6] satisfy:coderabbit --- apps/web/client/messages/en.d.json.ts | 5 +++++ apps/web/client/messages/en.json | 5 +++++ apps/web/client/messages/es.json | 5 +++++ apps/web/client/messages/ja.json | 5 +++++ apps/web/client/messages/ko.json | 5 +++++ apps/web/client/messages/zh.json | 5 +++++ .../landing-page/feature-blocks/brand-compliance.tsx | 12 ++++++++---- 7 files changed, 38 insertions(+), 4 deletions(-) diff --git a/apps/web/client/messages/en.d.json.ts b/apps/web/client/messages/en.d.json.ts index 7a11f37db2..8c94399ddb 100644 --- a/apps/web/client/messages/en.d.json.ts +++ b/apps/web/client/messages/en.d.json.ts @@ -366,6 +366,11 @@ declare const messages: { "reportIssue": "Report Issue", "shortcuts": "Shortcuts" } + }, + "BrandComplianceBlock": { + "brandColors": "Brand Colors", + "title": "Brand compliance", + "description": "Make your fonts, colors, and styles all speak the same language." } }; export default messages; \ No newline at end of file diff --git a/apps/web/client/messages/en.json b/apps/web/client/messages/en.json index 5907b83fbe..975a17c711 100644 --- a/apps/web/client/messages/en.json +++ b/apps/web/client/messages/en.json @@ -363,5 +363,10 @@ "reportIssue": "Report Issue", "shortcuts": "Shortcuts" } + }, + "BrandComplianceBlock": { + "brandColors": "Brand Colors", + "title": "Brand compliance", + "description": "Make your fonts, colors, and styles all speak the same language." } } \ No newline at end of file diff --git a/apps/web/client/messages/es.json b/apps/web/client/messages/es.json index 42d673bb2d..455c6915a4 100644 --- a/apps/web/client/messages/es.json +++ b/apps/web/client/messages/es.json @@ -363,5 +363,10 @@ "reportIssue": "Reportar Problema", "shortcuts": "Atajos" } + }, + "BrandComplianceBlock": { + "brandColors": "Brand Colors", + "title": "Brand compliance", + "description": "Make your fonts, colors, and styles all speak the same language." } } \ No newline at end of file diff --git a/apps/web/client/messages/ja.json b/apps/web/client/messages/ja.json index 9ead62a3a8..d4819e1a43 100644 --- a/apps/web/client/messages/ja.json +++ b/apps/web/client/messages/ja.json @@ -363,5 +363,10 @@ "reportIssue": "問題を報告", "shortcuts": "ショートカット" } + }, + "BrandComplianceBlock": { + "brandColors": "Brand Colors", + "title": "Brand compliance", + "description": "Make your fonts, colors, and styles all speak the same language." } } \ No newline at end of file diff --git a/apps/web/client/messages/ko.json b/apps/web/client/messages/ko.json index 535c850bd7..0a0fc1f8ef 100644 --- a/apps/web/client/messages/ko.json +++ b/apps/web/client/messages/ko.json @@ -363,5 +363,10 @@ "reportIssue": "오류 신고하기", "shortcuts": "단축키" } + }, + "BrandComplianceBlock": { + "brandColors": "Brand Colors", + "title": "Brand compliance", + "description": "Make your fonts, colors, and styles all speak the same language." } } \ No newline at end of file diff --git a/apps/web/client/messages/zh.json b/apps/web/client/messages/zh.json index 7e4063cac5..ed532449ba 100644 --- a/apps/web/client/messages/zh.json +++ b/apps/web/client/messages/zh.json @@ -363,5 +363,10 @@ "reportIssue": "报告问题", "shortcuts": "快捷键" } + }, + "BrandComplianceBlock": { + "brandColors": "Brand Colors", + "title": "Brand compliance", + "description": "Make your fonts, colors, and styles all speak the same language." } } \ No newline at end of file diff --git a/apps/web/client/src/app/_components/landing-page/feature-blocks/brand-compliance.tsx b/apps/web/client/src/app/_components/landing-page/feature-blocks/brand-compliance.tsx index 037e1d6dca..359aad8278 100644 --- a/apps/web/client/src/app/_components/landing-page/feature-blocks/brand-compliance.tsx +++ b/apps/web/client/src/app/_components/landing-page/feature-blocks/brand-compliance.tsx @@ -1,6 +1,8 @@ "use client"; import React, { useRef } from "react"; +import { useTranslations } from "next-intl"; +import { transKeys } from "@/i18n/keys"; import { motion, useReducedMotion, useScroll, useSpring, useTransform } from "motion/react"; import { Icons } from "@onlook/ui/icons"; @@ -52,13 +54,15 @@ function ParallaxContainer({ } export function BrandComplianceBlock() { + const t = useTranslations(); + return (

- Brand Colors + {t(transKeys.BrandComplianceBlock.brandColors)}

- Brand Colors + {t(transKeys.BrandComplianceBlock.brandColors)}

- Brand compliance + {t(transKeys.BrandComplianceBlock.title)}
{/* Description */}

- Make your fonts, colors, and styles all speak the same language. + {t(transKeys.BrandComplianceBlock.description)}