HifiPlanet-Website/hifi-src/src/components/Reveal.jsx
Maaxxs 17f331c35e Add global font selection with per-section override
Extracts the system-font list already used by RichTextEditor for mail
templates into a shared hifi-src/src/utils/fontOptions.js (frontend) and
App\Support\Fonts (backend), so it can drive two new pickers with a
consistent set of options.

Global: a new app_settings.site_font setting, exposed as an admin dropdown
in WebsiteSettings.jsx. tailwind.config.js now defines font-sans as
var(--site-font, ui-sans-serif, system-ui, sans-serif); Tailwind's
preflight already applies font-sans globally to <html>, so this alone
makes the chosen font cascade to virtually every text on the public site
without touching individual components. PublicLayout.jsx sets the CSS
variable from the fetched site settings.

Per-section override: a new home_sections.font_family column, editable
per homepage section in HomeSections.jsx ("Standard" = inherit the global
font). Home.jsx applies it as an inline style on each section's wrapper,
which naturally wins over the CSS-variable-driven global default when
set. Reveal.jsx gained an optional style prop (merged into its own
transform/opacity style) so the four flowing-text sections, which use it
directly as their wrapper, can receive the override too.

Verified locally: migration adds both columns without touching existing
rows, and both settings round-trip correctly through the database.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-09-10 00:12:01 +02:00

50 lines
1.6 KiB
JavaScript

import { motion } from 'framer-motion';
const EASE = [0.16, 1, 0.3, 1];
const offsetFor = {
up: { y: 40 },
left: { x: -56 },
right: { x: 56 },
};
function buildVariants(direction) {
const offset = offsetFor[direction] || offsetFor.up;
return {
hidden: { opacity: 0, scale: 0.96, filter: 'blur(8px)', ...offset },
visible: { opacity: 1, scale: 1, x: 0, y: 0, filter: 'blur(0px)' },
};
}
const shineVariants = {
hidden: { x: '-130%' },
visible: { x: '230%', transition: { duration: 1.1, ease: 'easeInOut', delay: 0.4 } },
};
// Trigger-based reveal: each element fades/slides/un-blurs into place the
// first time it enters the viewport, then stays put. Calm and predictable
// on repeated scrolling in either direction (no re-triggering, no jitter).
export default function Reveal({ children, direction = 'up', className = '', index = 0, shine = false, style }) {
const delay = Math.min(index * 0.09, 0.45);
return (
<motion.div
className={className}
style={{ position: 'relative', overflow: 'hidden', ...style }}
initial="hidden"
whileInView="visible"
viewport={{ once: true, amount: 0.25, margin: '-100px' }}
variants={buildVariants(direction)}
transition={{ duration: 0.75, ease: EASE, delay }}
>
{children}
{shine && (
<motion.div
aria-hidden
variants={shineVariants}
className="pointer-events-none absolute inset-y-0 -left-1/3 w-1/3 rotate-12 bg-gradient-to-r from-transparent via-white/40 to-transparent"
/>
)}
</motion.div>
);
}