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>
114 lines
4.2 KiB
JavaScript
114 lines
4.2 KiB
JavaScript
import { useEffect, useState } from 'react';
|
||
import { Outlet, useLocation } from 'react-router-dom';
|
||
import Navbar from './Navbar.jsx';
|
||
import Footer from './Footer.jsx';
|
||
import ScrollProgress from './ScrollProgress.jsx';
|
||
import MaintenanceNotice from './MaintenanceNotice.jsx';
|
||
import MaintenanceBypassBanner from './MaintenanceBypassBanner.jsx';
|
||
import CookieConsentBanner from './CookieConsentBanner.jsx';
|
||
import GoogleAnalytics from './GoogleAnalytics.jsx';
|
||
import { MaintenanceProvider } from '../context/MaintenanceContext.jsx';
|
||
import { SiteSettingsProvider } from '../context/SiteSettingsContext.jsx';
|
||
import { LanguageProvider } from '../context/LanguageContext.jsx';
|
||
import { useAuth } from '../context/AuthContext.jsx';
|
||
import { api } from '../api/client.js';
|
||
|
||
const FALLBACK_STATUS = {
|
||
global: { enabled: false, message: null },
|
||
services: { enabled: false, message: null },
|
||
vehicles: { enabled: false, message: null },
|
||
};
|
||
|
||
const DEFAULT_BUSINESS_HOURS = {
|
||
mon: { open: '09:00', close: '18:00', closed: false },
|
||
tue: { open: '09:00', close: '18:00', closed: false },
|
||
wed: { open: '09:00', close: '18:00', closed: false },
|
||
thu: { open: '09:00', close: '18:00', closed: false },
|
||
fri: { open: '09:00', close: '18:00', closed: false },
|
||
sat: { open: '10:00', close: '13:00', closed: false },
|
||
sun: { open: '', close: '', closed: true },
|
||
};
|
||
|
||
const DEFAULT_SITE_SETTINGS = {
|
||
phone: '09373 20 62 390',
|
||
whatsapp: null,
|
||
contact_email: 'info@hifi-planet-amorbach.de',
|
||
address_street: 'Boxbrunner Str. 20a',
|
||
address_zip: '63916',
|
||
address_city: 'Amorbach',
|
||
logo_path: null,
|
||
logo_dark_path: null,
|
||
business_hours: DEFAULT_BUSINESS_HOURS,
|
||
hero_image_path: null,
|
||
ga_measurement_id: null,
|
||
package_card_theme: 'graphite',
|
||
package_card_layout: 'strip',
|
||
package_wheel_hint_interval: 8,
|
||
gallery_card_text_x: 0,
|
||
gallery_card_text_y: 100,
|
||
site_font: null,
|
||
};
|
||
|
||
// Das Impressum (und die anderen rechtlichen Pflichtseiten) müssen laut § 5 DDG
|
||
// "leicht erkennbar und unmittelbar erreichbar" bleiben – auch während der
|
||
// generellen Wartung darf diese Erreichbarkeit nicht durch die Wartungsseite
|
||
// verdeckt werden.
|
||
const LEGAL_PATHS = ['/impressum', '/datenschutz', '/agb'];
|
||
|
||
export default function PublicLayout() {
|
||
const [status, setStatus] = useState(null);
|
||
const [siteSettings, setSiteSettings] = useState(DEFAULT_SITE_SETTINGS);
|
||
const { loading: authLoading, hasPermission } = useAuth();
|
||
const location = useLocation();
|
||
|
||
useEffect(() => {
|
||
api.get('/maintenance').then(setStatus).catch(() => setStatus(FALLBACK_STATUS));
|
||
api.get('/site-settings').then(setSiteSettings).catch(() => {});
|
||
}, []);
|
||
|
||
// Globale Schriftart als CSS-Variable auf <html> - tailwind.config.js definiert font-sans
|
||
// als var(--site-font, ...Systemschrift...), dadurch greift die Auswahl automatisch auf
|
||
// praktisch jeden Text der Seite, ohne einzelne Komponenten anzufassen.
|
||
useEffect(() => {
|
||
if (siteSettings.site_font) {
|
||
document.documentElement.style.setProperty('--site-font', siteSettings.site_font);
|
||
} else {
|
||
document.documentElement.style.removeProperty('--site-font');
|
||
}
|
||
}, [siteSettings.site_font]);
|
||
|
||
if (status === null || authLoading) {
|
||
return <div className="min-h-screen bg-white dark:bg-neutral-950" />;
|
||
}
|
||
|
||
const bypass = hasPermission('maintenance.bypass');
|
||
const isLegalPage = LEGAL_PATHS.includes(location.pathname);
|
||
|
||
if (status.global.enabled && !bypass && !isLegalPage) {
|
||
return (
|
||
<LanguageProvider>
|
||
<MaintenanceNotice message={status.global.message} fullScreen />
|
||
</LanguageProvider>
|
||
);
|
||
}
|
||
|
||
return (
|
||
<LanguageProvider>
|
||
<MaintenanceProvider value={{ ...status, bypass }}>
|
||
<SiteSettingsProvider value={siteSettings}>
|
||
<div className="page-texture flex min-h-screen flex-col text-neutral-900 dark:text-neutral-100">
|
||
{bypass && status.global.enabled && <MaintenanceBypassBanner />}
|
||
<ScrollProgress />
|
||
<Navbar />
|
||
<main className="flex-1">
|
||
<Outlet />
|
||
</main>
|
||
<Footer />
|
||
<CookieConsentBanner />
|
||
<GoogleAnalytics />
|
||
</div>
|
||
</SiteSettingsProvider>
|
||
</MaintenanceProvider>
|
||
</LanguageProvider>
|
||
);
|
||
}
|