From aacd2675f3274029725b61147e7b4bce1a40b861 Mon Sep 17 00:00:00 2001 From: johnchourajr Date: Sun, 12 Jan 2025 23:53:48 -0800 Subject: [PATCH] update component --- .../src/components/SliceHero/SliceHero.tsx | 44 +------------ .../src/components/SvgHeader/SvgHeader.tsx | 65 +++++++++++++------ 2 files changed, 49 insertions(+), 60 deletions(-) diff --git a/example/src/components/SliceHero/SliceHero.tsx b/example/src/components/SliceHero/SliceHero.tsx index 7c1206b..c13206e 100644 --- a/example/src/components/SliceHero/SliceHero.tsx +++ b/example/src/components/SliceHero/SliceHero.tsx @@ -1,28 +1,12 @@ "use client"; -import { useEffect, useRef, useState } from "react"; +import { useRef } from "react"; import { GenThreeShader } from "../GenThreeShader"; import { wavesShader } from "../GenThreeShader/shaders/wavesShader"; -import { logotype } from "../SvgHeader/logotype"; +import { SvgHeader } from "../SvgHeader"; export function SliceHero() { const containerRef = useRef(null); - const [scale, setScale] = useState(1); - - useEffect(() => { - const updateScale = () => { - if (!containerRef.current) return; - const { width } = containerRef.current.getBoundingClientRect(); - // Adjust these values to control how the logo scales - const baseWidth = 208; // Original SVG width - const newScale = width / baseWidth; - setScale(newScale); - }; - - updateScale(); - window.addEventListener("resize", updateScale); - return () => window.removeEventListener("resize", updateScale); - }, []); return (
- - - - - - - - - - +
); } diff --git a/example/src/components/SvgHeader/SvgHeader.tsx b/example/src/components/SvgHeader/SvgHeader.tsx index f926ef5..1b48910 100644 --- a/example/src/components/SvgHeader/SvgHeader.tsx +++ b/example/src/components/SvgHeader/SvgHeader.tsx @@ -1,28 +1,55 @@ "use client"; -import { motion } from "framer-motion"; +import clsx from "clsx"; +import { RefObject, useEffect, useState } from "react"; import { logotype } from "./logotype"; type SvgHeaderProps = { className?: string; + containerRef: RefObject; }; -const SvgHeader = ({ className }: SvgHeaderProps) => ( - - - -); +const SvgHeader = ({ className, containerRef }: SvgHeaderProps) => { + const [scale, setScale] = useState(1); + + useEffect(() => { + const updateScale = () => { + if (!containerRef.current) return; + const { width } = containerRef.current.getBoundingClientRect(); + // Adjust these values to control how the logo scales + const baseWidth = 208; // Original SVG width + const newScale = width / baseWidth; + setScale(newScale); + }; + + updateScale(); + window.addEventListener("resize", updateScale); + return () => window.removeEventListener("resize", updateScale); + }, []); + return ( + + + + + + + + + + + ); +}; export default SvgHeader;