mirror of
https://github.com/chillpadclub/bedolaga-cabinet.git
synced 2026-07-28 09:33:46 +00:00
fix(backgrounds): read aurora gradient colors and speed from settings
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
import { cn } from '@/lib/utils';
|
import { cn } from '@/lib/utils';
|
||||||
import { safeBoolean } from './types';
|
import { sanitizeColor, safeBoolean, safeSelect } from './types';
|
||||||
import { useAnimationPause } from '@/hooks/useAnimationLoop';
|
import { useAnimationPause } from '@/hooks/useAnimationLoop';
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
@@ -8,7 +8,17 @@ interface Props {
|
|||||||
|
|
||||||
const isMobile = typeof window !== 'undefined' && window.innerWidth < 768;
|
const isMobile = typeof window !== 'undefined' && window.innerWidth < 768;
|
||||||
|
|
||||||
|
const SPEED_DURATIONS: Record<string, string> = {
|
||||||
|
slow: '90s',
|
||||||
|
normal: '60s',
|
||||||
|
fast: '30s',
|
||||||
|
};
|
||||||
|
|
||||||
export default function AuroraBackground({ settings }: Props) {
|
export default function AuroraBackground({ settings }: Props) {
|
||||||
|
const firstColor = sanitizeColor(settings.firstColor, '#3b82f6');
|
||||||
|
const secondColor = sanitizeColor(settings.secondColor, '#a5b4fc');
|
||||||
|
const thirdColor = sanitizeColor(settings.thirdColor, '#93c5fd');
|
||||||
|
const speed = safeSelect(settings.speed, ['slow', 'normal', 'fast'] as const, 'normal');
|
||||||
const showRadialGradient = safeBoolean(settings.showRadialGradient, true);
|
const showRadialGradient = safeBoolean(settings.showRadialGradient, true);
|
||||||
const paused = useAnimationPause();
|
const paused = useAnimationPause();
|
||||||
|
|
||||||
@@ -22,9 +32,9 @@ export default function AuroraBackground({ settings }: Props) {
|
|||||||
'[mask-image:radial-gradient(ellipse_at_100%_0%,black_10%,transparent_70%)]',
|
'[mask-image:radial-gradient(ellipse_at_100%_0%,black_10%,transparent_70%)]',
|
||||||
)}
|
)}
|
||||||
style={{
|
style={{
|
||||||
backgroundImage:
|
backgroundImage: `repeating-linear-gradient(100deg, #000 0%, #000 7%, transparent 10%, transparent 12%, #000 16%), repeating-linear-gradient(100deg, ${firstColor} 10%, ${secondColor} 15%, ${thirdColor} 20%, ${secondColor} 25%, ${firstColor} 30%)`,
|
||||||
'repeating-linear-gradient(100deg, #000 0%, #000 7%, transparent 10%, transparent 12%, #000 16%), repeating-linear-gradient(100deg, #3b82f6 10%, #a5b4fc 15%, #93c5fd 20%, #ddd6fe 25%, #60a5fa 30%)',
|
|
||||||
backgroundSize: isMobile ? '100%, 100%' : '300%, 200%',
|
backgroundSize: isMobile ? '100%, 100%' : '300%, 200%',
|
||||||
|
animationDuration: SPEED_DURATIONS[speed],
|
||||||
animationPlayState: paused ? 'paused' : 'running',
|
animationPlayState: paused ? 'paused' : 'running',
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -59,9 +59,15 @@ export const backgroundRegistry: BackgroundDefinition[] = [
|
|||||||
descriptionKey: 'admin.backgrounds.auroraDesc',
|
descriptionKey: 'admin.backgrounds.auroraDesc',
|
||||||
category: 'css',
|
category: 'css',
|
||||||
settings: [
|
settings: [
|
||||||
{ key: 'firstColor', label: 'admin.backgrounds.color1', type: 'color', default: '#00d2ff' },
|
{ key: 'firstColor', label: 'admin.backgrounds.color1', type: 'color', default: '#3b82f6' },
|
||||||
{ key: 'secondColor', label: 'admin.backgrounds.color2', type: 'color', default: '#7928ca' },
|
{ key: 'secondColor', label: 'admin.backgrounds.color2', type: 'color', default: '#a5b4fc' },
|
||||||
{ key: 'thirdColor', label: 'admin.backgrounds.color3', type: 'color', default: '#ff0080' },
|
{ key: 'thirdColor', label: 'admin.backgrounds.color3', type: 'color', default: '#93c5fd' },
|
||||||
|
{
|
||||||
|
key: 'showRadialGradient',
|
||||||
|
label: 'admin.backgrounds.radialGradient',
|
||||||
|
type: 'boolean',
|
||||||
|
default: true,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
key: 'speed',
|
key: 'speed',
|
||||||
label: 'admin.backgrounds.speed',
|
label: 'admin.backgrounds.speed',
|
||||||
|
|||||||
Reference in New Issue
Block a user