Skip to content

Early color scheme#983

Merged
garronej merged 3 commits intomainfrom
early-color-scheme
Jan 14, 2026
Merged

Early color scheme#983
garronej merged 3 commits intomainfrom
early-color-scheme

Conversation

@garronej
Copy link
Copy Markdown
Collaborator

@garronej garronej commented Jan 13, 2026

Summary by CodeRabbit

  • New Features

    • Added support for early color-scheme scripts in themes to avoid color flashes during page load.
    • Static resource processing now includes SPA (Single-Page Application) themes so extension assets are transformed for all theme types.
  • Chores

    • Updated package version to 11.14.0-rc.1

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jan 13, 2026

📝 Walkthrough

Walkthrough

Detects per-theme presence of an early-color-scheme.js file, exposes that info on BuildContext, injects the script into generated FTL head when present, removes an early SPA-only early-exit so extension static resources are processed for SPA themes, and annotates extension files referencing the early-color-scheme script.

Changes

Cohort / File(s) Summary
Version Update
package.json
Bumped package version to 11.14.0-rc.1
Constants Definition
src/bin/shared/constants.ts
Added EARLY_COLOR_SCHEME_SCRIPT_BASENAME = "early-color-scheme.js"
Build Context
src/bin/shared/buildContext.ts
Added hasEarlyColorSchemeScript to implementedThemeTypes for login, account, admin; compute paths and check filesystem for early-color-scheme.js
FTL Generation
src/bin/keycloakify/generateFtl/generateFtl.ts
BuildContextLike now includes implementedThemeTypes; conditionally injects <script src=".../early-color-scheme.js"> into <head> when theme reports hasEarlyColorSchemeScript
Resource Processing
src/bin/keycloakify/generateResources/generateResources.ts
Removed early-exit for SPA in extension static resource handling so extension public resources are processed for SPA themes too
Extension Sync
src/bin/sync-extensions/getExtensionModuleFileSourceCodeReadyToBeCopied.ts
Detects early-color-scheme script files and appends related note to generated file comments (ownership/non-ownership paths)

Sequence Diagram(s)

sequenceDiagram
  participant CLI as Keycloakify CLI
  participant BC as BuildContext
  participant FS as FileSystem
  participant FTL as FTL Generator
  participant Resources as Resource Processor
  CLI->>BC: getBuildContext()
  BC->>FS: check theme public paths for early-color-scheme.js
  FS-->>BC: existence boolean per theme
  CLI->>FTL: generate FTL using BuildContext
  FTL->>BC: read implementedThemeTypes for theme
  FTL-->>FTL: inject early-color-scheme.js <script> if flagged
  CLI->>Resources: generateResources using BuildContext
  Resources->>FS: transform/copy extension public resources (no SPA early-exit)
  FS-->>Resources: copied resources (including early-color-scheme.js)
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Possibly related PRs

  • Sync extentions public #861: Modifies src/bin/sync-extensions/* and touches extension comment/handling—strongly related to the extension-file comment changes here.
  • Tokyo #866: Changes to src/bin/shared/buildContext.ts and BuildContext shape—related to the BuildContext type/logic updates in this PR.
  • Next #860: Adds calls/consumers of getBuildContext/implementedThemeTypes, likely affected by the new BuildContext field.

Poem

🐰 I sniffed the public path at dawn,
Found an early script to hop upon,
I told BuildContext, then I leapt—
Into heads it softly crept,
Themes awaken, colors drawn 🌈

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title "Early color scheme" directly reflects the main feature being implemented: automatic importing of early-color-scheme.js files into the of Keycloak pages.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings


📜 Recent review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 232c48d and ce53079.

📒 Files selected for processing (1)
  • src/bin/sync-extensions/getExtensionModuleFileSourceCodeReadyToBeCopied.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/bin/sync-extensions/getExtensionModuleFileSourceCodeReadyToBeCopied.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Test with Node v18 on ubuntu-latest

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@garronej
Copy link
Copy Markdown
Collaborator Author

garronej commented Jan 13, 2026

Hello @Oussemasahbeni,

This PR makes it so that if there is a file like public/keycloak-theme/[login|account|admin]/early-color-scheme.js it will be automatically imported in the <head/> of the pages rendered by keycloak.

If you update https://github.com/Oussemasahbeni/keycloakify-shadcn-starter so the NPM package includes include keycloak-theme/public/login/early-color-scheme.js, it will be automatically copied to the user's project in public/keycloak-theme/login/early-color-scheme.js and then automatically imported by Keycloakify.

Bottom line: The users won't have to edit the index.html.

@Oussemasahbeni
Copy link
Copy Markdown
Contributor

Hello @garronej
Looks good to me, this will provide a better and easier UX. Do we need to mention this in the docs?

@garronej
Copy link
Copy Markdown
Collaborator Author

@Oussemasahbeni if you're reffering to this doc: https://docs.keycloakify.dev/starter-themes/shadcn-ui-tailwind

No, nothing need to be added, that's the point. However a new version of @oussemasahbeni/keycloakify-login-shadcn should be released that includes keycloak-theme/public/login/early-color-scheme.js

@garronej garronej merged commit e207bb1 into main Jan 14, 2026
3 checks passed
@garronej garronej deleted the early-color-scheme branch January 14, 2026 18:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants