Make gallery card name label alignment configurable with a live preview
The brand/project name overlaid on gallery cards (GalleryOverview.jsx and the identical pattern in GalleryBrandPage.jsx) was always left- aligned with no way to change it - flagged against the brand-overview page specifically, but the same hard-coded markup exists on the brand detail page's project cards too, so both get the fix together as one setting rather than two. New app_settings.gallery_card_text_align (left/center/right, default left - no visual change until an admin picks something else), same site-wide-design-setting pattern as the existing package_card_theme/ package_card_layout. New "Bildergalerie-Kacheln" section in Website settings renders an actual live preview card - using a real uploaded gallery image and brand name when one exists, not just a placeholder - that updates immediately when a button is clicked, rather than a free-drag positioner: cheaper to build reliably and keeps the label inside the three positions the design's bottom gradient overlay is actually built to support. New shared hifi-src/src/utils/galleryCardAlign.js provides the class lookup both public pages and the admin preview use - a fixed map rather than a template-string class name, same reasoning as the Home.jsx section alignment work: Tailwind's build-time scanner needs literal class names in the source or it purges them from the production CSS. Verified against the local database directly via PHP CLI: the new column backfilled to 'left' on the existing app_settings row, and SiteSettingsController::show() returns it correctly. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
parent
ba4fa986d3
commit
142f9adb05
16 changed files with 346 additions and 239 deletions
|
|
@ -44,6 +44,7 @@ const DEFAULT_SITE_SETTINGS = {
|
|||
package_card_theme: 'graphite',
|
||||
package_card_layout: 'strip',
|
||||
package_wheel_hint_interval: 8,
|
||||
gallery_card_text_align: 'left',
|
||||
};
|
||||
|
||||
// Das Impressum (und die anderen rechtlichen Pflichtseiten) müssen laut § 5 DDG
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ const SiteSettingsContext = createContext({
|
|||
business_hours: null,
|
||||
hero_image_path: null,
|
||||
ga_measurement_id: null,
|
||||
gallery_card_text_align: 'left',
|
||||
});
|
||||
|
||||
export const SiteSettingsProvider = SiteSettingsContext.Provider;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import { useEffect, useState } from 'react';
|
||||
import { api } from '../../../api/client.js';
|
||||
import ImageUploadField from '../../../components/ImageUploadField.jsx';
|
||||
import { GALLERY_CARD_ALIGN } from '../../../utils/galleryCardAlign.js';
|
||||
|
||||
const DAYS = [
|
||||
{ key: 'mon', label: 'Montag' },
|
||||
|
|
@ -31,8 +32,15 @@ const emptyForm = {
|
|||
package_card_theme: 'graphite',
|
||||
package_card_layout: 'strip',
|
||||
package_wheel_hint_interval: 8,
|
||||
gallery_card_text_align: 'left',
|
||||
};
|
||||
|
||||
const GALLERY_CARD_ALIGN_OPTIONS = [
|
||||
{ value: 'left', label: 'Links' },
|
||||
{ value: 'center', label: 'Mittig' },
|
||||
{ value: 'right', label: 'Rechts' },
|
||||
];
|
||||
|
||||
const PACKAGE_CARD_THEMES = [
|
||||
{ value: 'graphite', label: 'Graphite Green', description: 'Graphit über Bronze/Silber/Gold/Platin bis zur Onyx-Krönung.' },
|
||||
{ value: 'deep-blue', label: 'Deep Blue Luxury', description: 'Kühles Blau, das sich über Grün zu Gold erwärmt.' },
|
||||
|
|
@ -51,6 +59,9 @@ export default function WebsiteSettings() {
|
|||
const [busy, setBusy] = useState(false);
|
||||
const [saved, setSaved] = useState(false);
|
||||
const [error, setError] = useState('');
|
||||
// Fuer die Live-Vorschau der Bildergalerie-Kachel-Ausrichtung - eine echte, bereits
|
||||
// hochgeladene Marke (falls vorhanden), damit die Vorschau zeigt, wie es wirklich aussieht.
|
||||
const [previewBrand, setPreviewBrand] = useState(null);
|
||||
|
||||
const [gaPropertyId, setGaPropertyId] = useState('');
|
||||
const [gaServiceAccountJson, setGaServiceAccountJson] = useState('');
|
||||
|
|
@ -87,9 +98,14 @@ export default function WebsiteSettings() {
|
|||
package_card_theme: res.package_card_theme || 'graphite',
|
||||
package_card_layout: res.package_card_layout || 'strip',
|
||||
package_wheel_hint_interval: res.package_wheel_hint_interval || 8,
|
||||
gallery_card_text_align: res.gallery_card_text_align || 'left',
|
||||
})
|
||||
)
|
||||
.finally(() => setLoading(false));
|
||||
api
|
||||
.get('/gallery-brands')
|
||||
.then((rows) => setPreviewBrand(rows.find((b) => b.cover_image_path) || null))
|
||||
.catch(() => {});
|
||||
api.get('/settings/analytics').then((res) => {
|
||||
setGaPropertyId(res.ga_property_id || '');
|
||||
setGaHasCredentials(res.has_credentials);
|
||||
|
|
@ -415,6 +431,48 @@ export default function WebsiteSettings() {
|
|||
</div>
|
||||
</section>
|
||||
|
||||
<section className="rounded-xl border border-neutral-200 bg-white p-6 dark:border-neutral-800 dark:bg-neutral-900">
|
||||
<h2 className="mb-1 font-semibold text-neutral-900 dark:text-white">Bildergalerie-Kacheln</h2>
|
||||
<p className="mb-4 text-sm text-neutral-500 dark:text-neutral-400">
|
||||
Ausrichtung des Marken-/Projekt-Namens auf den Kacheln der Bildergalerie-Übersicht und der
|
||||
Marken-Detailseite.
|
||||
</p>
|
||||
<div className="grid gap-4 sm:grid-cols-[auto_1fr] sm:items-start">
|
||||
<div className="w-40 shrink-0">
|
||||
<div className="relative aspect-[4/3] overflow-hidden rounded-xl bg-neutral-900 shadow-sm">
|
||||
{previewBrand ? (
|
||||
<img src={previewBrand.cover_image_path} alt="" className="h-full w-full object-cover" />
|
||||
) : (
|
||||
<div className="h-full w-full bg-gradient-to-br from-neutral-700 to-neutral-900" />
|
||||
)}
|
||||
<div className="absolute inset-0 bg-gradient-to-t from-black/85 via-black/10 to-transparent" />
|
||||
<span
|
||||
className={`absolute inset-x-0 bottom-0 p-3 text-sm font-extrabold text-white ${GALLERY_CARD_ALIGN[form.gallery_card_text_align] || GALLERY_CARD_ALIGN.left}`}
|
||||
>
|
||||
{previewBrand ? previewBrand.name : 'Beispiel-Marke'}
|
||||
</span>
|
||||
</div>
|
||||
<p className="mt-1.5 text-center text-xs text-neutral-400">Live-Vorschau</p>
|
||||
</div>
|
||||
<div className="flex flex-wrap gap-2 sm:pt-1">
|
||||
{GALLERY_CARD_ALIGN_OPTIONS.map((opt) => (
|
||||
<button
|
||||
key={opt.value}
|
||||
type="button"
|
||||
onClick={() => update('gallery_card_text_align', opt.value)}
|
||||
className={`rounded-md border px-4 py-2 text-sm font-medium transition ${
|
||||
form.gallery_card_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>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section className="rounded-xl border border-neutral-200 bg-white p-6 dark:border-neutral-800 dark:bg-neutral-900">
|
||||
<h2 className="mb-1 font-semibold text-neutral-900 dark:text-white">Google Analytics</h2>
|
||||
<p className="mb-4 text-sm text-neutral-500 dark:text-neutral-400">
|
||||
|
|
|
|||
|
|
@ -3,12 +3,15 @@ import { Link, useParams } from 'react-router-dom';
|
|||
import { api } from '../../api/client.js';
|
||||
import usePageMeta from '../../hooks/usePageMeta.js';
|
||||
import { useLanguage } from '../../context/LanguageContext.jsx';
|
||||
import { useSiteSettings } from '../../context/SiteSettingsContext.jsx';
|
||||
import { GALLERY_CARD_ALIGN } from '../../utils/galleryCardAlign.js';
|
||||
|
||||
export default function GalleryBrandPage() {
|
||||
const { brandSlug } = useParams();
|
||||
const [data, setData] = useState(null);
|
||||
const [error, setError] = useState('');
|
||||
const { t } = useLanguage();
|
||||
const { gallery_card_text_align: cardAlign } = useSiteSettings();
|
||||
|
||||
useEffect(() => {
|
||||
api.get(`/gallery-brands/${brandSlug}/projects`).then(setData).catch((e) => setError(e.message));
|
||||
|
|
@ -58,7 +61,9 @@ export default function GalleryBrandPage() {
|
|||
<div className="flex h-full w-full items-center justify-center bg-neutral-200 dark:bg-neutral-800" />
|
||||
)}
|
||||
<div className="absolute inset-0 bg-gradient-to-t from-black/85 via-black/10 to-transparent transition group-hover:from-black/95" />
|
||||
<span className="absolute inset-x-0 bottom-0 p-4 text-lg font-extrabold text-white">{project.name}</span>
|
||||
<span className={`absolute inset-x-0 bottom-0 p-4 text-lg font-extrabold text-white ${GALLERY_CARD_ALIGN[cardAlign] || GALLERY_CARD_ALIGN.left}`}>
|
||||
{project.name}
|
||||
</span>
|
||||
</Link>
|
||||
))}
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -3,11 +3,14 @@ import { Link } from 'react-router-dom';
|
|||
import { api } from '../../api/client.js';
|
||||
import usePageMeta from '../../hooks/usePageMeta.js';
|
||||
import { useLanguage } from '../../context/LanguageContext.jsx';
|
||||
import { useSiteSettings } from '../../context/SiteSettingsContext.jsx';
|
||||
import { GALLERY_CARD_ALIGN } from '../../utils/galleryCardAlign.js';
|
||||
|
||||
export default function GalleryOverview() {
|
||||
const [brands, setBrands] = useState(null);
|
||||
const [error, setError] = useState('');
|
||||
const { t } = useLanguage();
|
||||
const { gallery_card_text_align: cardAlign } = useSiteSettings();
|
||||
|
||||
usePageMeta({
|
||||
title: t('galleryOverview.metaTitle'),
|
||||
|
|
@ -49,7 +52,9 @@ export default function GalleryOverview() {
|
|||
<div className="flex h-full w-full items-center justify-center bg-neutral-200 dark:bg-neutral-800" />
|
||||
)}
|
||||
<div className="absolute inset-0 bg-gradient-to-t from-black/85 via-black/10 to-transparent transition group-hover:from-black/95" />
|
||||
<span className="absolute inset-x-0 bottom-0 p-4 text-lg font-extrabold text-white">{brand.name}</span>
|
||||
<span className={`absolute inset-x-0 bottom-0 p-4 text-lg font-extrabold text-white ${GALLERY_CARD_ALIGN[cardAlign] || GALLERY_CARD_ALIGN.left}`}>
|
||||
{brand.name}
|
||||
</span>
|
||||
</Link>
|
||||
))}
|
||||
</div>
|
||||
|
|
|
|||
14
hifi-src/src/utils/galleryCardAlign.js
Normal file
14
hifi-src/src/utils/galleryCardAlign.js
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
// Ausrichtung des Marken-/Projekt-Namens auf den Bildergalerie-Kacheln
|
||||
// (app_settings.gallery_card_text_align, siehe SiteSettingsController.php), genutzt von
|
||||
// GalleryOverview.jsx, GalleryBrandPage.jsx und der Live-Vorschau in WebsiteSettings.jsx.
|
||||
// Feste Lookup-Tabelle statt eines dynamisch zusammengesetzten `text-${align}`-Strings -
|
||||
// Tailwinds Build-Zeit-Scanner braucht die vollstaendigen Klassennamen woertlich im
|
||||
// Quellcode, sonst werden sie aus dem Production-CSS herausgefiltert.
|
||||
// Der Namens-Schriftzug ist ein absolut positioniertes Element mit inset-x-0 (volle
|
||||
// Breite ueber left/right:0), eine reine text-align-Klasse reicht darum - kein Flex-
|
||||
// Container involviert.
|
||||
export const GALLERY_CARD_ALIGN = {
|
||||
left: 'text-left',
|
||||
center: 'text-center',
|
||||
right: 'text-right',
|
||||
};
|
||||
10
hifi/api/database/migration_gallery_card_align.sql
Normal file
10
hifi/api/database/migration_gallery_card_align.sql
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
USE hifi_shop;
|
||||
|
||||
-- Horizontale Ausrichtung des Marken-/Projekt-Namens auf den Bildergalerie-Kacheln
|
||||
-- (Uebersicht + Marken-Detailseite) - vorher immer linksbuendig hart codiert.
|
||||
-- Additiv, nichts wird geloescht.
|
||||
-- Hinweis: Auf der Live-Seite reicht stattdessen ein Klick auf "Datenbankstruktur aktualisieren"
|
||||
-- unter Admin-Panel -> Einstellungen -> Datenbank.
|
||||
|
||||
ALTER TABLE app_settings
|
||||
ADD COLUMN IF NOT EXISTS gallery_card_text_align ENUM('left','center','right') NOT NULL DEFAULT 'left' AFTER package_wheel_hint_interval;
|
||||
|
|
@ -36,6 +36,7 @@ CREATE TABLE app_settings (
|
|||
package_card_theme VARCHAR(30) NOT NULL DEFAULT 'graphite',
|
||||
package_card_layout VARCHAR(20) NOT NULL DEFAULT 'strip',
|
||||
package_wheel_hint_interval INT NOT NULL DEFAULT 8,
|
||||
gallery_card_text_align ENUM('left','center','right') NOT NULL DEFAULT 'left',
|
||||
mail_host VARCHAR(255) NULL,
|
||||
mail_port INT NULL,
|
||||
mail_username VARCHAR(255) NULL,
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ class SettingsController
|
|||
'logo_path', 'logo_dark_path', 'business_hours',
|
||||
'hero_image_path',
|
||||
'ga_measurement_id', 'ga_property_id', 'google_place_id',
|
||||
'package_card_theme', 'package_card_layout', 'package_wheel_hint_interval',
|
||||
'package_card_theme', 'package_card_layout', 'package_wheel_hint_interval', 'gallery_card_text_align',
|
||||
'mail_host', 'mail_port', 'mail_username', 'mail_encryption',
|
||||
'mail_from_email', 'mail_from_name', 'mail_notify_email',
|
||||
'mail_customer_subject', 'mail_customer_body', 'mail_owner_subject', 'mail_owner_body',
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ class SiteSettingsController
|
|||
'package_card_theme' => 'graphite',
|
||||
'package_card_layout' => 'strip',
|
||||
'package_wheel_hint_interval' => 8,
|
||||
'gallery_card_text_align' => 'left',
|
||||
];
|
||||
|
||||
// Entspricht dem, was zuvor hart in Footer.jsx (isOpenNow() + die drei separaten
|
||||
|
|
@ -41,7 +42,9 @@ class SiteSettingsController
|
|||
|
||||
private const APP_SETTINGS_COLUMNS = 'phone, whatsapp, contact_email, address_street, address_zip, address_city,
|
||||
logo_path, logo_dark_path, business_hours, hero_image_path, ga_measurement_id,
|
||||
package_card_theme, package_card_layout, package_wheel_hint_interval';
|
||||
package_card_theme, package_card_layout, package_wheel_hint_interval, gallery_card_text_align';
|
||||
|
||||
private const TEXT_ALIGNS = ['left', 'center', 'right'];
|
||||
|
||||
public static function show(): void
|
||||
{
|
||||
|
|
@ -89,6 +92,11 @@ class SiteSettingsController
|
|||
$wheelHintInterval = (int) ($body['package_wheel_hint_interval'] ?? 8);
|
||||
$wheelHintInterval = max(2, min(120, $wheelHintInterval ?: 8));
|
||||
|
||||
$galleryCardTextAlign = trim($body['gallery_card_text_align'] ?? '') ?: 'left';
|
||||
if (!in_array($galleryCardTextAlign, self::TEXT_ALIGNS, true)) {
|
||||
$galleryCardTextAlign = 'left';
|
||||
}
|
||||
|
||||
$newHeroImagePath = trim($body['hero_image_path'] ?? '') ?: null;
|
||||
$newLogoPath = trim($body['logo_path'] ?? '') ?: null;
|
||||
$newLogoDarkPath = trim($body['logo_dark_path'] ?? '') ?: null;
|
||||
|
|
@ -117,7 +125,8 @@ class SiteSettingsController
|
|||
$stmt = $db->prepare(
|
||||
'UPDATE app_settings SET phone = ?, whatsapp = ?, contact_email = ?, address_street = ?, address_zip = ?,
|
||||
address_city = ?, logo_path = ?, logo_dark_path = ?, business_hours = ?, hero_image_path = ?,
|
||||
ga_measurement_id = ?, package_card_theme = ?, package_card_layout = ?, package_wheel_hint_interval = ?
|
||||
ga_measurement_id = ?, package_card_theme = ?, package_card_layout = ?, package_wheel_hint_interval = ?,
|
||||
gallery_card_text_align = ?
|
||||
WHERE id = 1'
|
||||
);
|
||||
$stmt->execute([
|
||||
|
|
@ -135,6 +144,7 @@ class SiteSettingsController
|
|||
$packageCardTheme,
|
||||
$packageCardLayout,
|
||||
$wheelHintInterval,
|
||||
$galleryCardTextAlign,
|
||||
]);
|
||||
|
||||
Uploads::deleteIfOrphaned($old['hero_image_path'] ?? null, $newHeroImagePath);
|
||||
|
|
|
|||
|
|
@ -53,6 +53,7 @@ class Schema
|
|||
package_card_theme VARCHAR(30) NOT NULL DEFAULT 'graphite',
|
||||
package_card_layout VARCHAR(20) NOT NULL DEFAULT 'strip',
|
||||
package_wheel_hint_interval INT NOT NULL DEFAULT 8,
|
||||
gallery_card_text_align ENUM('left','center','right') NOT NULL DEFAULT 'left',
|
||||
mail_host VARCHAR(255) NULL,
|
||||
mail_port INT NULL,
|
||||
mail_username VARCHAR(255) NULL,
|
||||
|
|
@ -344,6 +345,7 @@ class Schema
|
|||
'package_card_theme' => "VARCHAR(30) NOT NULL DEFAULT 'graphite'",
|
||||
'package_card_layout' => "VARCHAR(20) NOT NULL DEFAULT 'strip'",
|
||||
'package_wheel_hint_interval' => 'INT NOT NULL DEFAULT 8',
|
||||
'gallery_card_text_align' => "ENUM('left','center','right') NOT NULL DEFAULT 'left'",
|
||||
'mail_host' => 'VARCHAR(255) NULL',
|
||||
'mail_port' => 'INT NULL',
|
||||
'mail_username' => 'VARCHAR(255) NULL',
|
||||
|
|
|
|||
1
hifi/assets/index-BN9M3ekV.css
Normal file
1
hifi/assets/index-BN9M3ekV.css
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
231
hifi/assets/index-D_IEWnB1.js
Normal file
231
hifi/assets/index-D_IEWnB1.js
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
|
@ -43,9 +43,9 @@
|
|||
"sameAs": ["https://www.youtube.com/@hifiplanet2812"]
|
||||
}
|
||||
</script>
|
||||
<script type="module" crossorigin src="/assets/index-CbPgqJea.js"></script>
|
||||
<script type="module" crossorigin src="/assets/index-D_IEWnB1.js"></script>
|
||||
<link rel="modulepreload" crossorigin href="/assets/lucide-icons-Cg2IxtAO.js">
|
||||
<link rel="stylesheet" crossorigin href="/assets/index-XtLTH0HQ.css">
|
||||
<link rel="stylesheet" crossorigin href="/assets/index-BN9M3ekV.css">
|
||||
</head>
|
||||
<body class="bg-white text-slate-900 dark:bg-slate-950 dark:text-slate-100">
|
||||
<div id="root"></div>
|
||||
|
|
|
|||
Loading…
Reference in a new issue