HifiPlanet-Website/hifi/api/database/migration_home_sections_position.sql
Maaxxs 1b60b71ecd 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>
2026-09-09 03:42:17 +02:00

20 lines
1.2 KiB
SQL

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;