Let a header that paints its own surface show through while sticky
A section in the header set to #ffffff00 for the scrolled page still looked white: the sticky header element paints its own white surface and a shadow line underneath, so a transparent section showed that surface instead of the page, and the line could be neither recoloured nor removed. When a top-level header section defines a background of its own - normal, hover or scrolled - the header element now gets `has-own-surface` and paints nothing. A header without its own design keeps the white surface, so it does not turn see-through over the content. A text colour alone is not a surface, and a boxed column is not the whole header. The check is a Twig function rather than a controller variable because four paths render the header: page, archive, editor preview and area preview. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
fb7cfa37d1
commit
a4ee04533c
5 files changed
+85
-2
No files matched your search
@@ -810,6 +810,29 @@ final class CmsTest extends TestCase
|
||||
self::assertStringContainsString('class="site-header is-sticky"', $this->request('/')->getContent());
|
||||
}
|
||||
|
||||
/**
|
||||
* Ein Kopfbereich mit eigener Fläche bekommt keine zweite dahinter.
|
||||
*
|
||||
* Beim Nachbau der Tagespflege war die Sektion beim Scrollen auf #ffffff00 gestellt und blieb
|
||||
* trotzdem weiß: der klebende Kopf malte seine eigene Fläche und Schattenlinie darunter.
|
||||
*/
|
||||
public function testAHeaderThatPaintsItsOwnSurfaceGetsNoSecondOne(): void
|
||||
{
|
||||
$settings = $this->site->load();
|
||||
$this->site->save([...$settings, 'stickyHeader' => true, 'sameAs' => '', 'consentGroups' => $settings['consentGroups']]);
|
||||
self::assertStringContainsString('class="site-header is-sticky"', $this->request('/')->getContent(), 'Ohne eigene Fläche bleibt die weiße des Kopfes.');
|
||||
|
||||
self::assertTrue(\App\Twig\HeaderExtension::ownSurface(['blocks' => [['id' => 's', 'type' => 'section', 'style' => ['desktop' => ['scrolled' => ['backgroundColor' => '#ffffff00']]]]]]));
|
||||
self::assertTrue(\App\Twig\HeaderExtension::ownSurface(['blocks' => [['id' => 's', 'type' => 'section', 'style' => ['mobile' => ['backgroundColor' => '#294655']]]]]));
|
||||
// Eine Textfarbe ist keine Fläche, und ein Kasten in einer Spalte macht noch keinen Kopf.
|
||||
self::assertFalse(\App\Twig\HeaderExtension::ownSurface(['blocks' => [['id' => 's', 'type' => 'section', 'style' => ['desktop' => ['color' => '#294655']]]]]));
|
||||
self::assertFalse(\App\Twig\HeaderExtension::ownSurface(['blocks' => [['id' => 's', 'type' => 'section', 'children' => [['id' => 'c', 'type' => 'column', 'style' => ['desktop' => ['backgroundColor' => '#ffffff']]]]]]]));
|
||||
self::assertFalse(\App\Twig\HeaderExtension::ownSurface(null));
|
||||
|
||||
$css = (string) file_get_contents(__DIR__.'/../public/assets/site.css');
|
||||
self::assertStringContainsString('.site-header.is-sticky.has-own-surface{background:transparent;box-shadow:none}', $css);
|
||||
}
|
||||
|
||||
/** @return iterable<string, array{string, bool}> */
|
||||
public static function imageLinks(): iterable
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user