From 406177bf013b09949cc7f5536247796c45cb2873 Mon Sep 17 00:00:00 2001 From: Ameya Shenoy Date: Sat, 7 Jun 2025 16:33:42 +0530 Subject: [PATCH] chore: stuff Signed-off-by: Ameya Shenoy --- frontend/src/components/Navbar.tsx | 42 ++++++++++++-- frontend/src/components/PhysicsSimulation.tsx | 56 ++++++++++--------- 2 files changed, 67 insertions(+), 31 deletions(-) diff --git a/frontend/src/components/Navbar.tsx b/frontend/src/components/Navbar.tsx index 731c576..d11dd38 100644 --- a/frontend/src/components/Navbar.tsx +++ b/frontend/src/components/Navbar.tsx @@ -1,24 +1,56 @@ import { Button } from "@/components/ui/button"; import Link from "next/link"; import { ModeToggle } from "@/components/ModeToggle"; +import { + House, + NotebookPen, + BriefcaseBusiness, + MessageCircleMore, + Handshake, +} from "lucide-react"; export function NavigationMenu() { return (
diff --git a/frontend/src/components/PhysicsSimulation.tsx b/frontend/src/components/PhysicsSimulation.tsx index 1386caa..3282fff 100644 --- a/frontend/src/components/PhysicsSimulation.tsx +++ b/frontend/src/components/PhysicsSimulation.tsx @@ -3,6 +3,7 @@ import { useEffect, useRef } from "react"; import { useTheme } from "next-themes"; import Matter from "matter-js"; +import { twj } from "tw-to-css"; export function World() { const containerRef = useRef(null); @@ -24,14 +25,18 @@ export function World() { const width = container.offsetWidth; const height = container.offsetHeight; - const bgColor = getComputedStyle(document.documentElement) - .getPropertyValue("--color-background") - .trim(); - const fgColor = getComputedStyle(document.documentElement) - .getPropertyValue("--color-foreground") - .trim(); - console.log(resolvedTheme, bgColor, fgColor); + // TODO: ask Shubh about using variables in useEffect not working as expected + // const bgColor = getComputedStyle(document.documentElement) + // .getPropertyValue("--color-background") + // .trim(); + // const fgColor = getComputedStyle(document.documentElement) + // .getPropertyValue("--color-foreground") + // .trim(); + const bgColor = + resolvedTheme === "dark" ? "oklch(0.145 0 0)" : "oklch(1 0 0)"; + const fgColor = + resolvedTheme === "dark" ? "oklch(0.985 0 0)" : "oklch(0.145 0 0)"; const { Engine, @@ -89,20 +94,20 @@ export function World() { }); // Random ball position - const radius = 15; + const ballRadius = 15; - let [randomX, randomY] = getRandomXY(width, height, radius); - const ballRed = Bodies.circle(randomX, randomY, radius, { + let [randomX, randomY] = getRandomXY(width, height, ballRadius); + const ballRed = Bodies.circle(randomX, randomY, ballRadius, { restitution: 0.8, render: { fillStyle: "red" }, }); - [randomX, randomY] = getRandomXY(width, height, radius); - const ballBlue = Bodies.circle(randomX, randomY, radius, { + [randomX, randomY] = getRandomXY(width, height, ballRadius); + const ballBlue = Bodies.circle(randomX, randomY, ballRadius, { restitution: 0.8, render: { fillStyle: "blue" }, }); - [randomX, randomY] = getRandomXY(width, height, radius); - const ballGreen = Bodies.circle(randomX, randomY, radius, { + [randomX, randomY] = getRandomXY(width, height, ballRadius); + const ballGreen = Bodies.circle(randomX, randomY, ballRadius, { restitution: 0.8, render: { fillStyle: "green" }, }); @@ -132,12 +137,12 @@ export function World() { const pillText = pillInfo.text; const ctx = render.canvas.getContext("2d"); - ctx.font = `${fontSize}px Arial`; + ctx.font = `${fontSize}px Mono`; const textWidth = ctx.measureText(pillText).width; const pillHeight = fontSize * 2; const pillWidth = textWidth + pillHeight; - [randomX, randomY] = getRandomXY(width, height, radius); + [randomX, randomY] = getRandomXY(width, height, pillWidth / 2); const chamferRadius = pillInfo.chamferRadius || pillHeight / 2; const pill = Matter.Bodies.rectangle( randomX, @@ -161,16 +166,15 @@ export function World() { pills.push(pill); const text: HTMLDivElement = document.createElement("div"); Object.assign(text.style, { - position: "absolute", - width: `${pillWidth}px`, - height: `${pillHeight}px`, - display: "flex", - justifyContent: "center", - alignItems: "center", - fontFamily: "Space Mono", - fontSize: `${fontSize}px`, - color: fgColor, - pointerEvents: "none", + ...twj("absolute flex justify-center items-center"), + ...{ + width: `${pillWidth}px`, + height: `${pillHeight}px`, + fontFamily: "Space Mono", + fontSize: `${fontSize}px`, + color: fgColor, + pointerEvents: "none", + }, }); text.innerText = pillText; pillTexts.push(text);