Biete Bildausschnitt und Zoom für Bilder und Videos in Widgets an (ADR-70)
Redaktionelle Karten erhalten je Karte Fokus und Zoom, Einstieg, Bild und Text sowie Premium-Karten zusätzlich einen Zoom (100 bis 250 Prozent, darunter entstünden leere Ränder). Die Darstellung ist reines CSS um den Fokuspunkt; Video und Clip folgen dem Ausschnitt. Die Regler zeigen beim Laden die Vorgabe statt 0 (FramingSlider). Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
7f9534d289
commit
9353e2e38a
29 files changed
+641
-40
No files matched your search
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Unit;
|
||||
|
||||
use App\Domain\Cms\Widgets\Support\ImageFraming;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class ImageFramingTest extends TestCase
|
||||
{
|
||||
public function test_zoom_stays_between_fill_and_the_cap_and_never_below_one_hundred(): void
|
||||
{
|
||||
$this->assertSame(100, ImageFraming::zoom(null));
|
||||
$this->assertSame(100, ImageFraming::zoom(''));
|
||||
$this->assertSame(100, ImageFraming::zoom('abc'));
|
||||
$this->assertSame(100, ImageFraming::zoom(0), 'Ein Regler ohne Wert gilt als „kein Zoom“.');
|
||||
$this->assertSame(100, ImageFraming::zoom(60), 'Weiter herauszoomen würde Ränder lassen.');
|
||||
$this->assertSame(180, ImageFraming::zoom('180'));
|
||||
$this->assertSame(250, ImageFraming::zoom(900));
|
||||
}
|
||||
|
||||
public function test_a_card_stores_the_framing_only_when_it_differs_from_the_default(): void
|
||||
{
|
||||
$this->assertSame([], ImageFraming::cleanItem([]));
|
||||
$this->assertSame([], ImageFraming::cleanItem(['focus_x' => 50, 'focus_y' => '50', 'zoom' => 100]));
|
||||
$this->assertSame(['focus_y' => 0], ImageFraming::cleanItem(['focus_x' => 50, 'focus_y' => 0]));
|
||||
$this->assertSame(['focus_x' => 30, 'focus_y' => 70, 'zoom' => 180], ImageFraming::cleanItem(['focus_x' => 30, 'focus_y' => 70, 'zoom' => 180]));
|
||||
$this->assertSame(['focus_x' => 100, 'zoom' => 250], ImageFraming::cleanItem(['focus_x' => 400, 'zoom' => 999]));
|
||||
}
|
||||
|
||||
public function test_widget_data_keeps_the_zoom_key_only_above_one_hundred(): void
|
||||
{
|
||||
$this->assertSame(['alt' => 'x'], ImageFraming::cleanZoom(['alt' => 'x', 'zoom' => 100]));
|
||||
$this->assertSame(['alt' => 'x'], ImageFraming::cleanZoom(['alt' => 'x', 'zoom' => 0]));
|
||||
$this->assertSame(['alt' => 'x', 'zoom' => 140], ImageFraming::cleanZoom(['alt' => 'x', 'zoom' => '140']));
|
||||
}
|
||||
|
||||
public function test_the_image_of_a_card_gets_a_style_only_when_something_differs(): void
|
||||
{
|
||||
$this->assertNull(ImageFraming::itemStyle([]));
|
||||
$this->assertNull(ImageFraming::itemStyle(['focus_x' => 50, 'focus_y' => 50, 'zoom' => 100]));
|
||||
$this->assertSame('object-position: 50% 0%', ImageFraming::itemStyle(['focus_y' => 0]));
|
||||
$this->assertSame('object-position: 30% 70%; transform-origin: 30% 70%; scale: 1.8', ImageFraming::itemStyle(['focus_x' => 30, 'focus_y' => 70, 'zoom' => 180]));
|
||||
}
|
||||
|
||||
public function test_a_zoomed_image_asks_the_browser_for_a_larger_version(): void
|
||||
{
|
||||
$this->assertSame('(min-width: 900px) 40vw, 100vw', ImageFraming::sizes('(min-width: 900px) 40vw, 100vw', 100));
|
||||
$this->assertSame('(min-width: 900px) calc(40vw * 2), calc(100vw * 2)', ImageFraming::sizes('(min-width: 900px) 40vw, 100vw', 200));
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user