|
1 | 1 | "use client"; |
2 | 2 |
|
3 | | -import type React from "react"; |
4 | | -import { useId } from "react"; |
| 3 | +import { Apple } from "lucide-react"; |
5 | 4 | import { cn } from "@/lib/utils"; |
6 | 5 |
|
7 | | -interface DotPatternProps extends React.SVGProps<SVGSVGElement> { |
| 6 | +const APPLE_COLORS = [ |
| 7 | + "#61bb46", // green |
| 8 | + "#fdb827", // yellow |
| 9 | + "#f5821f", // orange |
| 10 | + "#e03a3e", // red |
| 11 | + "#963d97", // purple |
| 12 | + "#009ddc", // blue |
| 13 | +]; |
| 14 | + |
| 15 | +interface DotPatternProps { |
8 | 16 | width?: number; |
9 | 17 | height?: number; |
10 | | - x?: number; |
11 | | - y?: number; |
12 | | - cx?: number; |
13 | | - cy?: number; |
14 | | - cr?: number; |
15 | 18 | className?: string; |
16 | 19 | glow?: boolean; |
17 | 20 | } |
18 | 21 |
|
19 | | -export function DotPattern({ |
20 | | - width = 16, |
21 | | - height = 16, |
22 | | - x = 0, |
23 | | - y = 0, |
24 | | - cx = 1, |
25 | | - cy = 1, |
26 | | - cr = 1, |
27 | | - className, |
28 | | - glow = false, |
29 | | - ...props |
30 | | -}: DotPatternProps) { |
31 | | - const id = useId(); |
| 22 | +export function DotPattern({ width = 48, height = 48, className, glow = false }: DotPatternProps) { |
| 23 | + // Calculate grid dimensions based on a reasonable viewport |
| 24 | + const cols = Math.ceil(1920 / width); |
| 25 | + const rows = Math.ceil(1080 / height); |
| 26 | + |
| 27 | + // Create a grid of apples with deterministic colors |
| 28 | + const apples = []; |
| 29 | + for (let row = 0; row < rows; row++) { |
| 30 | + for (let col = 0; col < cols; col++) { |
| 31 | + // Deterministic "random" color based on position |
| 32 | + const colorIndex = (col * 7 + row * 13) % APPLE_COLORS.length; |
| 33 | + const color = APPLE_COLORS[colorIndex]; |
| 34 | + |
| 35 | + apples.push( |
| 36 | + <div |
| 37 | + key={`${row}-${col}`} |
| 38 | + className="absolute" |
| 39 | + style={{ |
| 40 | + left: col * width + width / 2 - 6, |
| 41 | + top: row * height + height / 2 - 6, |
| 42 | + }} |
| 43 | + > |
| 44 | + <Apple size={12} color={color} strokeWidth={1.5} style={{ opacity: 0.35 }} /> |
| 45 | + </div>, |
| 46 | + ); |
| 47 | + } |
| 48 | + } |
32 | 49 |
|
33 | 50 | return ( |
34 | | - <svg |
| 51 | + <div |
35 | 52 | aria-hidden="true" |
36 | 53 | className={cn( |
37 | | - "pointer-events-none absolute inset-0 h-full w-full text-neutral-400/80", |
| 54 | + "pointer-events-none absolute inset-0 overflow-hidden", |
38 | 55 | glow && "animate-dot-glow", |
39 | 56 | className, |
40 | 57 | )} |
41 | | - {...props} |
42 | 58 | > |
43 | | - <defs> |
44 | | - <pattern |
45 | | - id={`${id}-pattern`} |
46 | | - width={width} |
47 | | - height={height} |
48 | | - patternUnits="userSpaceOnUse" |
49 | | - patternContentUnits="userSpaceOnUse" |
50 | | - x={x} |
51 | | - y={y} |
52 | | - > |
53 | | - <circle cx={cx} cy={cy} r={cr} fill="currentColor" /> |
54 | | - </pattern> |
55 | | - </defs> |
56 | | - <rect width="100%" height="100%" fill={`url(#${id}-pattern)`} strokeWidth={0} /> |
57 | | - </svg> |
| 59 | + {apples} |
| 60 | + </div> |
58 | 61 | ); |
59 | 62 | } |
0 commit comments