Ergänze das CMS-Widget Hinweiszeile mit optional aufklappbarer Kurzdarstellung
Neues Widget notice (ADR-59): vollständiger Text und Kurztext als formatierte Texte, drei Modi (Volltext, responsiv mit Zeilengrenze, immer mit Kurzdarstellung), Symbol, Schriftgrößen XS bis L, Fläche, Rahmen und Akzentlinie. Der Server liefert immer den vollständigen Text; notice.js klappt ein und steht beim ersten Hinweis inline, damit nichts nach dem Laden springt (CLS 0,000). Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
a12818b752
commit
9e2d64a4a9
35 files changed
+1141
-40
No files matched your search
@@ -0,0 +1,58 @@
|
||||
{{--
|
||||
Hinweiszeile (NoticeWidget). Ohne JavaScript steht immer der vollständige Text (Grundzustand: .notice-short ist
|
||||
ausgeblendet, der Schalter hat das Attribut hidden). resources/js/notice.js macht aus dem Hinweis bei Bedarf eine
|
||||
Kurzdarstellung mit Schalter (aria-expanded) und entscheidet im Modus „responsive“ nach der Breite des Widgets und der
|
||||
Zahl der umgebrochenen Zeilen. Der Schalter legt eine Klickfläche über den ganzen Hinweis; Links im Text liegen
|
||||
darüber und bleiben einzeln bedienbar. Das Symbol ist Zierde (aria-hidden). Einstellungen kommen nur dann als Klasse an,
|
||||
wenn sie von der Vorgabe abweichen (NoticeWidget::layout).
|
||||
--}}
|
||||
@if (filled($textHtml))
|
||||
@php
|
||||
$collapsible = $layout['mode'] !== 'full';
|
||||
// Die Regeln für notice.js stehen nur an einklappbaren Hinweisen; ein Volltext bleibt ohne jedes data-Attribut.
|
||||
$noticeAttributes = (new \Illuminate\View\ComponentAttributeBag($collapsible ? array_filter([
|
||||
'data-notice' => '',
|
||||
'data-mode' => $layout['mode'],
|
||||
'data-narrow' => $layout['narrow'],
|
||||
'data-limit' => $layout['limit'],
|
||||
], fn ($value): bool => $value !== null) : []))->class([
|
||||
'notice',
|
||||
'notice--size-'.$layout['size'] => $layout['size'] !== 's',
|
||||
'notice--'.$layout['align'] => $layout['align'] !== 'left',
|
||||
'notice--surface scope-light notice--surface-'.$layout['surface'] => $layout['surface'] !== null,
|
||||
'notice--border' => $layout['border'],
|
||||
'notice--bar notice--bar-'.$layout['bar'] => $layout['bar'] !== null,
|
||||
'notice--symbol-'.$layout['symbolAlign'] => $layout['symbol'] !== null && $layout['symbolAlign'] !== 'top',
|
||||
]);
|
||||
@endphp
|
||||
<div {{ $noticeAttributes }}>
|
||||
<div class="notice-row">
|
||||
@if ($layout['symbol'] !== null)
|
||||
<x-brand.symbol :name="$layout['symbol']" class="notice-symbol notice-symbol--{{ $layout['symbolSize'] }}" preserveAspectRatio="xMinYMin meet" />
|
||||
@endif
|
||||
<div class="notice-body">
|
||||
@if ($collapsible)
|
||||
<div class="notice-short prose" data-notice-short>{!! $shortHtml !!}</div>
|
||||
@endif
|
||||
<div class="notice-full prose" data-notice-full>{!! $textHtml !!}</div>
|
||||
</div>
|
||||
@if ($collapsible)
|
||||
<button type="button" class="notice-toggle" data-notice-toggle aria-expanded="false" hidden>
|
||||
<span class="visually-hidden">Vollständigen Hinweis anzeigen</span>
|
||||
<svg class="notice-chevron" viewBox="0 0 20 20" width="20" height="20" aria-hidden="true" focusable="false"><path d="M5 7.5l5 5 5-5" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>
|
||||
</button>
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
@if ($collapsible)
|
||||
{{-- Entscheidet vor dem Malen, ob der Hinweis eingeklappt beginnt (Skript beim ersten Hinweis der Anfrage, danach nur der Aufruf). --}}
|
||||
@unless (request()->attributes->get('notice_boot'))
|
||||
@php request()->attributes->set('notice_boot', true); @endphp
|
||||
<script>{!! \App\Domain\Cms\Widgets\Types\NoticeWidget::bootScript() !!}</script>
|
||||
@endunless
|
||||
<script>window.lfNotice&&window.lfNotice.scan(document.currentScript.parentNode)</script>
|
||||
@endif
|
||||
@endif
|
||||
@if (! empty($notice))
|
||||
<p class="preview-note">{{ $notice }}</p>
|
||||
@endif
|
||||
Reference in new issue
Block a user