Loheide-eu-mitarbeiterplatt.../app/Http/Controllers/AppearanceController.php
Friederich Loheide 82bbeef31b
Some checks failed
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 2m7s
CI / PHP 8.4 / mariadb:10.6 (pull_request) Successful in 2m11s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 2m16s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 2m18s
CI / PHP 8.3 / mysql:8.0 (pull_request) Failing after 2m49s
CI / PHP 8.4 / mysql:8.0 (pull_request) Failing after 2m46s
CI / PHP 8.3 / mysql:8.4 (pull_request) Failing after 2m41s
CI / PHP 8.4 / mysql:8.4 (pull_request) Failing after 2m33s
CI / Build-Artefakte aktuell (pull_request) Successful in 1m0s
Phase 5: Erscheinungsbild mit Entwurf, Vorschau und Veröffentlichen
- Theme in den Einstellungen (Entwurf/veröffentlicht), Übernahme der
  Einstellungen aus Phase 0; statische CSS-Datei mit Hash beim Veröffentlichen
- Logos hell/dunkel, Signet, App-Symbol → Favicon, Homescreen-Symbole,
  Web-App-Manifest; SVG-Bereinigung
- Markenfarbe exakt, zweite Akzentfarbe, Kopfleiste hell/Marke/dunkel,
  Kontrastprüfung (WCAG AA) mit automatisch lesbarer Linkfarbe
- Lokale Schriften (Latein), Überschriften-Schrift, eigene WOFF2-Schrift,
  Ecken, Dichte, Dunkelmodus-Regel
- Anmeldeseite (geteilt/zentriert, Bild, Texte), Fußzeile, E-Mails im Design
- Admin: Live-Vorschau (Startseite, Anmeldung, Beispielseite; hell/dunkel),
  Veröffentlichen, Verwerfen, Export/Import, Zurücksetzen, eigenes CSS
- Admin-Bereich übernimmt Logo, Farbe und Favicon; Whitelabel

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-26 10:46:05 +00:00

86 lines
4.2 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
namespace App\Http\Controllers;
use App\Models\IdentityProvider;
use App\Pagebuilder\Content;
use App\Support\Branding;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Inertia\Inertia;
use Inertia\Response;
/**
* Web-App-Manifest und die Vorschauseiten für „Erscheinungsbild“.
*/
class AppearanceController extends Controller
{
public function manifest(Branding $branding): JsonResponse
{
$icons = collect($branding->get('icons') ?? [])
->reject(fn ($path, $size) => (int) $size < 192)
->map(fn ($path, $size) => ['src' => $branding->url($path), 'sizes' => "{$size}x{$size}", 'type' => 'image/png', 'purpose' => 'any'])
->values();
if ($icons->isEmpty()) {
$icons = collect([['src' => $branding->faviconUrl(), 'sizes' => 'any', 'type' => 'image/svg+xml']]);
}
return response()->json([
'name' => $branding->portalName(),
'short_name' => mb_substr($branding->portalName(), 0, 12),
'start_url' => '/',
'scope' => '/',
'display' => 'standalone',
'lang' => 'de',
'theme_color' => $branding->primaryColor(),
'background_color' => '#F4F5F7',
'icons' => $icons->all(),
], 200, ['Content-Type' => 'application/manifest+json', 'Cache-Control' => 'public, max-age=3600']);
}
/**
* Anmeldeseite im aktuellen Entwurf – für die Vorschau (Formular ohne Funktion).
*/
public function loginPreview(Request $request): Response
{
return Inertia::render('Auth/Login', [
'canResetPassword' => true,
'providers' => IdentityProvider::query()->where('enabled', true)->get()
->map(fn (IdentityProvider $p) => ['slug' => $p->slug, 'type' => $p->type, 'label' => $p->buttonLabel()])->values(),
'preview' => true,
]);
}
/**
* Beispielseite mit Boxen, Tabs, Akkordeon, Tabelle und Schaltflächen.
*/
public function sample(Request $request, Content $content): Response
{
$text = fn (string $html) => ['type' => 'text', 'data' => ['html' => $html]];
$box = fn (string $variant, string $title, string $html) => ['type' => 'box', 'data' => ['variant' => $variant, 'title' => $title, 'show_icon' => true], 'items' => [['blocks' => [$text($html)]]]];
$blocks = [
['type' => 'heading', 'data' => ['text' => 'Überschrift der Seite', 'level' => '2']],
$text('<p>Fließtext mit einem <a href="#">Link in der Akzentfarbe</a>, <strong>Hervorhebungen</strong> und einer Liste:</p><ul><li>erster Punkt</li><li>zweiter Punkt</li></ul>'),
['type' => 'columns', 'data' => ['layout' => '1-1'], 'items' => [
['blocks' => [$box('info', 'Info', '<p>Sprechstunde dienstags 14–16 Uhr.</p>'), $box('warning', 'Warnung', '<p>Bitte bis Freitag einreichen.</p>')]],
['blocks' => [$box('success', 'Erfolg', '<p>Das neue Verfahren gilt ab sofort.</p>'), $box('highlight', 'Hervorgehoben', '<p>In der Markenfarbe.</p>')]],
]],
['type' => 'tabs', 'items' => [
['title' => 'Erster Tab', 'blocks' => [$text('<p>Inhalt des ersten Tabs.</p>')]],
['title' => 'Zweiter Tab', 'blocks' => [$text('<p>Inhalt des zweiten Tabs.</p>')]],
]],
['type' => 'accordion', 'data' => ['first_open' => true], 'items' => [
['title' => 'Häufige Frage', 'blocks' => [$text('<p>Die Antwort steht hier.</p>')]],
['title' => 'Noch eine Frage', 'blocks' => [$text('<p>Noch eine Antwort.</p>')]],
]],
['type' => 'table', 'data' => ['header' => true, 'rows' => [['Bereich', 'Ansprechpartner', 'Durchwahl'], ['Personal', 'A. Beispiel', '123'], ['IT', 'B. Muster', '456']]]],
['type' => 'buttons', 'data' => ['buttons' => [['label' => 'Primäre Schaltfläche', 'url' => '#', 'variant' => 'primary'], ['label' => 'Umrandet', 'url' => '#', 'variant' => 'outline']]]],
];
return Inertia::render('Appearance/Sample', [
'content' => $content->render($content->sanitize(['blocks' => $blocks]), $request->user()),
]);
}
}