flarum / framework

Simple forum software for building great communities.
http://flarum.org/
6.39k stars 834 forks source link

fix: respect user theme preference #4033

Closed datlechin closed 2 months ago

datlechin commented 2 months ago

This PR fixes the issue where data-theme defaulted to auto, causing a flash of light mode before switching to dark. It ensures the theme respects the user's preference for a smoother experience.

Fixes #0000

Changes proposed in this pull request:

Reviewers should focus on:

Screenshot

QA

Necessity

Confirmed

Required changes:

datlechin commented 2 months ago

@SychO9 The logic behind auto is still preserved. If color_scheme is set to auto, it falls back to the user's browser preference via RequestUtil::getActor()->getPreference('colorScheme'). This ensures the same functionality while preventing the flash of light mode.

datlechin commented 2 months ago

Before:

https://github.com/user-attachments/assets/e197bf84-41de-419d-b0a5-43f089089d94


After:

https://github.com/user-attachments/assets/3c812b68-d6ae-41d6-b41c-c37f1aa050b9