Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b714dc8219 |
No files matched your search
@@ -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: 194 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 160 KiB |
@@ -48,6 +48,8 @@ ## 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`.
|
||||
- **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).
|
||||
|
||||
@@ -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));
|
||||
@@ -114,13 +132,23 @@ .lf-features__item {
|
||||
min-inline-size: 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* 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 +218,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 +245,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()) !!}
|
||||
@@ -9,7 +9,7 @@
|
||||
@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()
|
||||
@@ -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