Repository navigation
Let a custom project's theme add stylesheets - #40
Conversation
0f0d6d7 to
b4d92c5
Compare
b4d92c5 to
627c297
Compare
wborn
left a comment
There was a problem hiding this comment.
This is an initial AI-assisted review.
The addition of orStyles provides a straightforward mechanism for custom projects to extend the compiled OpenRemote Keycloak theme without rebuilding it.
The implementation is small and follows the intended behavior:
- Stylesheets are read from the theme's properties.
- Relative paths resolve against Keycloak's theme resources directory.
- Absolute HTTP(S) URLs are preserved.
- Stylesheets are appended after the bundle's own styles.
- Existing Keycloak
stylesproperties remain separate, preserving fallback theme behavior.
The README documents the configuration and explains why orStyles is needed instead of the standard styles property.
No additional code issues were identified in the three changed files.
A real child-theme deployment should still be tested to confirm that Keycloak supplies the expected resources URL and inherited properties, and that the custom stylesheet is actually loaded on an implemented page.
AI found no further issues in the reviewed change. Manual maintainer review is still needed before merge. This PR also remains marked as a draft.
627c297 to
3c6b9d7
Compare
3c6b9d7 to
cf5a13d
Compare
cf5a13d to
7bdefb8
Compare
richturner
left a comment
There was a problem hiding this comment.
This seems like a useful change, would it be much effort to include a mock example theme just for dev testing purposes?
94522fb to
dc20e37
Compare
1a373bc to
40238d4
Compare
A child theme with parent=openremote can override a page's .ftl and ship its own resources, but its CSS never loads: `styles=` in theme.properties becomes a <link> only in a FreeMarker theme, and these pages are a compiled bundle. The pages now read `orStyles` from the theme properties Keycloak already sends and append a <link> each, after the bundle's own so the child wins where specificity ties. Not Keycloak's own `styles=`, which is inherited from the fallback theme and renders the pages this theme does not implement.
40238d4 to
0cbfd88
Compare
Description
A child theme with
parent=openremotecan override a page's.ftland ship its own resources, but its CSS never loads:styles=intheme.propertiesbecomes a<link>only in a FreeMarker theme, and these pages are a compiled bundle. The one thing a custom project is most likely to want, is their own stylesheet. These changes allow a custom stylesheet to be applied on top of ours.Changelog
orStylesfrom the theme properties Keycloak already sends and writes a<link>per entry into the head, after the bundle's own so the child wins. Paths resolve against the theme'sresources, as Keycloak'sstyles=do, and an absolute URL is passed through.styles=. Appended, they arrived after the page had been built and painted in this theme's styling, and it visibly flipped; in WebKit the components were built before the child's rules existed at all.index.htmltherefore places the bundle's own tags itself, withinject: false.orStylesrather than Keycloak's ownstyles, which is inherited from the fallback theme and is what the pages this theme does not implement are rendered with: reading it would put the fallback theme's stylesheet on these pages, and declaring our own would take it away from theirs.orStyleswhenOR_CHILD_THEMEpoints at its login directory, and keeps the page hidden until they have loaded, as a real page does.yarn start:exampleruns it with a small example theme intheme/ui/dev-server/example-theme.Effect on custom projects
A theme mounted under
/deployment/keycloak/themeswithparent=openremoteandorStyles=css/custom.cssnow has that file loaded on every page this theme implements. With--spi-theme-cache-themes=false --spi-theme-static-max-age=-1on the container, editing it is a browser refresh.It can also be worked on without a container:
OR_CHILD_THEME=/path/to/custom/project/deployment/keycloak/themes/acme/login yarn startintheme/uiserves it to the dev server, which reloads the page when the stylesheet changes.That stylesheet is on the critical path, as Keycloak's
styles=has always been: a slow one is a slow login page. Two things it cannot hold back, both in the README: a web font withfont-display: swap, which is what Google Fonts' URLs ask for, and an entrance animation or transition that runs while the page is hidden for the realm's branding, which wants scoping underhtml:not(.or-booting).A realm that sets
stylesinmanager_config.jsonstill wins the brand colour: those are injected after everything else, and the demo configuration carries--or-app-color4by default. A child theme changes the rest, and the brand colour belongs to the realm.