diff --git a/src/components/ui/backgrounds/background-boxes.tsx b/src/components/ui/backgrounds/background-boxes.tsx index 78decc0..0f000dc 100644 --- a/src/components/ui/backgrounds/background-boxes.tsx +++ b/src/components/ui/backgrounds/background-boxes.tsx @@ -1,4 +1,4 @@ -import { useMemo } from 'react'; +import React, { useMemo } from 'react'; import { motion } from 'framer-motion'; import { sanitizeColor, clampNumber } from './types'; @@ -6,17 +6,35 @@ interface Props { settings: Record; } -export default function BackgroundBoxes({ settings }: Props) { - const rows = clampNumber(settings.rows, 2, 30, 12); - const cols = clampNumber(settings.cols, 2, 30, 12); +const COLORS = [ + '#93c5fd', + '#f9a8d4', + '#86efac', + '#fde047', + '#fca5a5', + '#d8b4fe', + '#a5b4fc', + '#c4b5fd', +]; + +export default React.memo(function BackgroundBoxes({ settings }: Props) { + const rows = clampNumber(settings.rows, 4, 30, 20); + const cols = clampNumber(settings.cols, 4, 30, 12); const boxColor = sanitizeColor(settings.boxColor, '#818cf8'); - const boxes = useMemo(() => { - const result: { row: number; col: number; color: string }[] = []; - for (let r = 0; r < rows; r++) { - for (let c = 0; c < cols; c++) { - result.push({ row: r, col: c, color: boxColor }); + const grid = useMemo(() => { + const result: { color: string; delay: number; duration: number }[][] = []; + for (let i = 0; i < rows; i++) { + const row: { color: string; delay: number; duration: number }[] = []; + for (let j = 0; j < cols; j++) { + row.push({ + color: + boxColor === '#818cf8' ? COLORS[Math.floor(Math.random() * COLORS.length)] : boxColor, + delay: Math.random() * 8, + duration: 3 + Math.random() * 4, + }); } + result.push(row); } return result; }, [rows, cols, boxColor]); @@ -24,33 +42,45 @@ export default function BackgroundBoxes({ settings }: Props) { return (
- {boxes.map((box, i) => ( - + {grid.map((row, i) => ( +
+ {row.map((cell, j) => ( + + {j % 2 === 0 && i % 2 === 0 && ( + + + + )} + + ))} +
))}
); -} +}); diff --git a/src/components/ui/backgrounds/registry.ts b/src/components/ui/backgrounds/registry.ts index 7f1925a..45aa514 100644 --- a/src/components/ui/backgrounds/registry.ts +++ b/src/components/ui/backgrounds/registry.ts @@ -337,17 +337,17 @@ export const backgroundRegistry: BackgroundDefinition[] = [ key: 'rows', label: 'admin.backgrounds.rows', type: 'number', - min: 4, - max: 20, - step: 1, - default: 12, + min: 10, + max: 40, + step: 5, + default: 20, }, { key: 'cols', label: 'admin.backgrounds.cols', type: 'number', - min: 4, - max: 20, + min: 5, + max: 25, step: 1, default: 12, },