feat(design): render a lockup on brand chrome in the frame text color

A generated lockup drew its title in the primary color with an
on-primary outline. On a header or sidebar that a role maps onto the
frame token, that put primary-colored text on a primary-toned ground.

A slot now takes `frame: true` in the role's design entry. The asset
action receives a second color pair from the palette, the on-frame
color as fill and the frame color as outline, and the renderer picks
the pair per slot. Slots without the flag render as before.

Keycloak calls the asset action directly and already rendered its
brand slot in the on-frame color, so it passes that color for both
pairs and keeps its output.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
kevinveenbirkenbachandClaude Opus 5.5 committed 2026-10-07 15:38:09 +02:00
1 parent 1cbbb8adbc
commit 724c4c2b5d
10 files changed
+71 -27

No files matched your search

@@ -121,6 +121,14 @@ class TestResolveBranding(unittest.TestCase):
self.assertFalse(slots["icon"]["text_only"])
self.assertTrue(slots["login"]["text_only"])
def test_slot_carries_the_frame_flag(self) -> None:
apps = self._apps(
{}, {"slots": {"topbar": {"width": 320, "height": 64, "frame": True}}}
)
slots = resolve_branding(apps, "web-app-a", self.root)["slots"]
self.assertTrue(slots["topbar"]["frame"])
self.assertFalse(slots["icon"]["frame"])
def test_missing_logo_file_fails_loudly(self) -> None:
with self.assertRaisesRegex(ValueError, "not found"):
resolve_branding(
+21 -10
View File
@@ -42,15 +42,17 @@ class TestChooseLayout(unittest.TestCase):
class TestRenderAssets(unittest.TestCase):
SLOTS: ClassVar[dict] = {
"icon": {"width": 512, "height": 512, "text_only": False},
"header": {"width": 320, "height": 64, "text_only": False},
"banner": {"width": 960, "height": 160, "text_only": False},
"wordmark": {"width": 320, "height": 64, "text_only": True},
"icon": {"width": 512, "height": 512, "text_only": False, "frame": False},
"header": {"width": 320, "height": 64, "text_only": False, "frame": False},
"banner": {"width": 960, "height": 160, "text_only": False, "frame": False},
"wordmark": {"width": 320, "height": 64, "text_only": True, "frame": False},
"topbar": {"width": 320, "height": 64, "text_only": False, "frame": True},
}
COLORS: ClassVar[tuple] = ("#001f3f", "#ffffff", "#fefefe", "#00152c")
def test_every_slot_renders_png_and_svg_at_its_size(self) -> None:
assets = render_assets(
LOGO, "Gitea", "git.example.org", "#001f3f", "#ffffff", self.SLOTS
LOGO, "Gitea", "git.example.org", *self.COLORS, self.SLOTS
)
for name, spec in self.SLOTS.items():
with self.subTest(slot=name):
@@ -64,7 +66,7 @@ class TestRenderAssets(unittest.TestCase):
def test_text_carries_fill_and_outline(self) -> None:
assets = render_assets(
LOGO, "Gitea", "git.example.org", "#001f3f", "#ffffff", self.SLOTS
LOGO, "Gitea", "git.example.org", *self.COLORS, self.SLOTS
)
texts = TEXT_RE.findall(assets["banner.svg"].decode("utf-8"))
self.assertEqual(
@@ -75,17 +77,26 @@ class TestRenderAssets(unittest.TestCase):
self.assertIn('stroke="#ffffff"', attrs)
self.assertIn("textLength=", attrs)
def test_frame_slot_takes_the_frame_colors(self) -> None:
assets = render_assets(
LOGO, "Gitea", "git.example.org", *self.COLORS, self.SLOTS
)
texts = TEXT_RE.findall(assets["topbar.svg"].decode("utf-8"))
self.assertEqual([content for _, content in texts], ["Gitea"])
for attrs, _ in texts:
self.assertIn('fill="#fefefe"', attrs)
self.assertIn('stroke="#00152c"', attrs)
self.assertNotEqual(assets["topbar.png"], assets["header.png"])
def test_favicon_holds_every_size(self) -> None:
assets = render_assets(
LOGO, "Gitea", "git.example.org", "#001f3f", "#ffffff", self.SLOTS
LOGO, "Gitea", "git.example.org", *self.COLORS, self.SLOTS
)
icon = Image.open(io.BytesIO(assets["favicon.ico"]))
self.assertEqual(icon.info["sizes"], {(16, 16), (32, 32), (48, 48), (64, 64)})
def test_disabled_title_drops_text_only_slots_and_text(self) -> None:
assets = render_assets(
LOGO, False, "git.example.org", "#001f3f", "#ffffff", self.SLOTS
)
assets = render_assets(LOGO, False, "git.example.org", *self.COLORS, self.SLOTS)
self.assertNotIn("wordmark.png", assets)
self.assertNotIn(b"<text", assets["banner.svg"])