Skip to content

Add a light/dark/auto theme selector to the create-app layout#15941

Merged
jdaugherty merged 3 commits into
apache:8.0.xfrom
codeconsole:feat/create-app-theme-selector
Jul 9, 2026
Merged

Add a light/dark/auto theme selector to the create-app layout#15941
jdaugherty merged 3 commits into
apache:8.0.xfrom
codeconsole:feat/create-app-theme-selector

Conversation

@codeconsole

Copy link
Copy Markdown
Contributor

Summary

Adds a Bootstrap 5.3 color-mode (light / dark / auto) switcher to the default generated application, so a freshly created app can toggle and remember its theme out of the box. The generated layout already uses theme-aware Bootstrap utilities and grails.css already has [data-bs-theme=dark] rules — this wires up the missing UI + persistence.

Independent of, and additive to, the i18n language-selector PR (#15940); both live in the same navbar but neither depends on the other.

Changes

New theme.js asset (clean-room, ASF-licensed — not a copy of Bootstrap's CC-BY docs snippet)

  • Persists the choice in localStorage; toggles data-bs-theme on <html>; auto follows the OS via prefers-color-scheme and re-resolves on OS change.
  • Applied immediately on load and wired to the buttons on DOMContentLoaded (updates the active check + toggle icon).

Default layout (grails-forge template + classic web profile skeleton)

  • Loads theme.js in the <head> so the theme is set before the page paints (no flash of the wrong theme).
  • Adds a light/dark/auto dropdown to the navbar (Bootstrap Icons, already a dependency).

grails-forge AssetPipeline feature

  • Registers theme.js so it is copied into the generated app's grails-app/assets/javascripts/.

Tests

  • GrailsGspSpec gains a check that a generated WEB app ships theme.js, loads it in the head, and that the navbar offers the light/dark/auto options.

All green.

Add a Bootstrap 5.3 color-mode switcher to the default generated
application. A new theme.js asset persists the choice in localStorage and
toggles data-bs-theme on the document element ("auto" follows the
operating system); it is loaded in the document head so the theme is
applied before the page paints, avoiding a flash of the wrong theme. A
light/dark/auto dropdown is added to the navbar of both the grails-forge
template and the classic web profile skeleton, and theme.js is registered
as a generated asset in the grails-forge AssetPipeline feature.
@codeconsole codeconsole force-pushed the feat/create-app-theme-selector branch 2 times, most recently from f9ca048 to ea6589b Compare July 8, 2026 23:52
The "Installed plugins" table header used `table-light`, a fixed light
color that stayed light in dark mode and left the header illegible.
Remove the color class entirely rather than swap in another shade: the
header cells already carry `fw-semibold text-body-secondary` and the
table draws a divider border, so the header stays legible and follows the
active light/dark color mode with no fixed color. Applied to the
grails-forge template and the classic web profile skeleton.
@codeconsole codeconsole force-pushed the feat/create-app-theme-selector branch from ea6589b to 7260b17 Compare July 8, 2026 23:56
Pad the tinted namespace label bar (px-0 -> px-2) so the label no longer
sits flush against the tint edge, match the controller rows to the same
inset so they line up under the label, and add `list-group-item-action`
so a row highlights on hover (theme-adaptive). Applied to the grails-forge
template and the classic web profile skeleton.
@codeconsole codeconsole force-pushed the feat/create-app-theme-selector branch from 3aeca91 to ae0572e Compare July 9, 2026 00:05
@testlens-app

testlens-app Bot commented Jul 9, 2026

Copy link
Copy Markdown

✅ All tests passed ✅

🏷️ Commit: ae0572e
▶️ Tests: 10096 executed
⚪️ Checks: 59/59 completed


Learn more about TestLens at testlens.app.

@jdaugherty jdaugherty merged commit c4754b5 into apache:8.0.x Jul 9, 2026
105 of 106 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants