Adds four numeric app_settings fields (vehicle_tile_width/height, package_card_width/height, all in px, clamped server-side to a sane range but otherwise a free number as requested) with matching inputs in WebsiteSettings.jsx. Brand/model tiles (VehicleSelect.jsx, BrandPage.jsx) move from a responsive CSS-grid with an implicit per-column width to a flex-wrap layout where every tile has the admin's chosen fixed width/height - applies to both the photo-background and plain-text card variants, so mixed grids stay visually consistent. Package cards (ModelPage.jsx) keep their three existing layout modes (grid/strip/coverflow) but the actual card dimensions - previously hardcoded Tailwind width/min-height classes with a separate mobile/sm breakpoint value - are now driven by the same two settings. Grid mode's column count is no longer fixed at 2/3 columns; it's now repeat(auto-fill, minmax(width, 1fr)), so the chosen width determines how many cards fit per row. Coverflow's center-scroll padding, previously hardcoded against the old fixed 230px card width, now derives from the configured width too. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
86 lines
3.7 KiB
JavaScript
86 lines
3.7 KiB
JavaScript
import { useEffect, useState } from 'react';
|
|
import { Link } from 'react-router-dom';
|
|
import { api } from '../../api/client.js';
|
|
import usePageMeta from '../../hooks/usePageMeta.js';
|
|
import MaintenanceNotice from '../../components/MaintenanceNotice.jsx';
|
|
import MaintenanceBypassBanner from '../../components/MaintenanceBypassBanner.jsx';
|
|
import { useMaintenance } from '../../context/MaintenanceContext.jsx';
|
|
import { useLanguage } from '../../context/LanguageContext.jsx';
|
|
import { fieldStyle, useTextStylesMap } from '../../context/TextStylesContext.jsx';
|
|
import { useSiteSettings } from '../../context/SiteSettingsContext.jsx';
|
|
|
|
export default function VehicleSelect() {
|
|
const [brands, setBrands] = useState([]);
|
|
const [error, setError] = useState('');
|
|
const maintenance = useMaintenance();
|
|
const { t } = useLanguage();
|
|
const textStyles = useTextStylesMap();
|
|
const { vehicle_tile_width: tileWidth, vehicle_tile_height: tileHeight } = useSiteSettings();
|
|
const tileSize = { width: `${tileWidth}px`, height: `${tileHeight}px` };
|
|
|
|
usePageMeta({
|
|
title: t('vehicleSelect.metaTitle'),
|
|
description: t('vehicleSelect.metaDescription'),
|
|
path: '/fahrzeuge',
|
|
});
|
|
|
|
useEffect(() => {
|
|
if (maintenance.vehicles.enabled && !maintenance.bypass) return;
|
|
api.get('/brands').then(setBrands).catch((e) => setError(e.message));
|
|
}, [maintenance.vehicles.enabled, maintenance.bypass]);
|
|
|
|
if (maintenance.vehicles.enabled && !maintenance.bypass) {
|
|
return <MaintenanceNotice message={maintenance.vehicles.message} />;
|
|
}
|
|
|
|
return (
|
|
<div className="mx-auto max-w-6xl px-4 py-12 sm:px-6">
|
|
{maintenance.vehicles.enabled && maintenance.bypass && <MaintenanceBypassBanner inline />}
|
|
<h1 className="mb-2 text-2xl font-bold text-neutral-900 dark:text-white sm:text-3xl">{t('vehicleSelect.title')}</h1>
|
|
<p className="mb-8 text-neutral-600 dark:text-neutral-300">
|
|
{t('vehicleSelect.intro')}
|
|
</p>
|
|
|
|
{error && <p className="text-red-600">{error}</p>}
|
|
|
|
{brands.length === 0 && !error && (
|
|
<p className="text-neutral-500 dark:text-neutral-400">{t('vehicleSelect.empty')}</p>
|
|
)}
|
|
|
|
<div className="flex flex-wrap gap-4">
|
|
{brands.map((brand) =>
|
|
brand.image_path ? (
|
|
<Link
|
|
key={brand.id}
|
|
to={`/fahrzeuge/${brand.slug}`}
|
|
style={tileSize}
|
|
className="group relative block shrink-0 overflow-hidden rounded-xl bg-neutral-900 shadow-sm transition hover:shadow-lg"
|
|
>
|
|
<img
|
|
src={brand.image_path}
|
|
alt=""
|
|
className="h-full w-full object-cover transition duration-300 group-hover:scale-105"
|
|
/>
|
|
<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-center text-lg font-extrabold text-white"
|
|
style={fieldStyle(textStyles, `brands.${brand.id}.name`)}
|
|
>
|
|
{brand.name}
|
|
</span>
|
|
</Link>
|
|
) : (
|
|
<Link
|
|
key={brand.id}
|
|
to={`/fahrzeuge/${brand.slug}`}
|
|
style={tileSize}
|
|
className="flex shrink-0 flex-col items-center justify-center gap-3 rounded-xl border border-neutral-200 bg-white px-6 text-center font-semibold text-neutral-800 shadow-sm transition hover:-translate-y-0.5 hover:border-brand-500 hover:shadow-md dark:border-neutral-800 dark:bg-neutral-900 dark:text-neutral-100"
|
|
>
|
|
<span style={fieldStyle(textStyles, `brands.${brand.id}.name`)}>{brand.name}</span>
|
|
</Link>
|
|
)
|
|
)}
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|