diff --git a/docs/agents/action/design.md b/docs/agents/action/design.md index 6720eb90f2..998b51821a 100644 --- a/docs/agents/action/design.md +++ b/docs/agents/action/design.md @@ -54,7 +54,7 @@ For tokens, the cascade layer and the role stylesheet contract see [style.css](. - CSS variable design system: map the app's variables onto the tokens in `templates/style.css.j2`. - Bootstrap app: set `bootstrap: true` in the role's `design:` entry to link the shared component mapping. Replace the app's hard-coded colors in the role stylesheet, as [web-app-dashboard](../../../roles/web-app-dashboard/files/style.css) does. - No design of its own: the shared element defaults apply. The role stylesheet only covers what stays hard-coded. -5. Set logo and title through the app's own mechanism from `lookup('design', application_id)`. Declare the slot sizes the app renders in the role's `design:` entry: measure the box the app gives its logo in every place (expanded and collapsed navigation, sign-in page) and size one slot per shape. Where the app shows a symbol plus a wordmark, declare a wide slot, so the generated lockup carries the title next to the logo. A lone symbol in a wide box is a defect. +5. Set logo and title through the app's own mechanism from `lookup('design', application_id)`. Declare the slot sizes the app renders in the role's `design:` entry: measure the box the app gives its logo in every place (expanded and collapsed navigation, sign-in page) and size one slot per shape. Where the app shows a symbol plus a wordmark, declare a wide slot, so the generated lockup carries the title next to the logo. A lone symbol in a wide box is a defect. A slot the app shows on brand-colored chrome (a header, sidebar or sign-in background mapped onto `--design-frame`) gets `frame: true`: its text is then rendered in the frame text color. A slot on a page or panel stays without it. 6. An app with its own theme switch ships `templates/design.js.j2` that mirrors the chosen theme into `data-design-theme` on ``. 7. Iterate without a second full deploy: - a changed stylesheet or logo: `make design-sync app= variant=0`, diff --git a/docs/requirements/037-corporate-design-overhaul.md b/docs/requirements/037-corporate-design-overhaul.md index f3b2ecec8f..ba2b9c9b92 100644 --- a/docs/requirements/037-corporate-design-overhaul.md +++ b/docs/requirements/037-corporate-design-overhaul.md @@ -15,7 +15,7 @@ These choices are settled at requirement creation time and bound the implementat 5. **Clean, flat base style.** No gradients on form controls and tables, subtle elevation shadows, one radius scale, 4/8 px spacing, visible focus rings, form state shown by border and icon. Font is the `system-ui` stack; `design.font` stays configurable. The shared element styles sit in the cascade layer `infinito-design`, so an app's own design system always wins over them and keeps its contrast relations. Such an app takes the palette through its own configuration first: a theming configuration, then an in-house theme or custom CSS option. Its role stylesheet maps the app's variables only for what no in-house option reaches. 6. **Dark mode.** An app's native theme toggle wins. Without one, the design follows `prefers-color-scheme`. No theme toggle is injected. 7. **Logo and title override semantics.** `design.logo` defaults to `assets/img/logo.png`, `design.title` defaults to `true`, which resolves to the role title (README H1). Set in `web-svc-design`, a value applies to every role. Set in a role's own `design:` entry, it applies to that role only. `false` or `0` disables the replacement for that scope. The legacy keys `title`, `titel`, `sitename` and `site_name` are migrated, the hardcoded titles in `web-app-joomla` and `web-app-pretix` are removed, and `web-app-decidim` and `web-app-socialhome` read the resolved title instead of `defaults_*`. -8. **Logo generator.** An SVG template renders the lockup, Pillow rasterises PNG and ICO variants. The variant is computed from the target slot format: square slot shows the logo only, wide slot shows logo and title, very wide or two-line slot adds the domain, text-only slot shows the title only. The background stays transparent. The text uses palette colors with an outline so it stands out on light and dark surfaces. +8. **Logo generator.** An SVG template renders the lockup, Pillow rasterises PNG and ICO variants. The variant is computed from the target slot format: square slot shows the logo only, wide slot shows logo and title, very wide or two-line slot adds the domain, text-only slot shows the title only. The background stays transparent. The text uses palette colors with an outline so it stands out on light and dark surfaces. A slot declared with `frame: true` sits on brand-colored chrome and takes the frame text color with a frame-colored outline. 9. **Branch and stack.** One branch `feature/designer` and one draft PR, opened once the base is approved. Exactly one compose stack runs at a time. Base changes land as base commits on the same branch. Role changes stay under `roles//` and are committed per role after approval. 10. **Verification.** Every change passes `make quality-high` and a minimal compose deploy against the running stack: `make compose-deploy apps= variant=0 disable=` (default `initialize` mode, no teardown, single pass, no `full_cycle`). CSS and branding iterations run without a redeploy through `make design-sync app= variant=0` (re-renders shared CSS, role `style.css` and the generated logo assets). A changed `design.js`, task, template or `meta/` file runs through `make compose-role-sync role= variant=0`, which re-runs only the app role against the running stack and renders the CSP hash in the vhost with it. A role pass runs the gate once, after its last edit, and repeats the compose deploy at its end only when it changed provisioning; any other pass closes with a role sync and the complete role spec. Each role is also asserted with one further base color, blue `#001f3f`, through `base=` on the sync targets. Swarm verification is out of scope. 11. **Review gallery.** Each role gets its own private Artifact with at least 20 views, each captured in light and dark mode and in a desktop (1440×900) and a mobile (390×844) viewport, so at least 80 before/after pairs per role. The views favour detail-rich surfaces: settings, administration, forms, lists and detail pages, logged in where the app has accounts, with idempotently seeded showcase content where a list or detail page would otherwise be empty. "Before" is the deployed app with every injected snippet stripped from the document (the body filter wraps its injections in `` markers), "after" is the same page with the corporate design. `make design-gallery app=` captures both sides in one spec run and copies them to `/tmp/design-gallery//`. The operator approves or rejects by comment. diff --git a/plugins/action/design_assets.py b/plugins/action/design_assets.py index 360291d102..209f8dc79a 100644 --- a/plugins/action/design_assets.py +++ b/plugins/action/design_assets.py @@ -9,7 +9,17 @@ from plugins.action.stack_host_copy import ActionModule as StackHostCopyAction from utils.design.branding import is_disabled from utils.design.logo import render_assets -_REQUIRED = ("logo", "title", "domain", "fill", "stroke", "slots", "dest") +_REQUIRED = ( + "logo", + "title", + "domain", + "fill", + "stroke", + "frame_fill", + "frame_stroke", + "slots", + "dest", +) class ActionModule(StackHostCopyAction): @@ -21,10 +31,12 @@ class ActionModule(StackHostCopyAction): logo absolute logo path title title text, or false domain role domain - fill text color - stroke text outline color - slots {name: {width, height, text_only}} - dest destination directory on the stack host + fill text color of a slot on a page or panel + stroke text outline color of a slot on a page or panel + frame_fill text color of a slot on brand-colored chrome + frame_stroke text outline color of a slot on brand-colored chrome + slots {name: {width, height, text_only, frame}} + dest destination directory on the stack host """ def run( @@ -47,6 +59,8 @@ class ActionModule(StackHostCopyAction): args["domain"], args["fill"], args["stroke"], + args["frame_fill"], + args["frame_stroke"], args["slots"], ) for name, content in assets.items(): diff --git a/plugins/lookup/design.py b/plugins/lookup/design.py index 689edf184e..16c8f8bf6d 100644 --- a/plugins/lookup/design.py +++ b/plugins/lookup/design.py @@ -21,7 +21,7 @@ class LookupModule(LookupBase): title title text, or False when the replacement is disabled name role README H1 label title, else name (for installers that require a site name) - slots {name: {width, height, text_only}} + slots {name: {width, height, text_only, frame}} domain canonical domain of the role dest CDN directory the generated assets are written to urls {"favicon_ico": url, "": {"png": url, "svg": url}} diff --git a/roles/sys-front-inj-design/tasks/assets.yml b/roles/sys-front-inj-design/tasks/assets.yml index 8c124c652a..207200f306 100644 --- a/roles/sys-front-inj-design/tasks/assets.yml +++ b/roles/sys-front-inj-design/tasks/assets.yml @@ -13,5 +13,7 @@ domain: "{{ design_branding.domain }}" fill: "{{ _palette.light['--design-primary'] }}" stroke: "{{ _palette.light['--design-on-primary'] }}" + frame_fill: "{{ _palette.light['--design-on-frame'] }}" + frame_stroke: "{{ _palette.light['--design-frame'] }}" slots: "{{ design_branding.slots }}" dest: "{{ design_assets_dest }}" diff --git a/roles/web-app-keycloak/tasks/utils/theme.yml b/roles/web-app-keycloak/tasks/utils/theme.yml index d7430cda31..d10a0fb915 100644 --- a/roles/web-app-keycloak/tasks/utils/theme.yml +++ b/roles/web-app-keycloak/tasks/utils/theme.yml @@ -24,6 +24,8 @@ domain: "{{ kc_design.domain }}" fill: "{{ KEYCLOAK_DESIGN_ON_FRAME }}" stroke: "{{ KEYCLOAK_DESIGN_ON_FRAME }}" + frame_fill: "{{ KEYCLOAK_DESIGN_ON_FRAME }}" + frame_stroke: "{{ KEYCLOAK_DESIGN_ON_FRAME }}" slots: "{{ {'brand': KEYCLOAK_DESIGN_BRAND} }}" dest: "{{ KEYCLOAK_DESIGN_DIR }}" diff --git a/tests/unit/python/utils/design/test_branding.py b/tests/unit/python/utils/design/test_branding.py index 4c538a3173..7342d42aa3 100644 --- a/tests/unit/python/utils/design/test_branding.py +++ b/tests/unit/python/utils/design/test_branding.py @@ -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( diff --git a/tests/unit/python/utils/design/test_logo.py b/tests/unit/python/utils/design/test_logo.py index 544887ac62..78c4311b38 100644 --- a/tests/unit/python/utils/design/test_logo.py +++ b/tests/unit/python/utils/design/test_logo.py @@ -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" dict[str, dict]: "width": width, "height": height, "text_only": bool(spec.get("text_only", False)), + "frame": bool(spec.get("frame", False)), } return slots @@ -95,10 +96,12 @@ def resolve_branding( ``{"logo": | False, "title": | False, "name": , "label": , "bootstrap": , - "slots": {name: {"width", "height", "text_only"}}}``. ``label`` serves - installers that require a site name even when the title replacement - is disabled. ``bootstrap`` tells whether the role links the shared - Bootstrap component mapping. + "slots": {name: {"width", "height", "text_only", "frame"}}}``. + ``label`` serves installers that require a site name even when the + title replacement is disabled. ``bootstrap`` tells whether the role + links the shared Bootstrap component mapping. A slot with ``frame`` + set is shown on brand-colored chrome, so its text takes the frame + text color. Raises: ValueError: When the logo file is missing, a slot is malformed or the diff --git a/utils/design/logo.py b/utils/design/logo.py index 29ddf0f053..1d993b02af 100644 --- a/utils/design/logo.py +++ b/utils/design/logo.py @@ -245,6 +245,8 @@ def render_assets( domain: str, fill: str, stroke: str, + frame_fill: str, + frame_stroke: str, slots: dict[str, dict], ) -> dict[str, bytes]: """Render every slot as PNG and SVG plus ``favicon.ico``. @@ -253,9 +255,11 @@ def render_assets( logo_path: Logo file. title: Title text, or ``False`` when titles are disabled. domain: Role domain. - fill: Text color. - stroke: Text outline color. - slots: ``{name: {"width", "height", "text_only"}}``. + fill: Text color of a slot on a page or panel. + stroke: Text outline color of a slot on a page or panel. + frame_fill: Text color of a slot on brand-colored chrome. + frame_stroke: Text outline color of a slot on brand-colored chrome. + slots: ``{name: {"width", "height", "text_only", "frame"}}``. Returns: ``{filename: content}``. @@ -272,8 +276,8 @@ def render_assets( logo_path, str(title), domain, - fill, - stroke, + frame_fill if spec["frame"] else fill, + frame_stroke if spec["frame"] else stroke, spec["width"], spec["height"], layout,