Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
90c74ac03d | ||
|
|
b714dc8219 |
No files matched your search
@@ -23,6 +23,37 @@ class FeaturesWidget extends WidgetType
|
||||
{
|
||||
private const DEFAULT_LINK_LABEL = 'Mehr erfahren';
|
||||
|
||||
/** @var array<string, string> */
|
||||
public const ALIGN = ['left' => 'Linksbündig', 'center' => 'Zentriert', 'right' => 'Rechtsbündig'];
|
||||
|
||||
/**
|
||||
* Kantenlänge des Symbolquadrats: klein 2,5 rem, mittel 3,5 rem (Vorgabe), groß 5 rem, sehr groß 7 rem.
|
||||
*
|
||||
* @var array<string, string>
|
||||
*/
|
||||
public const SYMBOL_SIZE = ['small' => 'Klein', 'medium' => 'Mittel', 'large' => 'Groß', 'xlarge' => 'Sehr groß'];
|
||||
|
||||
/** @var array<string, string> */
|
||||
public const DIVIDER = ['line' => 'Feiner Strich zwischen den Merkmalen'];
|
||||
|
||||
/**
|
||||
* Gültige Layout-Einstellungen mit Vorgaben (links, mittel, ohne Strich); alles andere fällt auf die Vorgabe zurück.
|
||||
*
|
||||
* @param array<string, mixed> $settings
|
||||
* @return array{align: string, size: string, divider: bool}
|
||||
*/
|
||||
public static function layout(array $settings): array
|
||||
{
|
||||
$align = $settings['align'] ?? null;
|
||||
$size = $settings['symbol_size'] ?? null;
|
||||
|
||||
return [
|
||||
'align' => is_string($align) && array_key_exists($align, self::ALIGN) ? $align : 'left',
|
||||
'size' => is_string($size) && array_key_exists($size, self::SYMBOL_SIZE) ? $size : 'medium',
|
||||
'divider' => ($settings['divider'] ?? null) === 'line',
|
||||
];
|
||||
}
|
||||
|
||||
public function key(): string
|
||||
{
|
||||
return 'features';
|
||||
@@ -85,17 +116,27 @@ public function dataRules(): array
|
||||
|
||||
public function settings(): array
|
||||
{
|
||||
return ['link_style' => HeadingAccent::LINK_STYLE];
|
||||
return [
|
||||
'align' => self::ALIGN,
|
||||
'symbol_size' => self::SYMBOL_SIZE,
|
||||
'divider' => self::DIVIDER,
|
||||
'link_style' => HeadingAccent::LINK_STYLE,
|
||||
];
|
||||
}
|
||||
|
||||
public function settingGroups(): array
|
||||
{
|
||||
return ['Aussehen' => ['link_style']];
|
||||
return ['Aussehen' => ['align', 'symbol_size', 'divider', 'link_style']];
|
||||
}
|
||||
|
||||
public function settingLabels(): array
|
||||
{
|
||||
return ['link_style' => HeadingAccent::LINK_STYLE_LABEL];
|
||||
return [
|
||||
'align' => ['Ausrichtung', 'Richtet Symbol, Titel, Satz und Link jedes Merkmals aus. Vorgabe: linksbündig.'],
|
||||
'symbol_size' => ['Größe der Symbole', 'Kantenlänge der Symbole: Klein 2,5 rem, Mittel 3,5 rem, Groß 5 rem, Sehr groß 7 rem. Vorgabe: Mittel.'],
|
||||
'divider' => ['Trennstrich', 'Ein feiner Strich zwischen den Merkmalen: senkrecht zwischen Spalten, waagerecht zwischen Zeilen und bei untereinander stehenden Merkmalen. Vorgabe: ohne.'],
|
||||
'link_style' => HeadingAccent::LINK_STYLE_LABEL,
|
||||
];
|
||||
}
|
||||
|
||||
public function dataFields(): array
|
||||
@@ -168,7 +209,9 @@ public function resolve(array $widget, RenderContext $context): array
|
||||
];
|
||||
}
|
||||
|
||||
return ['items' => $items, 'linkStyle' => HeadingAccent::linkStyle($widget['settings'] ?? [])];
|
||||
$settings = $widget['settings'] ?? [];
|
||||
|
||||
return ['items' => $items, 'linkStyle' => HeadingAccent::linkStyle($settings), 'layout' => self::layout($settings)];
|
||||
}
|
||||
|
||||
public function summary(array $widget): string
|
||||
|
||||
@@ -25,6 +25,9 @@ final class Symbols
|
||||
/** @var array<string, string> */
|
||||
private static array $cache = [];
|
||||
|
||||
/** @var array<string, array<string, float>>|null */
|
||||
private static ?array $bounds = null;
|
||||
|
||||
/**
|
||||
* @return list<string>
|
||||
*/
|
||||
@@ -56,20 +59,51 @@ private static function render(string $set, string $name, string $attributes): H
|
||||
throw new InvalidArgumentException("Unbekanntes Markensymbol „{$name}“ im Satz „{$set}“.");
|
||||
}
|
||||
|
||||
$svg = self::$cache["$set/$name"] ??= self::clean((string) file_get_contents(self::directory($set)."/$name.svg"));
|
||||
$svg = self::$cache["$set/$name"] ??= self::clean((string) file_get_contents(self::directory($set)."/$name.svg"), $set === self::SET_SYMBOLS ? self::bounds($name) : null);
|
||||
$extra = trim($attributes) === '' ? '' : ' '.trim($attributes);
|
||||
|
||||
return new HtmlString(preg_replace('/^<svg\b/', '<svg aria-hidden="true" focusable="false"'.$extra, $svg, 1) ?? $svg);
|
||||
}
|
||||
|
||||
private static function clean(string $svg): string
|
||||
/**
|
||||
* Sichtbare Zeichnung eines Symbols in Einheiten seiner ursprünglichen Zeichenfläche: x, y, w (Breite), h (Höhe).
|
||||
* Die Kit-Dateien haben einen unsichtbaren Rand um die Zeichnung (je nach Symbol 5 bis 20 % der Fläche). Beim
|
||||
* Einbetten wird die Zeichenfläche auf diese Grenzen zugeschnitten, damit die Oberkante der Zeichnung bündig mit der
|
||||
* Oberkante von Text oder Rahmen abschließt. Gemessen mit scripts/brand-symbol-bounds.py (Datei _grenzen.json).
|
||||
*
|
||||
* @return array{x: float, y: float, w: float, h: float}|null
|
||||
*/
|
||||
public static function bounds(string $name): ?array
|
||||
{
|
||||
self::$bounds ??= (function (): array {
|
||||
$file = self::directory(self::SET_SYMBOLS).'/_grenzen.json';
|
||||
$data = is_file($file) ? json_decode((string) file_get_contents($file), true) : null;
|
||||
|
||||
return is_array($data) ? $data : [];
|
||||
})();
|
||||
|
||||
$box = self::$bounds[$name] ?? null;
|
||||
|
||||
return is_array($box) && isset($box['x'], $box['y'], $box['w'], $box['h']) && $box['w'] > 0 && $box['h'] > 0 ? $box : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array{x: float, y: float, w: float, h: float}|null $bounds
|
||||
*/
|
||||
private static function clean(string $svg, ?array $bounds = null): string
|
||||
{
|
||||
$svg = trim($svg);
|
||||
$svg = preg_replace('#<title\b[^>]*>.*?</title>#s', '', $svg) ?? $svg;
|
||||
$svg = preg_replace('/\r?\n\s*/', '', $svg) ?? $svg;
|
||||
|
||||
return (string) preg_replace_callback('/^<svg\b[^>]*>/', function (array $root): string {
|
||||
return (string) preg_replace('/\s(?:id|role|aria-labelledby|width|height)="[^"]*"/', '', $root[0]);
|
||||
return (string) preg_replace_callback('/^<svg\b[^>]*>/', function (array $root) use ($bounds): string {
|
||||
$tag = (string) preg_replace('/\s(?:id|role|aria-labelledby|width|height)="[^"]*"/', '', $root[0]);
|
||||
|
||||
if ($bounds !== null) {
|
||||
$tag = (string) preg_replace('/\sviewBox="[^"]*"/', ' viewBox="'.implode(' ', [$bounds['x'], $bounds['y'], $bounds['w'], $bounds['h']]).'"', $tag, 1);
|
||||
}
|
||||
|
||||
return $tag;
|
||||
}, $svg);
|
||||
}
|
||||
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 134 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 135 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 194 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 160 KiB |
@@ -48,6 +48,9 @@ ## 1b. Stand der Umsetzung Stufe 3: Gestaltung im Redaktionsinhalt (Branch `feat
|
||||
- **Links in der Merkmalszeile:** je Merkmal optional Linkziel und Linktext (Vorgabe „Mehr erfahren“); die Einstellung „Darstellung der Links“ wählt für das ganze Widget kleiner Textlink (Vorgabe) oder Pille.
|
||||
- **Beleg (großes Symbol, Links):** `16_Lara-Felix-Kleingrafiken/abnahme/cms-symbol-gross-merkmal-links-breit.png` und `…-schmal.png`.
|
||||
- **Beleg (Größen, Ausrichtung, 1 bis 6 Merkmale):** `16_Lara-Felix-Kleingrafiken/abnahme/cms-symbolgroesse-ausrichtung-breit.png` und `…-schmal.png`.
|
||||
- **Bündige Ausrichtung** (nach der dritten Sichtung): Die Kit-Dateien haben einen unsichtbaren Rand um die Zeichnung (die Zeichnung beginnt je nach Symbol erst bei 5 bis 20 % der Fläche). `scripts/brand-symbol-bounds.py` misst am gerenderten Bild die äußersten sichtbaren Pixel und schreibt sie nach `resources/svg/brand/symbole/_grenzen.json`; `Symbols` schneidet die Zeichenfläche beim Einbetten darauf zu (die Kit-Dateien bleiben unverändert). Damit sitzt die Oberkante der Zeichnung exakt an der Oberkante des Elements. Bei „Oben“ zieht ein negativer Abstand die Überschrift hoch, sodass die Oberkante der Großbuchstaben auf der Oberkante des Symbols liegt (am gerenderten Bild gemessen: Abweichung unter einem Pixel); „Unten“ legt die Unterkante des Symbols auf die Grundlinie der letzten Zeile. In der Merkmalszeile haben alle Symbole dieselbe Höhe, die Titel stehen auf einer Linie. Wird eine Kit-Datei ersetzt, muss das Skript erneut laufen; ein Test prüft, dass zu jedem Symbol Grenzen vorliegen.
|
||||
- **Beleg (bündig):** `16_Lara-Felix-Kleingrafiken/abnahme/cms-symbol-buendig-breit.png` und `…-schmal.png`.
|
||||
- **Merkmalszeile, Layout** (nach der vierten Sichtung): Einstellungen „Ausrichtung“ (linksbündig, zentriert, rechtsbündig), „Größe der Symbole“ (klein, mittel, groß, sehr groß) und „Trennstrich“ (feiner Strich zwischen den Merkmalen). Beleg: `16_Lara-Felix-Kleingrafiken/abnahme/cms-merkmale-layout-breit.png` und `…-schmal.png`.
|
||||
- **Beleg:** `16_Lara-Felix-Kleingrafiken/abnahme/cms-symbole-merkmale-breit.png` und `…-schmal.png` (lokal aus den echten Ansichten und dem gebauten Stylesheet gerendert). Die Prüfung im Editor und auf luf-test steht noch aus.
|
||||
|
||||
Nicht umgesetzt: Symbole mitten im Fließtext (Stufe 3b, braucht einen Symbol-Knopf im Editor) und die Lernbausteine im Player (Stufe 4).
|
||||
|
||||
@@ -104,7 +104,7 @@ ## 4. Registrierte Widget-Arten
|
||||
| Pinselstrich (Überschrift) | `settings.accent` = `brush` | nur Widget „Überschrift und Einleitung“; Motiv „gelbe-unterstreichung“ des Kits |
|
||||
| Höhe | `settings.height` | gemeinsamer Layoutvertrag (§12) |
|
||||
|
||||
**Merkmalszeile.** `data.items[]` mit `symbol` (Auswahl wie oben), `title` (höchstens 60 Zeichen) und optional `text` (höchstens 200 Zeichen), `url` (über `SafeUrl`) und `link_label` (höchstens 60 Zeichen, Vorgabe „Mehr erfahren“, wird ohne `url` verworfen); ein bis zwölf Einträge, in jeder Platzbreite (1–4 Einheiten). Die Spaltenzahl ergibt sich aus der Anzahl der Einträge und der tatsächlichen Breite (Raster ab 12 rem je Merkmal), nicht aus einer eigenen Einstellung. `settings.link_style` bestimmt für alle Links des Widgets die Darstellung: `text` (kleiner Textlink, Vorgabe) oder `pill` (Pille). Der zugängliche Name des Links nennt das Merkmal („Mehr erfahren: Kurze Filme“).
|
||||
**Merkmalszeile.** `data.items[]` mit `symbol` (Auswahl wie oben), `title` (höchstens 60 Zeichen) und optional `text` (höchstens 200 Zeichen), `url` (über `SafeUrl`) und `link_label` (höchstens 60 Zeichen, Vorgabe „Mehr erfahren“, wird ohne `url` verworfen); ein bis zwölf Einträge, in jeder Platzbreite (1–4 Einheiten). Die Spaltenzahl ergibt sich aus der Anzahl der Einträge und der tatsächlichen Breite (Raster ab 12 rem je Merkmal), nicht aus einer eigenen Einstellung. `settings.link_style` bestimmt für alle Links des Widgets die Darstellung: `text` (kleiner Textlink, Vorgabe) oder `pill` (Pille). Weitere Einstellungen: `settings.align` (`left` Vorgabe, `center`, `right`; richtet Symbol, Titel, Satz und Link aus), `settings.symbol_size` (`small` 2,5 rem, `medium` 3,5 rem Vorgabe, `large` 5 rem, `xlarge` 7 rem) und `settings.divider` = `line` (feiner Strich in der Mitte der Lücke: senkrecht zwischen Spalten, waagerecht zwischen Zeilen und bei untereinander stehenden Merkmalen; die Liste schneidet die Striche am Rand ab). Ungültige gespeicherte Werte fallen auf die Vorgaben zurück (`FeaturesWidget::layout`). Der zugängliche Name des Links nennt das Merkmal („Mehr erfahren: Kurze Filme“).
|
||||
|
||||
**Abweichungen vom Kit (bewusst):**
|
||||
- Kennungen bleiben `hero` und `image_text`, nicht `lf-brand-hero`/`lf-editorial-bild-text`; Varianten `photo_split`/`editorial_solid` mit Unterstrich, weil Variantenkennungen `^[a-z][a-z0-9_]*$` folgen.
|
||||
|
||||
@@ -2,12 +2,22 @@
|
||||
* Markensymbole und Material-Tags (Brand-Kit 16_Lara-Felix-Kleingrafiken).
|
||||
* Nur Tokens aus tokens.css. Symbole sind dekorativ (aria-hidden); Tags tragen immer Text.
|
||||
*/
|
||||
/*
|
||||
* Die Symbole werden beim Einbetten auf ihre sichtbare Zeichnung zugeschnitten (App\Support\Brand\Symbols::bounds) und
|
||||
* tragen Breite und Höhe dieser Zeichnung als --sym-w und --sym-h. --sym-s ist die Kantenlänge des Quadrats, in das die
|
||||
* Zeichnung passen soll; die längere Seite füllt es, die kürzere folgt dem Seitenverhältnis. So gibt es keinen
|
||||
* unsichtbaren Rand mehr, und die Oberkante der Zeichnung sitzt exakt an der Oberkante des Elements. Im Fließtext steht
|
||||
* die Zeichnung auf Höhe der Mitte der Großbuchstaben.
|
||||
*/
|
||||
.brand-symbol {
|
||||
--sym-s: 1.5em;
|
||||
--sym-bw: calc(var(--sym-s) * min(1, var(--sym-w, 1) / var(--sym-h, 1)));
|
||||
--sym-bh: calc(var(--sym-s) * min(1, var(--sym-h, 1) / var(--sym-w, 1)));
|
||||
display: inline-block;
|
||||
inline-size: 1.5em;
|
||||
block-size: 1.5em;
|
||||
inline-size: var(--sym-bw);
|
||||
block-size: var(--sym-bh);
|
||||
flex: none;
|
||||
vertical-align: -0.3em;
|
||||
vertical-align: calc(0.34em - var(--sym-bh) / 2);
|
||||
overflow: visible;
|
||||
}
|
||||
|
||||
@@ -64,12 +74,8 @@ .brand-tag--paket {
|
||||
* sonst verschwänden die Linien.
|
||||
*/
|
||||
.lf-heading-symbol {
|
||||
display: inline-block;
|
||||
inline-size: 1.2em;
|
||||
block-size: 1.2em;
|
||||
--sym-s: 1.2em;
|
||||
margin-inline-end: 0.35em;
|
||||
vertical-align: -0.2em;
|
||||
overflow: visible;
|
||||
}
|
||||
|
||||
.lf-heading-brush {
|
||||
@@ -85,13 +91,25 @@ .scope-accent .lf-heading-symbol,
|
||||
.lf-bt--navy .lf-heading-symbol,
|
||||
.lf-hero--editorial-solid .lf-heading-symbol,
|
||||
.scope-dark .lf-features__symbol,
|
||||
.scope-accent .lf-features__symbol {
|
||||
.scope-accent .lf-features__symbol,
|
||||
.scope-dark .lf-lead__symbol,
|
||||
.scope-accent .lf-lead__symbol {
|
||||
--sym-chip: calc(var(--sym-s) * 0.2);
|
||||
box-sizing: content-box;
|
||||
padding: 0.14em;
|
||||
/* Die Scheibe ist immer rund: Das Quadrat um die Zeichnung ist Kantenlänge + 2 × Rand, unabhängig vom Seitenverhältnis. */
|
||||
padding-inline: calc((var(--sym-s) - var(--sym-bw)) / 2 + var(--sym-chip));
|
||||
padding-block: calc((var(--sym-s) - var(--sym-bh)) / 2 + var(--sym-chip));
|
||||
border-radius: 50%;
|
||||
background: var(--lf-white);
|
||||
}
|
||||
|
||||
.scope-dark .lf-heading-symbol,
|
||||
.scope-accent .lf-heading-symbol,
|
||||
.lf-bt--navy .lf-heading-symbol,
|
||||
.lf-hero--editorial-solid .lf-heading-symbol {
|
||||
vertical-align: calc(0.34em - (var(--sym-s) + 2 * var(--sym-chip)) / 2);
|
||||
}
|
||||
|
||||
.lf-features {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(min(100%, 12rem), 1fr));
|
||||
@@ -101,26 +119,92 @@ .lf-features {
|
||||
list-style: none;
|
||||
}
|
||||
|
||||
/* Ein einzelnes Merkmal wird nicht über die ganze Breite gezogen. */
|
||||
/* Ein einzelnes Merkmal wird nicht über die ganze Breite gezogen; zentriert oder rechts steht auch die Spalte so. */
|
||||
.lf-features--1 {
|
||||
grid-template-columns: minmax(0, 28rem);
|
||||
}
|
||||
|
||||
.lf-features--1.lf-features--center { justify-content: center; }
|
||||
.lf-features--1.lf-features--right { justify-content: end; }
|
||||
|
||||
.lf-features__item {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
align-items: stretch;
|
||||
gap: var(--space-2);
|
||||
min-inline-size: 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Ausrichtung der Merkmale (Einstellung „Ausrichtung“): links (Vorgabe), zentriert, rechts. Texte folgen text-align; das
|
||||
* Symbol und die auf Lesebreite begrenzten Absätze rücken über align-self und automatische Ränder mit.
|
||||
*/
|
||||
.lf-features--center .lf-features__item { text-align: center; }
|
||||
.lf-features--center .lf-features__symbol { align-self: center; }
|
||||
.lf-features--center .lf-features__text { margin-inline: auto; }
|
||||
|
||||
.lf-features--right .lf-features__item { text-align: right; }
|
||||
.lf-features--right .lf-features__symbol { align-self: flex-end; }
|
||||
.lf-features--right .lf-features__text { margin-inline-start: auto; }
|
||||
|
||||
/* Größe der Symbole (Einstellung „Größe der Symbole“): Kantenlänge des Quadrats, in das die Zeichnung passt. */
|
||||
.lf-features--size-small .lf-features__symbol { --sym-s: 2.5rem; }
|
||||
.lf-features--size-large .lf-features__symbol { --sym-s: 5rem; }
|
||||
.lf-features--size-xlarge .lf-features__symbol { --sym-s: 7rem; }
|
||||
|
||||
/*
|
||||
* Trennstrich (Einstellung „Trennstrich“): Jedes Merkmal trägt links und oben einen Strich in der Mitte der Lücke. Die Liste
|
||||
* schneidet alles außerhalb ihres Rahmens ab; so entfallen die Striche am linken Rand und in der ersten Zeile von selbst,
|
||||
* egal wie viele Spalten die Breite zulässt. Der Rand von 0,375 rem außen bleibt für Fokusrahmen frei (ausgeglichen durch
|
||||
* den negativen Außenabstand).
|
||||
*/
|
||||
.lf-features--lines {
|
||||
overflow: hidden;
|
||||
overflow: clip;
|
||||
margin: -0.375rem;
|
||||
padding: 0.375rem;
|
||||
}
|
||||
|
||||
.lf-features--lines .lf-features__item {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.lf-features--lines .lf-features__item::before,
|
||||
.lf-features--lines .lf-features__item::after {
|
||||
content: "";
|
||||
position: absolute;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.lf-features--lines .lf-features__item::before {
|
||||
inset-block: 0;
|
||||
inset-inline-start: calc(var(--space-4) / -2);
|
||||
border-inline-start: 1px solid var(--color-border);
|
||||
}
|
||||
|
||||
.lf-features--lines .lf-features__item::after {
|
||||
inset-inline: 0;
|
||||
inset-block-start: calc(var(--space-5) / -2);
|
||||
border-block-start: 1px solid var(--color-border);
|
||||
}
|
||||
|
||||
/*
|
||||
* Alle Symbole einer Zeile bekommen dieselbe Höhe, damit die Titel auf einer Linie stehen; die Zeichnung sitzt oben links
|
||||
* (preserveAspectRatio xMinYMin), die Oberkante bleibt bündig. Auf dunklem Grund sorgt die runde Scheibe selbst für gleiche
|
||||
* Höhen (siehe oben), dort gilt die Höhe der Zeichnung.
|
||||
*/
|
||||
.lf-features__symbol {
|
||||
inline-size: 3.5rem;
|
||||
block-size: 3.5rem;
|
||||
--sym-s: 3.5rem;
|
||||
block-size: var(--sym-s);
|
||||
flex: none;
|
||||
overflow: visible;
|
||||
}
|
||||
|
||||
.scope-dark .lf-features__symbol,
|
||||
.scope-accent .lf-features__symbol {
|
||||
block-size: var(--sym-bh);
|
||||
}
|
||||
|
||||
.lf-features__title {
|
||||
margin: 0;
|
||||
color: var(--color-heading);
|
||||
@@ -190,24 +274,23 @@ .lf-lead {
|
||||
|
||||
.lf-lead--top { align-items: flex-start; }
|
||||
.lf-lead--center { align-items: center; }
|
||||
.lf-lead--bottom { align-items: flex-end; }
|
||||
/* Unten: Unterkante des Symbols auf der Grundlinie der letzten Textzeile; ältere Browser nehmen die Unterkante des Blocks. */
|
||||
.lf-lead--bottom {
|
||||
align-items: flex-end;
|
||||
align-items: last baseline;
|
||||
}
|
||||
|
||||
.cta .lf-lead--bottom { align-items: flex-end; }
|
||||
|
||||
.lf-lead__symbol {
|
||||
inline-size: clamp(4.5rem, 12cqi, 7rem);
|
||||
block-size: clamp(4.5rem, 12cqi, 7rem);
|
||||
--sym-s: clamp(4.5rem, 12cqi, 7rem);
|
||||
flex: none;
|
||||
overflow: visible;
|
||||
}
|
||||
|
||||
.lf-lead--medium .lf-lead__symbol {
|
||||
inline-size: 3.5rem;
|
||||
block-size: 3.5rem;
|
||||
}
|
||||
.lf-lead--medium .lf-lead__symbol { --sym-s: 3.5rem; }
|
||||
|
||||
.lf-lead--xlarge .lf-lead__symbol {
|
||||
inline-size: clamp(6rem, 20cqi, 10rem);
|
||||
block-size: clamp(6rem, 20cqi, 10rem);
|
||||
}
|
||||
.lf-lead--xlarge .lf-lead__symbol { --sym-s: clamp(6rem, 20cqi, 10rem); }
|
||||
|
||||
.lf-lead__body {
|
||||
flex: 1 1 0;
|
||||
@@ -218,17 +301,20 @@ .lf-lead__body > :first-child {
|
||||
margin-block-start: 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Oben: Die Überschrift hat über den Großbuchstaben Luft (halber Zeilenabstand plus der Abstand zwischen Oberkante der
|
||||
* Zeile und Oberkante der Großbuchstaben). Dieser Abstand wird hochgezogen, damit die Oberkante der Buchstaben bündig
|
||||
* mit der Oberkante des Symbols abschließt. Bei Nunito reichen die Großbuchstaben 0,4 em unter die Hälfte des
|
||||
* Zeilenabstands (Zeilenhöhe 1,15, am gerenderten Bild nachgemessen): Verschiebung = 0,4 em − Zeilenabstand / 2.
|
||||
*/
|
||||
.lf-lead--top .lf-lead__body > :is(h1, h2) {
|
||||
margin-block-start: calc((0.4 - var(--leading-heading, 1.15) / 2) * 1em);
|
||||
}
|
||||
|
||||
@container slot (max-width: 24rem) {
|
||||
.lf-lead {
|
||||
.lf-lead,
|
||||
.cta .lf-lead--bottom {
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
}
|
||||
}
|
||||
|
||||
.scope-dark .lf-lead__symbol,
|
||||
.scope-accent .lf-lead__symbol {
|
||||
box-sizing: content-box;
|
||||
padding: 0.5rem;
|
||||
border-radius: 50%;
|
||||
background: var(--lf-white);
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
{
|
||||
"bildung": {
|
||||
"x": 6.7,
|
||||
"y": 19.7,
|
||||
"w": 82.6,
|
||||
"h": 54.7
|
||||
},
|
||||
"buch": {
|
||||
"x": 10.0,
|
||||
"y": 23.7,
|
||||
"w": 76,
|
||||
"h": 55.4
|
||||
},
|
||||
"download": {
|
||||
"x": 13.4,
|
||||
"y": 14.4,
|
||||
"w": 69.2,
|
||||
"h": 65.2
|
||||
},
|
||||
"filmklappe": {
|
||||
"x": 4.8,
|
||||
"y": 6.3,
|
||||
"w": 87.4,
|
||||
"h": 83.1
|
||||
},
|
||||
"filmstreifen": {
|
||||
"x": 11.7,
|
||||
"y": 16.7,
|
||||
"w": 72.6,
|
||||
"h": 62.6
|
||||
},
|
||||
"gelbe-unterstreichung": {
|
||||
"x": 5.7,
|
||||
"y": 6.0,
|
||||
"w": 232.6,
|
||||
"h": 29.6
|
||||
},
|
||||
"gruppe": {
|
||||
"x": 7.9,
|
||||
"y": 23.1,
|
||||
"w": 80.2,
|
||||
"h": 54.1
|
||||
},
|
||||
"merkblatt": {
|
||||
"x": 20.7,
|
||||
"y": 10.7,
|
||||
"w": 54.6,
|
||||
"h": 73.6
|
||||
},
|
||||
"muskelarm": {
|
||||
"x": 8.0,
|
||||
"y": 16.5,
|
||||
"w": 85.8,
|
||||
"h": 67.5
|
||||
},
|
||||
"paket": {
|
||||
"x": 12.7,
|
||||
"y": 12.6,
|
||||
"w": 70.6,
|
||||
"h": 71.8
|
||||
},
|
||||
"pause-hand": {
|
||||
"x": 13.7,
|
||||
"y": 8.3,
|
||||
"w": 58.5,
|
||||
"h": 76.9
|
||||
},
|
||||
"play": {
|
||||
"x": 9.3,
|
||||
"y": 16.3,
|
||||
"w": 77.4,
|
||||
"h": 63.4
|
||||
},
|
||||
"schutzschild": {
|
||||
"x": 16.7,
|
||||
"y": 9.7,
|
||||
"w": 62.6,
|
||||
"h": 77.6
|
||||
},
|
||||
"signalstrahlen": {
|
||||
"x": 6.2,
|
||||
"y": 6.2,
|
||||
"w": 35.6,
|
||||
"h": 31.6
|
||||
},
|
||||
"sprechblase-fragezeichen": {
|
||||
"x": 5.7,
|
||||
"y": 11.7,
|
||||
"w": 84.6,
|
||||
"h": 74.6
|
||||
},
|
||||
"uebungsblatt": {
|
||||
"x": 14.7,
|
||||
"y": 12.7,
|
||||
"w": 68.6,
|
||||
"h": 70.6
|
||||
}
|
||||
}
|
||||
@@ -1 +1 @@
|
||||
@props(['name']){!! \App\Support\Brand\Symbols::symbol($name, $attributes->class(['brand-symbol'])->toHtml()) !!}
|
||||
@props(['name'])@php($box = \App\Support\Brand\Symbols::bounds($name)){!! \App\Support\Brand\Symbols::symbol($name, $attributes->class(['brand-symbol'])->style($box === null ? [] : ['--sym-w: '.$box['w'], '--sym-h: '.$box['h']])->toHtml()) !!}
|
||||
@@ -2,14 +2,21 @@
|
||||
Merkmalszeile: ein bis zwölf Merkmale mit Symbol, Kurztitel, Satz und optionalem Link. Die Spaltenzahl folgt der Anzahl
|
||||
der Einträge und der tatsächlichen Breite (Raster mit Mindestbreite). Die Symbole sind Zierde; der Kurztitel trägt die
|
||||
Aussage. Der Link erscheint als kleiner Textlink oder als Pille (Einstellung link_style); sein zugänglicher Name nennt
|
||||
das Merkmal, damit mehrere „Mehr erfahren“ unterscheidbar bleiben.
|
||||
das Merkmal, damit mehrere „Mehr erfahren“ unterscheidbar bleiben. Layout (Ausrichtung, Symbolgröße, Trennstrich) kommt
|
||||
als Klassen an der Liste; ungültige Werte sind bereits auf die Vorgabe zurückgefallen (FeaturesWidget::layout).
|
||||
--}}
|
||||
@if ($items !== [])
|
||||
<ul class="lf-features lf-features--{{ count($items) }}">
|
||||
<ul @class([
|
||||
'lf-features',
|
||||
'lf-features--'.count($items),
|
||||
'lf-features--'.$layout['align'],
|
||||
'lf-features--size-'.$layout['size'],
|
||||
'lf-features--lines' => $layout['divider'],
|
||||
])>
|
||||
@foreach ($items as $item)
|
||||
<li class="lf-features__item">
|
||||
@if ($item['symbol'] !== null)
|
||||
<x-brand.symbol :name="$item['symbol']" class="lf-features__symbol" />
|
||||
<x-brand.symbol :name="$item['symbol']" class="lf-features__symbol" preserveAspectRatio="xMinYMin meet" />
|
||||
@endif
|
||||
<p class="lf-features__title">{{ $item['title'] }}</p>
|
||||
@if (filled($item['text']))
|
||||
|
||||
@@ -0,0 +1,80 @@
|
||||
"""Misst bei jedem Kit-Symbol, wo die sichtbare Zeichnung liegt, und schreibt die Grenzen als JSON.
|
||||
|
||||
Die Kit-Dateien (resources/svg/brand/symbole/*.svg) haben eine feste Zeichenfläche (viewBox 0 0 96 96), die Zeichnung füllt
|
||||
sie aber nicht aus: oben, unten und an den Seiten bleibt ein unsichtbarer Rand. Damit ein Symbol bündig mit Text oder Rand
|
||||
abschließt, schneidet App\\Support\\Brand\\Symbols die Zeichenfläche beim Einbetten auf diese Grenzen zu.
|
||||
|
||||
Gemessen wird nicht mit getBBox() (das lässt Linienstärken, Kappen und Drehungen aus), sondern am gerenderten Bild:
|
||||
Jede Datei wird zehnfach vergrößert auf eine transparente Fläche gezeichnet; die Grenzen sind die äußersten Pixel mit
|
||||
sichtbarer Deckkraft. Ergebnis: resources/svg/brand/symbole/_grenzen.json (x, y, Breite, Höhe in Einheiten der viewBox).
|
||||
|
||||
Aufruf (im Repository-Wurzelverzeichnis): python scripts/brand-symbol-bounds.py
|
||||
Voraussetzung: playwright für Python mit installiertem Chromium. Nach jeder Änderung oder jedem Austausch einer Kit-Datei
|
||||
erneut ausführen; ein Test prüft, dass zu jedem Symbol Grenzen vorliegen und sie innerhalb der Zeichenfläche liegen.
|
||||
"""
|
||||
|
||||
import json
|
||||
import pathlib
|
||||
import re
|
||||
|
||||
from playwright.sync_api import sync_playwright
|
||||
|
||||
ROOT = pathlib.Path(__file__).resolve().parent.parent
|
||||
DIR = ROOT / "resources" / "svg" / "brand" / "symbole"
|
||||
SCALE = 10
|
||||
|
||||
JS = """
|
||||
async ([svg, w, h, scale]) => {
|
||||
const url = 'data:image/svg+xml;charset=utf-8,' + encodeURIComponent(svg);
|
||||
const img = new Image();
|
||||
img.src = url;
|
||||
await img.decode();
|
||||
const c = document.createElement('canvas');
|
||||
c.width = Math.round(w * scale); c.height = Math.round(h * scale);
|
||||
const ctx = c.getContext('2d');
|
||||
ctx.drawImage(img, 0, 0, c.width, c.height);
|
||||
const d = ctx.getImageData(0, 0, c.width, c.height).data;
|
||||
let minX = c.width, minY = c.height, maxX = -1, maxY = -1;
|
||||
for (let y = 0; y < c.height; y++) {
|
||||
for (let x = 0; x < c.width; x++) {
|
||||
if (d[(y * c.width + x) * 4 + 3] > 16) {
|
||||
if (x < minX) minX = x; if (x > maxX) maxX = x;
|
||||
if (y < minY) minY = y; if (y > maxY) maxY = y;
|
||||
}
|
||||
}
|
||||
}
|
||||
return [minX / scale, minY / scale, (maxX + 1) / scale, (maxY + 1) / scale];
|
||||
}
|
||||
"""
|
||||
|
||||
|
||||
def main() -> None:
|
||||
result = {}
|
||||
with sync_playwright() as p:
|
||||
browser = p.chromium.launch()
|
||||
page = browser.new_page()
|
||||
for path in sorted(DIR.glob("*.svg")):
|
||||
svg = path.read_text(encoding="utf-8")
|
||||
vb = re.search(r'viewBox="([\d.\s-]+)"', svg).group(1).split()
|
||||
vx, vy, vw, vh = (float(v) for v in vb)
|
||||
# Ohne feste Größe zeichnen lassen: die viewBox bestimmt das Seitenverhältnis.
|
||||
sized = re.sub(r'(<svg\b[^>]*?)\swidth="[^"]*"', r"\1", svg, count=1)
|
||||
sized = re.sub(r'(<svg\b[^>]*?)\sheight="[^"]*"', r"\1", sized, count=1)
|
||||
sized = sized.replace("<svg ", f'<svg width="{vw * SCALE}" height="{vh * SCALE}" ', 1)
|
||||
x0, y0, x1, y1 = page.evaluate(JS, [sized, vw, vh, SCALE])
|
||||
result[path.stem] = {
|
||||
"x": round(vx + x0, 2),
|
||||
"y": round(vy + y0, 2),
|
||||
"w": round(x1 - x0, 2),
|
||||
"h": round(y1 - y0, 2),
|
||||
}
|
||||
browser.close()
|
||||
|
||||
out = DIR / "_grenzen.json"
|
||||
out.write_text(json.dumps(result, indent=2, ensure_ascii=False) + "\n", encoding="utf-8", newline="\n")
|
||||
for name, b in result.items():
|
||||
print(f"{name:28s} x={b['x']:6.2f} y={b['y']:6.2f} w={b['w']:6.2f} h={b['h']:6.2f}")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
use App\Domain\Cms\Page;
|
||||
use App\Domain\Cms\PageService;
|
||||
use App\Domain\Cms\Widgets\Types\FeaturesWidget;
|
||||
use App\Domain\Cms\Widgets\WidgetRegistry;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
@@ -99,7 +100,8 @@ public function test_the_features_row_renders_symbols_titles_and_text_with_one_c
|
||||
];
|
||||
$html = $this->publish('/merkmale', $this->widget('features', ['items' => $items]));
|
||||
|
||||
$this->assertStringContainsString('class="lf-features lf-features--3"', $html);
|
||||
$this->assertStringContainsString('class="lf-features lf-features--3 lf-features--left lf-features--size-medium"', $html, 'Vorgaben: linksbündig, mittlere Symbole, kein Strich.');
|
||||
$this->assertStringNotContainsString('lf-features--lines', $html);
|
||||
$this->assertSame(3, substr_count($html, 'class="lf-features__item"'));
|
||||
$this->assertSame(3, preg_match_all('~<svg[^>]*aria-hidden="true"[^>]*class="brand-symbol lf-features__symbol"~', $html));
|
||||
$this->assertStringContainsString('<p class="lf-features__title">Übung</p>', $html);
|
||||
@@ -214,6 +216,34 @@ public function test_feature_links_must_be_safe_and_a_label_without_a_link_is_dr
|
||||
}
|
||||
}
|
||||
|
||||
public function test_the_features_row_takes_alignment_symbol_size_and_divider_from_its_settings(): void
|
||||
{
|
||||
$items = [['symbol' => 'buch', 'title' => 'Eins', 'text' => null], ['symbol' => 'gruppe', 'title' => 'Zwei', 'text' => null]];
|
||||
|
||||
$html = $this->publish('/merkmale-layout', $this->widget('features', ['items' => $items], ['align' => 'center', 'symbol_size' => 'xlarge', 'divider' => 'line']));
|
||||
$this->assertStringContainsString('class="lf-features lf-features--2 lf-features--center lf-features--size-xlarge lf-features--lines"', $html);
|
||||
|
||||
$right = $this->publish('/merkmale-rechts', $this->widget('features', ['items' => $items], ['align' => 'right', 'symbol_size' => 'small']));
|
||||
$this->assertStringContainsString('class="lf-features lf-features--2 lf-features--right lf-features--size-small"', $right);
|
||||
$this->assertStringNotContainsString('lf-features--lines', $right);
|
||||
}
|
||||
|
||||
public function test_unknown_layout_values_of_the_features_row_are_rejected_and_fall_back_to_the_defaults(): void
|
||||
{
|
||||
foreach ([['align' => 'justify'], ['symbol_size' => 'huge'], ['divider' => 'double']] as $index => $settings) {
|
||||
try {
|
||||
$this->publish('/merkmale-layout-falsch-'.$index, $this->widget('features', ['items' => [['symbol' => 'buch', 'title' => 'Eins', 'text' => null], ['symbol' => 'buch', 'title' => 'Zwei', 'text' => null]]], $settings));
|
||||
$this->fail('Angenommen: '.json_encode($settings));
|
||||
} catch (ValidationException $exception) {
|
||||
$this->assertStringContainsString('nicht freigegeben', implode(' ', array_merge(...array_values($exception->errors()))));
|
||||
}
|
||||
}
|
||||
|
||||
// Schon gespeicherte, später ungültig gewordene Werte dürfen die Ausgabe nicht brechen.
|
||||
$this->assertSame(['align' => 'left', 'size' => 'medium', 'divider' => false], FeaturesWidget::layout(['align' => ['x'], 'symbol_size' => 'huge', 'divider' => 'double']));
|
||||
$this->assertSame(['align' => 'right', 'size' => 'large', 'divider' => true], FeaturesWidget::layout(['align' => 'right', 'symbol_size' => 'large', 'divider' => 'line']));
|
||||
}
|
||||
|
||||
public function test_the_features_row_fits_every_slot_width(): void
|
||||
{
|
||||
foreach ([1, 2, 3, 4] as $units) {
|
||||
|
||||
@@ -44,6 +44,45 @@ public function test_the_kit_ids_titles_and_fixed_sizes_are_removed_so_several_s
|
||||
$this->assertSame(3, substr_count($html, 'viewBox='));
|
||||
}
|
||||
|
||||
public function test_every_symbol_is_cropped_to_its_visible_drawing_so_it_ends_flush_with_text(): void
|
||||
{
|
||||
foreach (Symbols::names() as $name) {
|
||||
$box = Symbols::bounds($name);
|
||||
$this->assertNotNull($box, "Zu $name fehlen Grenzen. scripts/brand-symbol-bounds.py ausführen.");
|
||||
|
||||
preg_match('/viewBox="([\d.\s-]+)"/', (string) file_get_contents(resource_path("svg/brand/symbole/$name.svg")), $original);
|
||||
[$ox, $oy, $ow, $oh] = array_map('floatval', preg_split('/\s+/', trim($original[1])));
|
||||
|
||||
$this->assertGreaterThanOrEqual($ox - 0.01, $box['x'], "$name: links innerhalb der Zeichenfläche");
|
||||
$this->assertGreaterThanOrEqual($oy - 0.01, $box['y'], "$name: oben innerhalb der Zeichenfläche");
|
||||
$this->assertLessThanOrEqual($ox + $ow + 0.01, $box['x'] + $box['w'], "$name: rechts innerhalb der Zeichenfläche");
|
||||
$this->assertLessThanOrEqual($oy + $oh + 0.01, $box['y'] + $box['h'], "$name: unten innerhalb der Zeichenfläche");
|
||||
$this->assertGreaterThan(($ow * $oh) * 0.1, $box['w'] * $box['h'], "$name: Grenzen sind nicht plausibel klein");
|
||||
|
||||
$this->assertStringContainsString(
|
||||
'viewBox="'.$box['x'].' '.$box['y'].' '.$box['w'].' '.$box['h'].'"',
|
||||
(string) Symbols::symbol($name),
|
||||
"$name wird auf die Grenzen zugeschnitten",
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public function test_the_component_hands_the_drawing_size_to_the_stylesheet_and_glyphs_stay_untouched(): void
|
||||
{
|
||||
$box = Symbols::bounds('schutzschild');
|
||||
$html = Blade::render('<x-brand.symbol name="schutzschild" style="color: red" />');
|
||||
|
||||
$this->assertStringContainsString('--sym-w: '.$box['w'], $html);
|
||||
$this->assertStringContainsString('--sym-h: '.$box['h'], $html);
|
||||
$this->assertStringContainsString('color: red', $html, 'Eigene Stilangaben bleiben erhalten.');
|
||||
$this->assertSame(1, substr_count($html, 'style="'), 'Nur ein style-Attribut.');
|
||||
|
||||
foreach (Symbols::names(Symbols::SET_GLYPHS) as $name) {
|
||||
preg_match('/viewBox="([^"]*)"/', (string) file_get_contents(resource_path("svg/brand/glyphen/$name.svg")), $original);
|
||||
$this->assertStringContainsString('viewBox="'.$original[1].'"', (string) Symbols::glyph($name), "Glyphe $name bleibt unverändert");
|
||||
}
|
||||
}
|
||||
|
||||
public function test_attributes_of_the_component_are_kept_and_escaped(): void
|
||||
{
|
||||
$html = Blade::render('<x-brand.symbol name="play" class="extra" :data-x="$value" />', ['value' => 'a"b']);
|
||||
|
||||
Reference in new issue
Block a user