diff --git a/components/ui/wavy-background.tsx b/components/ui/wavy-background.tsx new file mode 100644 index 0000000..082fe73 --- /dev/null +++ b/components/ui/wavy-background.tsx @@ -0,0 +1,132 @@ +"use client"; +import { cn } from "~/lib/utils"; +import React, { useEffect, useRef, useState } from "react"; +import { createNoise3D } from "simplex-noise"; + +export const WavyBackground = ({ + children, + className, + containerClassName, + colors, + waveWidth, + backgroundFill, + blur = 10, + speed = "fast", + waveOpacity = 0.5, + ...props +}: { + children?: any; + className?: string; + containerClassName?: string; + colors?: string[]; + waveWidth?: number; + backgroundFill?: string; + blur?: number; + speed?: "slow" | "fast"; + waveOpacity?: number; + [key: string]: any; +}) => { + const noise = createNoise3D(); + let w: number, + h: number, + nt: number, + i: number, + x: number, + ctx: any, + canvas: any; + const canvasRef = useRef(null); + const getSpeed = () => { + switch (speed) { + case "slow": + return 0.001; + case "fast": + return 0.002; + default: + return 0.001; + } + }; + + const init = () => { + canvas = canvasRef.current; + ctx = canvas.getContext("2d"); + w = ctx.canvas.width = window.innerWidth; + h = ctx.canvas.height = window.innerHeight; + ctx.filter = `blur(${blur}px)`; + nt = 0; + window.onresize = function () { + w = ctx.canvas.width = window.innerWidth; + h = ctx.canvas.height = window.innerHeight; + ctx.filter = `blur(${blur}px)`; + }; + render(); + }; + + const waveColors = colors ?? [ + "#38bdf8", + "#818cf8", + "#c084fc", + "#e879f9", + "#22d3ee", + ]; + const drawWave = (n: number) => { + nt += getSpeed(); + for (i = 0; i < n; i++) { + ctx.beginPath(); + ctx.lineWidth = waveWidth || 50; + ctx.strokeStyle = waveColors[i % waveColors.length]; + for (x = 0; x < w; x += 5) { + var y = noise(x / 800, 0.3 * i, nt) * 100; + ctx.lineTo(x, y + h * 0.5); // adjust for height, currently at 50% of the container + } + ctx.stroke(); + ctx.closePath(); + } + }; + + let animationId: number; + const render = () => { + ctx.fillStyle = backgroundFill || "black"; + ctx.globalAlpha = waveOpacity || 0.5; + ctx.fillRect(0, 0, w, h); + drawWave(5); + animationId = requestAnimationFrame(render); + }; + + useEffect(() => { + init(); + return () => { + cancelAnimationFrame(animationId); + }; + }, []); + + const [isSafari, setIsSafari] = useState(false); + useEffect(() => { + // I'm sorry but i have got to support it on safari. + setIsSafari( + typeof window !== "undefined" && + navigator.userAgent.includes("Safari") && + !navigator.userAgent.includes("Chrome") + ); + }, []); + + return ( +
+ +
+ {children} +
+
+ ); +}; diff --git a/screens/home/MainHomeScreen.tsx b/screens/home/MainHomeScreen.tsx index cfbff09..a69a6cc 100644 --- a/screens/home/MainHomeScreen.tsx +++ b/screens/home/MainHomeScreen.tsx @@ -29,7 +29,8 @@ import { ChevronRight } from "lucide-react"; import { cn } from "~/lib/utils"; // import { Button } from "@/components/ui/button"; import { BoxReveal } from "~/components/magicui/box-reveal"; - +import { WavyBackground } from "~/components/ui/wavy-background"; + const Header = () => { return
@@ -68,66 +69,28 @@ export const Container = ({ children, noHeader }: any) => { } const EmptyHome = () => { - return -
- - - Welcome to Carmel City - -
-
-
- -
- -
- -

- People are debating about -

-
- - -

- how to build more human world -

-
- - - - - - - - -

- - Check out what the community is building - -

-
-
- - - - -
-
+ return +
+

+ How do we build a more human world? +

+

+ See what other Carmel members in debating how we build a more human world. +

+ + + + + + +
+
} const onItemPress = (element: any, router: any) => { diff --git a/styles/globals.css b/styles/globals.css index b11600b..86ea7f4 100644 --- a/styles/globals.css +++ b/styles/globals.css @@ -287,8 +287,6 @@ blockquote.twitter-tweet a:focus { margin-top: 1rem; } - - @layer base { :root { --background: 0 0% 100%; @@ -297,7 +295,7 @@ blockquote.twitter-tweet a:focus { --card-foreground: 0 0% 3.9%; --popover: 0 0% 100%; --popover-foreground: 0 0% 3.9%; - --primary: 0 0% 9%; + --primary: 0 73% 83%; --primary-foreground: 0 0% 98%; --secondary: 0 0% 96.1%; --secondary-foreground: 0 0% 9%; @@ -324,7 +322,7 @@ blockquote.twitter-tweet a:focus { --card-foreground: 0 0% 98%; --popover: 0 0% 3.9%; --popover-foreground: 0 0% 98%; - --primary: 0 0% 98%; + --primary: 187 92.4% 69%; --primary-foreground: 0 0% 9%; --secondary: 0 0% 14.9%; --secondary-foreground: 0 0% 98%;