mirror of
https://github.com/chillpadclub/bedolaga-cabinet.git
synced 2026-07-30 02:23:47 +00:00
fix: boxes background not covering full screen
- Use original Aceternity positioning: translate(-40%,-60%) with -top-1/4 left-1/4 to cover viewport after skew transform - Switch from CSS grid to flex layout matching original structure - Add cross (+) SVG markers at grid intersections - Use pastel color palette from original, animate opacity per cell - Increase default rows to 20 for better coverage
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
import { useMemo } from 'react';
|
import React, { useMemo } from 'react';
|
||||||
import { motion } from 'framer-motion';
|
import { motion } from 'framer-motion';
|
||||||
import { sanitizeColor, clampNumber } from './types';
|
import { sanitizeColor, clampNumber } from './types';
|
||||||
|
|
||||||
@@ -6,17 +6,35 @@ interface Props {
|
|||||||
settings: Record<string, unknown>;
|
settings: Record<string, unknown>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function BackgroundBoxes({ settings }: Props) {
|
const COLORS = [
|
||||||
const rows = clampNumber(settings.rows, 2, 30, 12);
|
'#93c5fd',
|
||||||
const cols = clampNumber(settings.cols, 2, 30, 12);
|
'#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 boxColor = sanitizeColor(settings.boxColor, '#818cf8');
|
||||||
|
|
||||||
const boxes = useMemo(() => {
|
const grid = useMemo(() => {
|
||||||
const result: { row: number; col: number; color: string }[] = [];
|
const result: { color: string; delay: number; duration: number }[][] = [];
|
||||||
for (let r = 0; r < rows; r++) {
|
for (let i = 0; i < rows; i++) {
|
||||||
for (let c = 0; c < cols; c++) {
|
const row: { color: string; delay: number; duration: number }[] = [];
|
||||||
result.push({ row: r, col: c, color: boxColor });
|
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;
|
return result;
|
||||||
}, [rows, cols, boxColor]);
|
}, [rows, cols, boxColor]);
|
||||||
@@ -24,33 +42,45 @@ export default function BackgroundBoxes({ settings }: Props) {
|
|||||||
return (
|
return (
|
||||||
<div className="absolute inset-0 overflow-hidden">
|
<div className="absolute inset-0 overflow-hidden">
|
||||||
<div
|
<div
|
||||||
className="absolute inset-0"
|
className="absolute -top-1/4 left-1/4 flex h-full w-full p-4"
|
||||||
style={{
|
style={{
|
||||||
display: 'grid',
|
transform:
|
||||||
gridTemplateRows: `repeat(${rows}, 1fr)`,
|
'translate(-40%, -60%) skewX(-48deg) skewY(14deg) scale(0.675) rotate(0deg) translateZ(0)',
|
||||||
gridTemplateColumns: `repeat(${cols}, 1fr)`,
|
|
||||||
transform: 'skewX(-48deg) skewY(14deg) scale(0.675) translateX(10%)',
|
|
||||||
transformOrigin: 'center center',
|
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{boxes.map((box, i) => (
|
{grid.map((row, i) => (
|
||||||
<motion.div
|
<div key={i} className="relative h-8 w-16 border-l border-slate-700">
|
||||||
key={i}
|
{row.map((cell, j) => (
|
||||||
className="border border-white/5"
|
<motion.div
|
||||||
initial={{ opacity: 0 }}
|
key={j}
|
||||||
animate={{
|
className="relative h-8 w-16 border-r border-t border-slate-700"
|
||||||
opacity: [0, 0.08, 0],
|
initial={{ opacity: 0 }}
|
||||||
}}
|
animate={{ opacity: [0, 0.15, 0] }}
|
||||||
transition={{
|
transition={{
|
||||||
duration: 3 + Math.random() * 4,
|
duration: cell.duration,
|
||||||
delay: Math.random() * 5,
|
delay: cell.delay,
|
||||||
repeat: Infinity,
|
repeat: Infinity,
|
||||||
ease: 'easeInOut',
|
ease: 'easeInOut',
|
||||||
}}
|
}}
|
||||||
style={{ backgroundColor: box.color }}
|
style={{ backgroundColor: cell.color }}
|
||||||
/>
|
>
|
||||||
|
{j % 2 === 0 && i % 2 === 0 && (
|
||||||
|
<svg
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
fill="none"
|
||||||
|
viewBox="0 0 24 24"
|
||||||
|
strokeWidth="1.5"
|
||||||
|
stroke="currentColor"
|
||||||
|
className="pointer-events-none absolute -left-[22px] -top-[14px] h-6 w-10 stroke-[1px] text-slate-700"
|
||||||
|
>
|
||||||
|
<path strokeLinecap="round" strokeLinejoin="round" d="M12 6v12m6-6H6" />
|
||||||
|
</svg>
|
||||||
|
)}
|
||||||
|
</motion.div>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
});
|
||||||
|
|||||||
@@ -337,17 +337,17 @@ export const backgroundRegistry: BackgroundDefinition[] = [
|
|||||||
key: 'rows',
|
key: 'rows',
|
||||||
label: 'admin.backgrounds.rows',
|
label: 'admin.backgrounds.rows',
|
||||||
type: 'number',
|
type: 'number',
|
||||||
min: 4,
|
min: 10,
|
||||||
max: 20,
|
max: 40,
|
||||||
step: 1,
|
step: 5,
|
||||||
default: 12,
|
default: 20,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: 'cols',
|
key: 'cols',
|
||||||
label: 'admin.backgrounds.cols',
|
label: 'admin.backgrounds.cols',
|
||||||
type: 'number',
|
type: 'number',
|
||||||
min: 4,
|
min: 5,
|
||||||
max: 20,
|
max: 25,
|
||||||
step: 1,
|
step: 1,
|
||||||
default: 12,
|
default: 12,
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user