Skip to content

Improve color mode preference detection at initialization - #6093

Open
dfsmania wants to merge 1 commit into
ColorlibHQ:masterfrom
dfsmania:improve_color_mode_initialization
Open

Improve color mode preference detection at initialization#6093
dfsmania wants to merge 1 commit into
ColorlibHQ:masterfrom
dfsmania:improve_color_mode_initialization

Conversation

@dfsmania

@dfsmania dfsmania commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

This pull request refactors and improves the src/ts/color-mode.ts module, enhancing clarity, maintainability, and theme selection logic. The most important changes are grouped below:

Code organization and documentation improvements:

  • Improved and standardized section headers and comments throughout the file for better readability, and clarified the file-level documentation.

Theme selection and validation enhancements:

  • Introduced a new isValidTheme method to centralize and clarify theme value validation.
  • Added the getDataBsTheme method to support reading the theme from the data-bs-theme attribute, improving compatibility with server-side rendering and allowing theme selection via markup.
  • Enhanced the theme selection logic in getPreferredTheme to check, in order: localStorage, the markup attribute, and finally OS preference, for a more robust and predictable user experience.

Code clarity and maintainability:

  • Improved inline documentation and added comments to clarify logic in event listeners and initialization code, making the code easier to understand and maintain.
  • Added a docstring to _prefersDark for consistency.

…alization

On initialization, also detect whether data-bs-theme was predefined on the html tag
@netlify

netlify Bot commented Aug 5, 2026

Copy link
Copy Markdown

Deploy Preview for adminlte-v4 ready!

Name Link
🔨 Latest commit 5f298ad
🔍 Latest deploy log https://app.netlify.com/projects/adminlte-v4/deploys/6a729ebbd686c3000868872b
😎 Deploy Preview https://deploy-preview-6093--adminlte-v4.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

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.

1 participant