Add live-preview positioning to all homepage sections

Follow-up to "mach das bitte auch für alle Startseiten-Sektionen" -
the request was for the same drag experience across all six homepage
text sections, but they split into two structurally different groups
and got two different (both live-preview-driven) treatments rather
than forcing one interaction model onto both:

- Hero and the YouTube section have a real background (image, video)
  behind the text, structurally identical to the gallery cards - these
  get full continuous 2D drag positioning, reusing the same "left/top +
  translate(-x%,-y%)" technique. New home_sections.text_align_x/_y
  (TINYINT UNSIGNED 0-100, default 50/50 = centered, matching current
  behavior) sit alongside the existing text_align column rather than
  replacing it, since the other four sections still need it.
- Craft, Advice, Insights, and "More than car-hifi" are normal
  paragraph text next to a separate image column, with no background
  to drag over - text-align (left/center/right) is the actually correct
  tool for how wrapped paragraph lines align, the same way word
  processors use alignment buttons rather than a position slider for
  body text. These keep the existing text_align enum, but the admin
  page (HomeSections.jsx) replaces the old bare <select> with an actual
  rendered live preview (title/eyebrow/body snippet in a mock card)
  instead of leaving these four with zero visual feedback.

Renamed the shared positioning helper from galleryCardAlign.js /
galleryCardLabelStyle() to dragAnchorPosition.js / dragAnchorStyle()
(now takes a per-caller default so gallery cards keep their bottom-
anchored default while Home.jsx sections default to centered) since
it's no longer gallery-specific - three call sites updated.

Restructured Hero and the YouTube section in Home.jsx so the drag-set
static position doesn't fight with existing animation: Hero already
composes a scroll-linked parallax transform (framer-motion) and an
entrance fade-in on nested motion.div elements, both of which manage
their own `transform` internally - inserting a new plain (non-motion)
div between them for the percentage-based positioning keeps the static
placement and the two animations from touching the same CSS property.

Verified against the local database directly via PHP CLI: hero/youtube
default to 50/50 (centered, no visual change from before), and an
arbitrary pair (25/80) written to hero round-trips correctly through
HomeSectionController::index(), then removed the test row.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
Maaxxs 2026-09-09 03:42:17 +02:00
parent 28fc9d76dd
commit 1b60b71ecd
16 changed files with 390 additions and 183 deletions

View file

@ -1,6 +1,7 @@
import { useEffect, useState } from 'react'; import { useEffect, useRef, useState } from 'react';
import { api } from '../../api/client.js'; import { api } from '../../api/client.js';
import RichTextEditor from '../../components/RichTextEditor.jsx'; import RichTextEditor from '../../components/RichTextEditor.jsx';
import { dragAnchorStyle } from '../../utils/dragAnchorPosition.js';
const SECTIONS = [ const SECTIONS = [
{ slug: 'hero', label: 'Hero (ganz oben)' }, { slug: 'hero', label: 'Hero (ganz oben)' },
@ -11,12 +12,30 @@ const SECTIONS = [
{ slug: 'more', label: 'Mehr als Car-Hifi' }, { slug: 'more', label: 'Mehr als Car-Hifi' },
]; ];
// Hero und YouTube haben einen echten Hintergrund (Bild bzw. Video) und der Textblock liegt
// darueber - dort ist eine frei ziehbare 2D-Position sinnvoll, genau wie bei den
// Bildergalerie-Kacheln (siehe WebsiteSettings.jsx). Die anderen vier Abschnitte sind
// normaler, neben einem separaten Bild fliessender bzw. umbrechender Text ohne eigenen
// Hintergrund - dort bleibt links/mittig/rechts (text-align auf ganzen Absaetzen) das
// richtige Werkzeug, keine frei ziehbare Position wie bei einem einzelnen ueberlagerten Label.
const POSITIONABLE_SLUGS = ['hero', 'youtube'];
const ALIGN_OPTIONS = [ const ALIGN_OPTIONS = [
{ value: 'left', label: 'Links' }, { value: 'left', label: 'Links' },
{ value: 'center', label: 'Mittig' }, { value: 'center', label: 'Mittig' },
{ value: 'right', label: 'Rechts' }, { value: 'right', label: 'Rechts' },
]; ];
// Feste Klassen (nicht dynamisch zusammengesetzt) fuer Tailwinds Build-Zeit-Scanner - siehe
// Kommentar bei dragAnchorPosition.js/Home.jsx.
const ALIGN_OPTIONS_TEXT = { left: 'text-left', center: 'text-center', right: 'text-right' };
function stripHtml(html) {
const div = document.createElement('div');
div.innerHTML = html || '';
return div.textContent || '';
}
export default function HomeSections() { export default function HomeSections() {
const [sections, setSections] = useState(null); const [sections, setSections] = useState(null);
const [activeSlug, setActiveSlug] = useState('hero'); const [activeSlug, setActiveSlug] = useState('hero');
@ -24,9 +43,15 @@ export default function HomeSections() {
const [saveBusy, setSaveBusy] = useState(false); const [saveBusy, setSaveBusy] = useState(false);
const [saveError, setSaveError] = useState(''); const [saveError, setSaveError] = useState('');
const [saveSuccess, setSaveSuccess] = useState(false); const [saveSuccess, setSaveSuccess] = useState(false);
// Fuer eine realistischere Hero-Vorschau (echtes Hero-Bild, falls schon eines hochgeladen ist).
const [heroImagePath, setHeroImagePath] = useState('');
const previewRef = useRef(null);
const [dragging, setDragging] = useState(false);
useEffect(() => { useEffect(() => {
api.get('/home-sections').then(setSections); api.get('/home-sections').then(setSections);
api.get('/site-settings').then((res) => setHeroImagePath(res.hero_image_path || ''));
}, []); }, []);
if (!sections) { if (!sections) {
@ -34,12 +59,42 @@ export default function HomeSections() {
} }
const active = sections[activeSlug]; const active = sections[activeSlug];
const isPositionable = POSITIONABLE_SLUGS.includes(activeSlug);
const update = (field, value) => { const update = (field, value) => {
setSections((s) => ({ ...s, [activeSlug]: { ...s[activeSlug], [field]: value } })); setSections((s) => ({ ...s, [activeSlug]: { ...s[activeSlug], [field]: value } }));
setSaveSuccess(false); setSaveSuccess(false);
}; };
const updatePosition = (x, y) => {
setSections((s) => ({ ...s, [activeSlug]: { ...s[activeSlug], text_align_x: x, text_align_y: y } }));
setSaveSuccess(false);
};
const positionFromPointer = (clientX, clientY) => {
const rect = previewRef.current.getBoundingClientRect();
return {
x: Math.max(0, Math.min(100, Math.round(((clientX - rect.left) / rect.width) * 100))),
y: Math.max(0, Math.min(100, Math.round(((clientY - rect.top) / rect.height) * 100))),
};
};
const handleDragStart = (e) => {
e.preventDefault();
e.currentTarget.setPointerCapture(e.pointerId);
setDragging(true);
const { x, y } = positionFromPointer(e.clientX, e.clientY);
updatePosition(x, y);
};
const handleDragMove = (e) => {
if (!dragging) return;
const { x, y } = positionFromPointer(e.clientX, e.clientY);
updatePosition(x, y);
};
const handleDragEnd = (e) => {
setDragging(false);
e.currentTarget.releasePointerCapture(e.pointerId);
};
const handleSave = async () => { const handleSave = async () => {
setSaveBusy(true); setSaveBusy(true);
setSaveError(''); setSaveError('');
@ -54,12 +109,16 @@ export default function HomeSections() {
} }
}; };
const previewEyebrow = active[`eyebrow_${activeLang}`] || '';
const previewTitle = active[`title_${activeLang}`] || SECTIONS.find((s) => s.slug === activeSlug)?.label || '';
const previewBody = stripHtml(active[`body_html_${activeLang}`]);
return ( return (
<div className="max-w-3xl space-y-6"> <div className="max-w-3xl space-y-6">
<div> <div>
<h1 className="mb-1 text-xl font-bold text-neutral-900 dark:text-white">Startseite</h1> <h1 className="mb-1 text-xl font-bold text-neutral-900 dark:text-white">Startseite</h1>
<p className="mb-4 text-sm text-neutral-500 dark:text-neutral-400"> <p className="mb-4 text-sm text-neutral-500 dark:text-neutral-400">
Text, Ausrichtung und (falls vorhanden) Button-Ziel der wichtigsten Textabschnitte auf der Text, Position/Ausrichtung und (falls vorhanden) Button-Ziel der wichtigsten Textabschnitte auf der
Startseite. Bilder, Statistik-Kacheln, Marken-Streifen, Bewertungen und FAQ werden an anderer Startseite. Bilder, Statistik-Kacheln, Marken-Streifen, Bewertungen und FAQ werden an anderer
Stelle verwaltet. Stelle verwaltet.
</p> </p>
@ -87,8 +146,7 @@ export default function HomeSections() {
))} ))}
</div> </div>
<div className="mb-4 flex items-center justify-between gap-4 border-b border-neutral-200 pb-4 dark:border-neutral-800"> <div className="mb-4 flex gap-1 border-b border-neutral-200 pb-4 dark:border-neutral-800">
<div className="flex gap-1">
{[ {[
['de', 'Deutsch'], ['de', 'Deutsch'],
['en', 'English'], ['en', 'English'],
@ -107,21 +165,119 @@ export default function HomeSections() {
</button> </button>
))} ))}
</div> </div>
<div className="flex items-center gap-2">
<label className="text-sm font-medium text-neutral-700 dark:text-neutral-300">Ausrichtung</label> {isPositionable ? (
<select <div className="mb-5 grid gap-4 border-b border-neutral-200 pb-5 dark:border-neutral-800 sm:grid-cols-[16rem_1fr] sm:items-start">
value={active.text_align} <div>
onChange={(e) => update('text_align', e.target.value)} <div
className="rounded-md border border-neutral-300 bg-white px-2 py-1 text-sm dark:border-neutral-700 dark:bg-neutral-900" ref={previewRef}
className="relative aspect-video select-none overflow-hidden rounded-xl bg-neutral-900 shadow-sm"
> >
{ALIGN_OPTIONS.map((a) => ( {activeSlug === 'hero' && heroImagePath ? (
<option key={a.value} value={a.value}> <img src={heroImagePath} alt="" draggable={false} className="h-full w-full object-cover" />
{a.label} ) : (
</option> <div className="flex h-full w-full items-center justify-center bg-gradient-to-br from-neutral-700 to-neutral-900 text-xs uppercase tracking-wide text-neutral-500">
{activeSlug === 'youtube' ? 'Video-Hintergrund' : 'Hero-Bild'}
</div>
)}
<div className="absolute inset-0 bg-gradient-to-t from-black/70 via-black/20 to-black/40" />
<div
onPointerDown={handleDragStart}
onPointerMove={handleDragMove}
onPointerUp={handleDragEnd}
style={{
...dragAnchorStyle(active.text_align_x, active.text_align_y, { x: 50, y: 50 }),
touchAction: 'none',
}}
className={`absolute max-w-[85%] select-none whitespace-nowrap rounded p-2 text-center transition-colors ${
dragging ? 'cursor-grabbing bg-white/10 ring-2 ring-brand-400' : 'cursor-grab hover:bg-white/10'
}`}
>
{previewEyebrow && (
<p className="truncate text-[10px] font-semibold uppercase tracking-wide text-brand-300">
{previewEyebrow}
</p>
)}
<p className="truncate text-sm font-extrabold text-white">{previewTitle}</p>
</div>
</div>
<p className="mt-1.5 text-center text-xs text-neutral-400">Zum Verschieben ziehen</p>
</div>
<div className="flex flex-col gap-3 sm:pt-1">
<p className="text-sm text-neutral-500 dark:text-neutral-400">
Position:{' '}
<span className="font-mono font-semibold text-neutral-700 dark:text-neutral-200">
{active.text_align_x}% / {active.text_align_y}%
</span>
</p>
<div>
<p className="mb-1.5 text-xs font-medium uppercase tracking-wide text-neutral-400">
Schnellauswahl waagerecht
</p>
<div className="flex flex-wrap gap-2">
<button type="button" onClick={() => updatePosition(0, active.text_align_y)} className="rounded-md border border-neutral-300 px-3 py-1.5 text-sm text-neutral-600 hover:bg-neutral-100 dark:border-neutral-700 dark:text-neutral-300 dark:hover:bg-neutral-800">
Links
</button>
<button type="button" onClick={() => updatePosition(50, active.text_align_y)} className="rounded-md border border-neutral-300 px-3 py-1.5 text-sm text-neutral-600 hover:bg-neutral-100 dark:border-neutral-700 dark:text-neutral-300 dark:hover:bg-neutral-800">
Mittig
</button>
<button type="button" onClick={() => updatePosition(100, active.text_align_y)} className="rounded-md border border-neutral-300 px-3 py-1.5 text-sm text-neutral-600 hover:bg-neutral-100 dark:border-neutral-700 dark:text-neutral-300 dark:hover:bg-neutral-800">
Rechts
</button>
</div>
</div>
<div>
<p className="mb-1.5 text-xs font-medium uppercase tracking-wide text-neutral-400">
Schnellauswahl senkrecht
</p>
<div className="flex flex-wrap gap-2">
<button type="button" onClick={() => updatePosition(active.text_align_x, 0)} className="rounded-md border border-neutral-300 px-3 py-1.5 text-sm text-neutral-600 hover:bg-neutral-100 dark:border-neutral-700 dark:text-neutral-300 dark:hover:bg-neutral-800">
Oben
</button>
<button type="button" onClick={() => updatePosition(active.text_align_x, 50)} className="rounded-md border border-neutral-300 px-3 py-1.5 text-sm text-neutral-600 hover:bg-neutral-100 dark:border-neutral-700 dark:text-neutral-300 dark:hover:bg-neutral-800">
Mittig
</button>
<button type="button" onClick={() => updatePosition(active.text_align_x, 100)} className="rounded-md border border-neutral-300 px-3 py-1.5 text-sm text-neutral-600 hover:bg-neutral-100 dark:border-neutral-700 dark:text-neutral-300 dark:hover:bg-neutral-800">
Unten
</button>
</div>
</div>
</div>
</div>
) : (
<div className="mb-5 grid gap-4 border-b border-neutral-200 pb-5 dark:border-neutral-800 sm:grid-cols-[10rem_1fr] sm:items-center">
<div className="aspect-square rounded-xl bg-neutral-100 dark:bg-neutral-800" aria-hidden />
<div>
<div className={`rounded-lg border border-neutral-200 p-3 dark:border-neutral-700 ${ALIGN_OPTIONS_TEXT[active.text_align] || 'text-left'}`}>
{previewEyebrow && (
<p className="mb-1 text-xs font-semibold uppercase tracking-wide text-brand-600 dark:text-brand-400">
{previewEyebrow}
</p>
)}
<p className="mb-1 font-bold text-neutral-900 dark:text-white">{previewTitle}</p>
<p className="line-clamp-2 text-xs text-neutral-500 dark:text-neutral-400">
{previewBody || 'Text erscheint hier…'}
</p>
</div>
<div className="mt-2 flex flex-wrap gap-2">
{ALIGN_OPTIONS.map((opt) => (
<button
key={opt.value}
type="button"
onClick={() => update('text_align', opt.value)}
className={`rounded-md border px-3 py-1.5 text-sm font-medium transition ${
active.text_align === opt.value
? 'border-brand-500 bg-brand-500 text-white'
: 'border-neutral-300 text-neutral-600 hover:bg-neutral-100 dark:border-neutral-700 dark:text-neutral-300 dark:hover:bg-neutral-800'
}`}
>
{opt.label}
</button>
))} ))}
</select>
</div> </div>
</div> </div>
</div>
)}
<div className="space-y-3"> <div className="space-y-3">
<div> <div>

View file

@ -1,7 +1,7 @@
import { useEffect, useRef, useState } from 'react'; import { useEffect, useRef, useState } from 'react';
import { api } from '../../../api/client.js'; import { api } from '../../../api/client.js';
import ImageUploadField from '../../../components/ImageUploadField.jsx'; import ImageUploadField from '../../../components/ImageUploadField.jsx';
import { galleryCardLabelStyle } from '../../../utils/galleryCardAlign.js'; import { dragAnchorStyle } from '../../../utils/dragAnchorPosition.js';
const DAYS = [ const DAYS = [
{ key: 'mon', label: 'Montag' }, { key: 'mon', label: 'Montag' },
@ -486,7 +486,7 @@ export default function WebsiteSettings() {
onPointerDown={handleGalleryDragStart} onPointerDown={handleGalleryDragStart}
onPointerMove={handleGalleryDragMove} onPointerMove={handleGalleryDragMove}
onPointerUp={handleGalleryDragEnd} onPointerUp={handleGalleryDragEnd}
style={{ ...galleryCardLabelStyle(form.gallery_card_text_x, form.gallery_card_text_y), touchAction: 'none' }} style={{ ...dragAnchorStyle(form.gallery_card_text_x, form.gallery_card_text_y, { x: 0, y: 100 }), touchAction: 'none' }}
className={`absolute select-none whitespace-nowrap rounded p-3 text-sm font-extrabold text-white transition-colors ${ className={`absolute select-none whitespace-nowrap rounded p-3 text-sm font-extrabold text-white transition-colors ${
galleryDragging ? 'cursor-grabbing bg-white/10 ring-2 ring-brand-400' : 'cursor-grab hover:bg-white/10' galleryDragging ? 'cursor-grabbing bg-white/10 ring-2 ring-brand-400' : 'cursor-grab hover:bg-white/10'
}`} }`}

View file

@ -4,7 +4,7 @@ import { api } from '../../api/client.js';
import usePageMeta from '../../hooks/usePageMeta.js'; import usePageMeta from '../../hooks/usePageMeta.js';
import { useLanguage } from '../../context/LanguageContext.jsx'; import { useLanguage } from '../../context/LanguageContext.jsx';
import { useSiteSettings } from '../../context/SiteSettingsContext.jsx'; import { useSiteSettings } from '../../context/SiteSettingsContext.jsx';
import { galleryCardLabelStyle } from '../../utils/galleryCardAlign.js'; import { dragAnchorStyle } from '../../utils/dragAnchorPosition.js';
export default function GalleryBrandPage() { export default function GalleryBrandPage() {
const { brandSlug } = useParams(); const { brandSlug } = useParams();
@ -63,7 +63,7 @@ export default function GalleryBrandPage() {
<div className="absolute inset-0 bg-gradient-to-t from-black/85 via-black/10 to-transparent transition group-hover:from-black/95" /> <div className="absolute inset-0 bg-gradient-to-t from-black/85 via-black/10 to-transparent transition group-hover:from-black/95" />
<span <span
className="absolute whitespace-nowrap p-4 text-lg font-extrabold text-white" className="absolute whitespace-nowrap p-4 text-lg font-extrabold text-white"
style={galleryCardLabelStyle(cardTextX, cardTextY)} style={dragAnchorStyle(cardTextX, cardTextY, { x: 0, y: 100 })}
> >
{project.name} {project.name}
</span> </span>

View file

@ -4,7 +4,7 @@ import { api } from '../../api/client.js';
import usePageMeta from '../../hooks/usePageMeta.js'; import usePageMeta from '../../hooks/usePageMeta.js';
import { useLanguage } from '../../context/LanguageContext.jsx'; import { useLanguage } from '../../context/LanguageContext.jsx';
import { useSiteSettings } from '../../context/SiteSettingsContext.jsx'; import { useSiteSettings } from '../../context/SiteSettingsContext.jsx';
import { galleryCardLabelStyle } from '../../utils/galleryCardAlign.js'; import { dragAnchorStyle } from '../../utils/dragAnchorPosition.js';
export default function GalleryOverview() { export default function GalleryOverview() {
const [brands, setBrands] = useState(null); const [brands, setBrands] = useState(null);
@ -54,7 +54,7 @@ export default function GalleryOverview() {
<div className="absolute inset-0 bg-gradient-to-t from-black/85 via-black/10 to-transparent transition group-hover:from-black/95" /> <div className="absolute inset-0 bg-gradient-to-t from-black/85 via-black/10 to-transparent transition group-hover:from-black/95" />
<span <span
className="absolute whitespace-nowrap p-4 text-lg font-extrabold text-white" className="absolute whitespace-nowrap p-4 text-lg font-extrabold text-white"
style={galleryCardLabelStyle(cardTextX, cardTextY)} style={dragAnchorStyle(cardTextX, cardTextY, { x: 0, y: 100 })}
> >
{brand.name} {brand.name}
</span> </span>

View file

@ -9,6 +9,7 @@ import StarRating from '../../components/StarRating.jsx';
import TestimonialSlider from '../../components/TestimonialSlider.jsx'; import TestimonialSlider from '../../components/TestimonialSlider.jsx';
import { useSiteSettings } from '../../context/SiteSettingsContext.jsx'; import { useSiteSettings } from '../../context/SiteSettingsContext.jsx';
import { useLanguage } from '../../context/LanguageContext.jsx'; import { useLanguage } from '../../context/LanguageContext.jsx';
import { dragAnchorStyle } from '../../utils/dragAnchorPosition.js';
import defaultHeroImage from '../../assets/photos/gallery-dash2.webp'; import defaultHeroImage from '../../assets/photos/gallery-dash2.webp';
import galleryAmp from '../../assets/photos/gallery-amp-purple.webp'; import galleryAmp from '../../assets/photos/gallery-amp-purple.webp';
import gallerySpeaker from '../../assets/photos/gallery-speaker.webp'; import gallerySpeaker from '../../assets/photos/gallery-speaker.webp';
@ -26,13 +27,12 @@ const brands = ['Ground Zero Audio', 'Audison', 'Hertz', 'Helix', 'Brax', 'Glade
// erkannt und aus dem Production-CSS herausgefiltert. Deshalb feste Lookup-Tabellen statt // erkannt und aus dem Production-CSS herausgefiltert. Deshalb feste Lookup-Tabellen statt
// Template-Strings, angesteuert ueber home_sections.text_align (siehe HomeSectionController). // Template-Strings, angesteuert ueber home_sections.text_align (siehe HomeSectionController).
const ALIGN_TEXT = { left: 'text-left', center: 'text-center', right: 'text-right' }; const ALIGN_TEXT = { left: 'text-left', center: 'text-center', right: 'text-right' };
const ALIGN_ITEMS = { left: 'items-start', center: 'items-center', right: 'items-end' };
const ALIGN_JUSTIFY = { left: 'justify-start', center: 'justify-center', right: 'justify-end' };
const ALIGN_MARGIN_X = { left: '', center: 'mx-auto', right: 'ml-auto' }; const ALIGN_MARGIN_X = { left: '', center: 'mx-auto', right: 'ml-auto' };
const EMPTY_SECTION = { const EMPTY_SECTION = {
eyebrow_de: '', eyebrow_en: '', title_de: '', title_en: '', body_html_de: '', body_html_en: '', eyebrow_de: '', eyebrow_en: '', title_de: '', title_en: '', body_html_de: '', body_html_en: '',
text_align: 'center', button_label_de: '', button_label_en: '', button_url: '', text_align: 'center', text_align_x: 50, text_align_y: 50,
button_label_de: '', button_label_en: '', button_url: '',
}; };
/** Rendert nur, wenn sowohl Beschriftung als auch Ziel gesetzt sind - interne Ziele (mit "/") /** Rendert nur, wenn sowohl Beschriftung als auch Ziel gesetzt sind - interne Ziele (mit "/")
@ -84,6 +84,9 @@ export default function Home() {
title: s[`title_${language}`] || '', title: s[`title_${language}`] || '',
bodyHtml: s[`body_html_${language}`] || '', bodyHtml: s[`body_html_${language}`] || '',
align: s.text_align || 'center', align: s.text_align || 'center',
// Nur fuer hero/youtube genutzt (echter Hintergrund) - siehe dragAnchorStyle-Aufrufe unten.
alignX: s.text_align_x,
alignY: s.text_align_y,
buttonLabel: s[`button_label_${language}`] || '', buttonLabel: s[`button_label_${language}`] || '',
buttonUrl: s.button_url || '', buttonUrl: s.button_url || '',
}; };
@ -198,9 +201,13 @@ export default function Home() {
/> />
<div className="absolute inset-0 bg-gradient-to-t from-neutral-950 via-neutral-950/80 to-neutral-950/40" /> <div className="absolute inset-0 bg-gradient-to-t from-neutral-950 via-neutral-950/80 to-neutral-950/40" />
<motion.div <motion.div style={{ y: heroTextY, opacity: heroOpacity }} className="absolute inset-0">
style={{ y: heroTextY, opacity: heroOpacity }} {/* Reine Positionierungs-Ebene (kein motion.div - siehe Kommentar bei dragAnchorPosition.js:
className={`relative flex h-full max-w-6xl flex-col ${ALIGN_ITEMS[section('hero').align]} justify-center px-4 mx-auto ${ALIGN_TEXT[section('hero').align]} sm:px-6`} das eigene Scroll-Transform von framer-motion oben und die Eintritts-Animation unten
sollen sich nicht mit dieser statischen, per Drag gesetzten Position ueberschneiden). */}
<div
className="absolute w-full max-w-2xl px-4 text-center sm:px-6"
style={dragAnchorStyle(section('hero').alignX, section('hero').alignY, { x: 50, y: 50 })}
> >
<motion.div <motion.div
initial={{ opacity: 0, y: 20 }} initial={{ opacity: 0, y: 20 }}
@ -216,10 +223,10 @@ export default function Home() {
{section('hero').title} {section('hero').title}
</h1> </h1>
<div <div
className={`legal-content mt-4 max-w-2xl text-base text-neutral-200 sm:text-lg ${ALIGN_MARGIN_X[section('hero').align]}`} className="legal-content mx-auto mt-4 max-w-2xl text-base text-neutral-200 sm:text-lg"
dangerouslySetInnerHTML={{ __html: section('hero').bodyHtml }} dangerouslySetInnerHTML={{ __html: section('hero').bodyHtml }}
/> />
<div className={`mt-8 flex flex-wrap items-center ${ALIGN_JUSTIFY[section('hero').align]} gap-3`}> <div className="mt-8 flex flex-wrap items-center justify-center gap-3">
<Link <Link
to="/fahrzeuge" to="/fahrzeuge"
className="rounded-md bg-brand-500 px-6 py-3 text-sm font-semibold text-white shadow-sm transition hover:-translate-y-0.5 hover:bg-brand-600 hover:shadow-lg" className="rounded-md bg-brand-500 px-6 py-3 text-sm font-semibold text-white shadow-sm transition hover:-translate-y-0.5 hover:bg-brand-600 hover:shadow-lg"
@ -234,6 +241,7 @@ export default function Home() {
</Link> </Link>
</div> </div>
</motion.div> </motion.div>
</div>
</motion.div> </motion.div>
</section> </section>
@ -263,7 +271,7 @@ export default function Home() {
</div> </div>
</section> </section>
<section className="relative flex min-h-[70vh] items-center justify-center overflow-hidden sm:min-h-[85vh]"> <section className="relative min-h-[70vh] overflow-hidden sm:min-h-[85vh]">
<video <video
autoPlay autoPlay
loop loop
@ -276,7 +284,11 @@ export default function Home() {
</video> </video>
<div className="absolute inset-0 bg-black/55" /> <div className="absolute inset-0 bg-black/55" />
<Reveal className={`relative mx-auto max-w-3xl px-4 ${ALIGN_TEXT[section('youtube').align]} sm:px-6`}> <div
className="absolute w-full max-w-3xl px-4 text-center sm:px-6"
style={dragAnchorStyle(section('youtube').alignX, section('youtube').alignY, { x: 50, y: 50 })}
>
<Reveal>
{section('youtube').eyebrow && ( {section('youtube').eyebrow && (
<p className="mb-4 text-xs font-semibold uppercase tracking-[0.2em] text-neutral-200 sm:text-sm"> <p className="mb-4 text-xs font-semibold uppercase tracking-[0.2em] text-neutral-200 sm:text-sm">
{section('youtube').eyebrow} {section('youtube').eyebrow}
@ -295,6 +307,7 @@ export default function Home() {
className="mt-8 inline-flex items-center justify-center rounded-full bg-white px-8 py-3 text-xs font-bold uppercase tracking-wide text-neutral-900 transition hover:-translate-y-0.5 hover:bg-neutral-100" className="mt-8 inline-flex items-center justify-center rounded-full bg-white px-8 py-3 text-xs font-bold uppercase tracking-wide text-neutral-900 transition hover:-translate-y-0.5 hover:bg-neutral-100"
/> />
</Reveal> </Reveal>
</div>
</section> </section>
<section className="grain-band border-y border-neutral-200 bg-neutral-50 py-16 dark:border-neutral-800 dark:bg-neutral-900/40"> <section className="grain-band border-y border-neutral-200 bg-neutral-50 py-16 dark:border-neutral-800 dark:bg-neutral-900/40">

View file

@ -0,0 +1,22 @@
// Frei per Drag & Drop setzbare 2D-Position eines ueberlagerten Elements (Bildergalerie-
// Kachel-Namen, siehe GalleryOverview.jsx/GalleryBrandPage.jsx; Home.jsx-Hero/YouTube-Text,
// siehe Home.jsx) - je 0-100 pro Achse, per Drag in der jeweiligen Live-Vorschau gesetzt
// (WebsiteSettings.jsx bzw. HomeSections.jsx).
//
// `left: X%` + `translateX(-X%)` (und analog `top`/`translateY` fuer die Y-Achse) ist der
// Standard-CSS-Trick, um einen einzigen Prozentwert stufenlos zwischen einer Kante (0%,
// Element faengt dort an) und der gegenueberliegenden Kante (100%, Element endet dort, da es
// um seine volle Breite/Hoehe zurueckgeschoben wird) zu interpolieren - bei 50% landet die
// Element-Mitte in der Mitte des umgebenden Kastens. Deshalb eine echte Inline-Style-
// Berechnung statt einer festen Tailwind-Klasse (anders als z.B. bei den Home.jsx-Abschnitten
// ohne eigenen Hintergrund, wo drei feste text-align-Werte genuegen, siehe Home.jsx/
// HomeSections.jsx ALIGN_TEXT).
export function dragAnchorStyle(xPercent, yPercent, defaults = { x: 0, y: 0 }) {
const x = Math.max(0, Math.min(100, xPercent == null ? defaults.x : Number(xPercent) || 0));
const y = Math.max(0, Math.min(100, yPercent == null ? defaults.y : Number(yPercent) || 0));
return {
left: `${x}%`,
top: `${y}%`,
transform: `translate(-${x}%, -${y}%)`,
};
}

View file

@ -1,22 +0,0 @@
// Position des Marken-/Projekt-Namens auf den Bildergalerie-Kacheln
// (app_settings.gallery_card_text_x/_y, je 0-100, siehe SiteSettingsController.php) - per
// Drag & Drop in der Live-Vorschau gesetzt (WebsiteSettings.jsx), genutzt von
// GalleryOverview.jsx und GalleryBrandPage.jsx.
//
// `left: X%` + `translateX(-X%)` (und analog `top`/`translateY` fuer die Y-Achse) ist der
// Standard-CSS-Trick, um einen einzigen Prozentwert stufenlos zwischen einer Kante (0%,
// Element faengt dort an) und der gegenueberliegenden Kante (100%, Element endet dort, da es
// um seine volle Breite/Hoehe zurueckgeschoben wird) zu interpolieren - bei 50% landet die
// Textmitte in der Kachelmitte. Deshalb eine echte Inline-Style-Berechnung statt einer festen
// Tailwind-Klasse (anders als z.B. bei den Home.jsx-Abschnitten, wo drei feste Werte genuegen).
export function galleryCardLabelStyle(xPercent, yPercent) {
const x = Math.max(0, Math.min(100, Number(xPercent) || 0));
// Ohne expliziten Wert (aeltere/noch nicht geladene Einstellungen) faellt Y auf 100 (unten)
// zurueck - entspricht der urspruenglichen, immer unten fixierten Position.
const y = Math.max(0, Math.min(100, yPercent == null ? 100 : Number(yPercent) || 0));
return {
left: `${x}%`,
top: `${y}%`,
transform: `translate(-${x}%, -${y}%)`,
};
}

View file

@ -0,0 +1,20 @@
USE hifi_shop;
-- Freie 2D-Drag-Position (wie schon bei den Bildergalerie-Kacheln, siehe
-- migration_gallery_card_drag.sql/migration_gallery_card_y.sql) fuer die zwei
-- Startseiten-Abschnitte mit echtem Hintergrund (Hero-Bild, YouTube-Video): 0-100 je
-- Achse, Standard 50/50 = mittig (entspricht der bisherigen, immer zentrierten Position -
-- keine optische Aenderung, solange niemand daran zieht).
--
-- Bleibt bewusst NEBEN der bestehenden text_align-Spalte bestehen (nicht ersetzt): die
-- anderen vier Abschnitte (Handwerk, Beratung, Einblicke, "Mehr als Car-Hifi") sind
-- normaler, neben einem Bild fließender Text ohne eigenen Hintergrund - dort ist
-- links/mittig/rechts (text-align auf ganzen, umgebrochenen Absaetzen) das richtige
-- Konzept, keine frei ziehbare Position wie bei einem einzelnen ueberlagerten Label.
-- Additiv, nichts wird geloescht.
-- Hinweis: Auf der Live-Seite reicht stattdessen ein Klick auf "Datenbankstruktur aktualisieren"
-- unter Admin-Panel -> Einstellungen -> Datenbank.
ALTER TABLE home_sections
ADD COLUMN IF NOT EXISTS text_align_x TINYINT UNSIGNED NOT NULL DEFAULT 50 AFTER text_align,
ADD COLUMN IF NOT EXISTS text_align_y TINYINT UNSIGNED NOT NULL DEFAULT 50 AFTER text_align_x;

View file

@ -71,6 +71,8 @@ CREATE TABLE home_sections (
body_html_de TEXT NULL, body_html_de TEXT NULL,
body_html_en TEXT NULL, body_html_en TEXT NULL,
text_align ENUM('left','center','right') NOT NULL DEFAULT 'center', text_align ENUM('left','center','right') NOT NULL DEFAULT 'center',
text_align_x TINYINT UNSIGNED NOT NULL DEFAULT 50,
text_align_y TINYINT UNSIGNED NOT NULL DEFAULT 50,
button_label_de VARCHAR(100) NULL, button_label_de VARCHAR(100) NULL,
button_label_en VARCHAR(100) NULL, button_label_en VARCHAR(100) NULL,
button_url VARCHAR(500) NULL, button_url VARCHAR(500) NULL,

View file

@ -25,6 +25,7 @@ class HomeSectionController
'body_html_de' => '<p>Dein Car-Hifi Spezialist für individuelle Sound-Umbauten. Wähle dein Fahrzeug, entdecke passende Pakete und frag unverbindlich an – wir kümmern uns um den Rest.</p>', 'body_html_de' => '<p>Dein Car-Hifi Spezialist für individuelle Sound-Umbauten. Wähle dein Fahrzeug, entdecke passende Pakete und frag unverbindlich an – wir kümmern uns um den Rest.</p>',
'body_html_en' => '<p>Your car-hifi specialist for custom sound installations. Choose your vehicle, discover the right package and get in touch, no obligation – we take care of the rest.</p>', 'body_html_en' => '<p>Your car-hifi specialist for custom sound installations. Choose your vehicle, discover the right package and get in touch, no obligation – we take care of the rest.</p>',
'text_align' => 'center', 'text_align' => 'center',
'text_align_x' => 50, 'text_align_y' => 50,
'button_label_de' => null, 'button_label_en' => null, 'button_url' => null, 'button_label_de' => null, 'button_label_en' => null, 'button_url' => null,
], ],
'youtube' => [ 'youtube' => [
@ -33,6 +34,7 @@ class HomeSectionController
'body_html_de' => '<p>Entdecke die Handwerkskunst hinter unserer Arbeit</p>', 'body_html_de' => '<p>Entdecke die Handwerkskunst hinter unserer Arbeit</p>',
'body_html_en' => '<p>Discover the artistry behind our work</p>', 'body_html_en' => '<p>Discover the artistry behind our work</p>',
'text_align' => 'center', 'text_align' => 'center',
'text_align_x' => 50, 'text_align_y' => 50,
'button_label_de' => 'Jetzt ansehen', 'button_label_en' => 'Watch now', 'button_label_de' => 'Jetzt ansehen', 'button_label_en' => 'Watch now',
'button_url' => 'https://www.youtube.com/watch?v=ostj2mKDVUc', 'button_url' => 'https://www.youtube.com/watch?v=ostj2mKDVUc',
], ],
@ -42,6 +44,7 @@ class HomeSectionController
'body_html_de' => '<p>Ob eigens gefertigte Subwoofer-Gehäuse, integrierte Beleuchtung oder unsichtbar verlegte Kabelwege – dank eigener CNC-, Laser- und 3D-Druck-Fertigung entstehen bei uns Lösungen, die es von der Stange nicht gibt.</p>', 'body_html_de' => '<p>Ob eigens gefertigte Subwoofer-Gehäuse, integrierte Beleuchtung oder unsichtbar verlegte Kabelwege – dank eigener CNC-, Laser- und 3D-Druck-Fertigung entstehen bei uns Lösungen, die es von der Stange nicht gibt.</p>',
'body_html_en' => '<p>Whether custom-built subwoofer enclosures, integrated lighting or invisibly routed cabling – our own CNC, laser and 3D-printing production means we can build solutions you simply can\'t buy off the shelf.</p>', 'body_html_en' => '<p>Whether custom-built subwoofer enclosures, integrated lighting or invisibly routed cabling – our own CNC, laser and 3D-printing production means we can build solutions you simply can\'t buy off the shelf.</p>',
'text_align' => 'left', 'text_align' => 'left',
'text_align_x' => 50, 'text_align_y' => 50,
'button_label_de' => null, 'button_label_en' => null, 'button_url' => null, 'button_label_de' => null, 'button_label_en' => null, 'button_url' => null,
], ],
'advice' => [ 'advice' => [
@ -50,6 +53,7 @@ class HomeSectionController
'body_html_de' => '<p>Jedes Fahrzeug und jeder Anspruch ist anders. Deshalb beraten wir dich persönlich und unverbindlich – vom dezenten Upgrade bis zum kompromisslosen High-End-System.</p>', 'body_html_de' => '<p>Jedes Fahrzeug und jeder Anspruch ist anders. Deshalb beraten wir dich persönlich und unverbindlich – vom dezenten Upgrade bis zum kompromisslosen High-End-System.</p>',
'body_html_en' => '<p>Every vehicle and every requirement is different. That\'s why we advise you personally and without obligation – from a subtle upgrade to an uncompromising high-end system.</p>', 'body_html_en' => '<p>Every vehicle and every requirement is different. That\'s why we advise you personally and without obligation – from a subtle upgrade to an uncompromising high-end system.</p>',
'text_align' => 'left', 'text_align' => 'left',
'text_align_x' => 50, 'text_align_y' => 50,
'button_label_de' => null, 'button_label_en' => null, 'button_url' => null, 'button_label_de' => null, 'button_label_en' => null, 'button_url' => null,
], ],
'insights' => [ 'insights' => [
@ -58,6 +62,7 @@ class HomeSectionController
'body_html_de' => '<p>Vom unauffälligen Sound-Upgrade bis zum aufwendigen Komplettumbau – Handarbeit aus unserer Werkstatt in Amorbach.</p>', 'body_html_de' => '<p>Vom unauffälligen Sound-Upgrade bis zum aufwendigen Komplettumbau – Handarbeit aus unserer Werkstatt in Amorbach.</p>',
'body_html_en' => '<p>From subtle sound upgrades to elaborate full installations – handcrafted in our workshop in Amorbach.</p>', 'body_html_en' => '<p>From subtle sound upgrades to elaborate full installations – handcrafted in our workshop in Amorbach.</p>',
'text_align' => 'center', 'text_align' => 'center',
'text_align_x' => 50, 'text_align_y' => 50,
'button_label_de' => null, 'button_label_en' => null, 'button_url' => null, 'button_label_de' => null, 'button_label_en' => null, 'button_url' => null,
], ],
'more' => [ 'more' => [
@ -66,6 +71,7 @@ class HomeSectionController
'body_html_de' => '<p>Neben individuellen Sound-Umbauten bieten wir CNC-Zerspanung, Lasertechnik, 3D-Druck und mehr – alles aus einer Hand in unserer eigenen Werkstatt.</p>', 'body_html_de' => '<p>Neben individuellen Sound-Umbauten bieten wir CNC-Zerspanung, Lasertechnik, 3D-Druck und mehr – alles aus einer Hand in unserer eigenen Werkstatt.</p>',
'body_html_en' => '<p>Besides custom sound installations, we also offer CNC machining, laser technology, 3D printing and more – all from a single source in our own workshop.</p>', 'body_html_en' => '<p>Besides custom sound installations, we also offer CNC machining, laser technology, 3D printing and more – all from a single source in our own workshop.</p>',
'text_align' => 'left', 'text_align' => 'left',
'text_align_x' => 50, 'text_align_y' => 50,
'button_label_de' => 'Alle Leistungen entdecken', 'button_label_en' => 'Discover all our services', 'button_label_de' => 'Alle Leistungen entdecken', 'button_label_en' => 'Discover all our services',
'button_url' => '/leistungen', 'button_url' => '/leistungen',
], ],
@ -73,7 +79,7 @@ class HomeSectionController
private const COLUMNS = [ private const COLUMNS = [
'eyebrow_de', 'eyebrow_en', 'title_de', 'title_en', 'body_html_de', 'body_html_en', 'eyebrow_de', 'eyebrow_en', 'title_de', 'title_en', 'body_html_de', 'body_html_en',
'text_align', 'button_label_de', 'button_label_en', 'button_url', 'text_align', 'text_align_x', 'text_align_y', 'button_label_de', 'button_label_en', 'button_url',
]; ];
/** Oeffentlich + Admin: alle Abschnitte auf einmal (DB-Stand oder Standardtext). */ /** Oeffentlich + Admin: alle Abschnitte auf einmal (DB-Stand oder Standardtext). */
@ -103,6 +109,10 @@ class HomeSectionController
if (!in_array($align, ['left', 'center', 'right'], true)) { if (!in_array($align, ['left', 'center', 'right'], true)) {
$align = 'center'; $align = 'center';
} }
// Nur fuer hero/youtube genutzt (echter Hintergrund, siehe Home.jsx) - per Drag & Drop
// in der Live-Vorschau gesetzt (HomeSections.jsx), auf 0-100 geklammert.
$alignX = max(0, min(100, (int) ($body['text_align_x'] ?? 50)));
$alignY = max(0, min(100, (int) ($body['text_align_y'] ?? 50)));
$values = [ $values = [
'eyebrow_de' => trim($body['eyebrow_de'] ?? '') ?: null, 'eyebrow_de' => trim($body['eyebrow_de'] ?? '') ?: null,
@ -112,6 +122,8 @@ class HomeSectionController
'body_html_de' => (string) ($body['body_html_de'] ?? ''), 'body_html_de' => (string) ($body['body_html_de'] ?? ''),
'body_html_en' => (string) ($body['body_html_en'] ?? ''), 'body_html_en' => (string) ($body['body_html_en'] ?? ''),
'text_align' => $align, 'text_align' => $align,
'text_align_x' => $alignX,
'text_align_y' => $alignY,
'button_label_de' => trim($body['button_label_de'] ?? '') ?: null, 'button_label_de' => trim($body['button_label_de'] ?? '') ?: null,
'button_label_en' => trim($body['button_label_en'] ?? '') ?: null, 'button_label_en' => trim($body['button_label_en'] ?? '') ?: null,
'button_url' => trim($body['button_url'] ?? '') ?: null, 'button_url' => trim($body['button_url'] ?? '') ?: null,

View file

@ -51,7 +51,7 @@ class SettingsController
'legal_pages' => ['id', 'slug', 'title', 'body_html', 'updated_at'], 'legal_pages' => ['id', 'slug', 'title', 'body_html', 'updated_at'],
'home_sections' => [ 'home_sections' => [
'id', 'slug', 'eyebrow_de', 'eyebrow_en', 'title_de', 'title_en', 'id', 'slug', 'eyebrow_de', 'eyebrow_en', 'title_de', 'title_en',
'body_html_de', 'body_html_en', 'text_align', 'body_html_de', 'body_html_en', 'text_align', 'text_align_x', 'text_align_y',
'button_label_de', 'button_label_en', 'button_url', 'updated_at', 'button_label_de', 'button_label_en', 'button_url', 'updated_at',
], ],
]; ];

View file

@ -97,6 +97,8 @@ class Schema
body_html_de TEXT NULL, body_html_de TEXT NULL,
body_html_en TEXT NULL, body_html_en TEXT NULL,
text_align ENUM('left','center','right') NOT NULL DEFAULT 'center', text_align ENUM('left','center','right') NOT NULL DEFAULT 'center',
text_align_x TINYINT UNSIGNED NOT NULL DEFAULT 50,
text_align_y TINYINT UNSIGNED NOT NULL DEFAULT 50,
button_label_de VARCHAR(100) NULL, button_label_de VARCHAR(100) NULL,
button_label_en VARCHAR(100) NULL, button_label_en VARCHAR(100) NULL,
button_url VARCHAR(500) NULL, button_url VARCHAR(500) NULL,
@ -379,6 +381,8 @@ class Schema
'body_html_de' => 'TEXT NULL', 'body_html_de' => 'TEXT NULL',
'body_html_en' => 'TEXT NULL', 'body_html_en' => 'TEXT NULL',
'text_align' => "ENUM('left','center','right') NOT NULL DEFAULT 'center'", 'text_align' => "ENUM('left','center','right') NOT NULL DEFAULT 'center'",
'text_align_x' => 'TINYINT UNSIGNED NOT NULL DEFAULT 50',
'text_align_y' => 'TINYINT UNSIGNED NOT NULL DEFAULT 50',
'button_label_de' => 'VARCHAR(100) NULL', 'button_label_de' => 'VARCHAR(100) NULL',
'button_label_en' => 'VARCHAR(100) NULL', 'button_label_en' => 'VARCHAR(100) NULL',
'button_url' => 'VARCHAR(500) NULL', 'button_url' => 'VARCHAR(500) NULL',

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -43,9 +43,9 @@
"sameAs": ["https://www.youtube.com/@hifiplanet2812"] "sameAs": ["https://www.youtube.com/@hifiplanet2812"]
} }
</script> </script>
<script type="module" crossorigin src="/assets/index-BPvbL8M7.js"></script> <script type="module" crossorigin src="/assets/index-B_Zex33k.js"></script>
<link rel="modulepreload" crossorigin href="/assets/lucide-icons-Cg2IxtAO.js"> <link rel="modulepreload" crossorigin href="/assets/lucide-icons-Cg2IxtAO.js">
<link rel="stylesheet" crossorigin href="/assets/index-CxsdIqOv.css"> <link rel="stylesheet" crossorigin href="/assets/index-B1rtregG.css">
</head> </head>
<body class="bg-white text-slate-900 dark:bg-slate-950 dark:text-slate-100"> <body class="bg-white text-slate-900 dark:bg-slate-950 dark:text-slate-100">
<div id="root"></div> <div id="root"></div>