Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

feat: enhance theme detection with auto mode and multiple strategies #235

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
brionmario wants to merge 1 commit into asgardeo:main
base: main
Choose a base branch
Loading
from brionmario:thunder

Conversation

@brionmario
Copy link
Member

@brionmario brionmario commented Nov 6, 2025
edited
Loading

Purpose

This pull request introduces a major refactor and enhancement to the theme detection and switching logic across the JavaScript, Browser, and React packages. It unifies and extends theme detection strategies, replacing the old 'class' mode with a more flexible 'auto' mode that supports detection via data attributes, CSS classes, and system preferences, with configurable strategy and priority. The React ThemeProvider and related APIs are updated to leverage these new capabilities, providing more robust and customizable theme handling.

Theme detection and configuration enhancements:

  • Added a new ThemeDetectionStrategy type and expanded the ThemeDetection interface to support detection via data attributes, CSS classes, and system preferences, with configurable strategy and priority ('auto' mode now replaces 'class' mode). [1] [2]
  • Introduced new observer utilities: createDataAttributeObserver and createAutoObserver for robust theme change detection based on the configured strategy and priority. [1] [2]
  • Refactored detectThemeMode to support the new strategies and fallback logic, and deprecated the 'class' mode in favor of 'auto'. [1] [2]
  • Updated exports and types to reflect new capabilities, including exporting ThemeDetectionStrategy and BrowserThemeDetection. [1] [2]

React ThemeProvider and context updates:

  • Updated the ThemeProvider to use the new 'auto' mode by default, support the new detection strategies, and clean up observers properly. The old 'class' and 'branding' modes are removed or replaced. [1] [2] [3] [4]
  • Updated the ThemeContext and related types to use the new ThemeMode and detection logic.

API and type improvements:

  • Improved the createTheme API to exclude runtime detection properties from its config, clarifying its intended use.
  • Updated theme config and detection types for better clarity and extensibility. [1] [2]

Code quality and consistency:

  • Refactored code for better naming, type safety, and maintainability (e.g., consistent use of DOMTokenList, explicit type annotations, and improved observer setup/cleanup). [1] [2]

These changes collectively provide a more flexible, reliable, and extensible foundation for theme management in applications using these packages.

Related Issues

Related PRs

  • N/A

Checklist

  • Followed the CONTRIBUTING guidelines.
  • Manual test round performed and verified.
  • Documentation provided. (Add links if there are any)
  • Unit tests provided. (Add links if there are any)

Security checks

Copy link

⚠️ No Changeset found

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go.

If these changes should result in a version bump, you need to add a changeset.

Refer Release Documentation to learn how to add a changeset.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

feat: detect the application color scheme automatically based on common strategies (class based, data attr based)

AltStyle によって変換されたページ (->オリジナル) /