Skip to content

Conversation

@stherzada
Copy link

@stherzada stherzada commented Nov 7, 2024

Hi people,

I noticed an issue where older versions of Safari weren't displaying theme colors correctly due to the lack of support for OKLCH. To resolve this, I created a fallback to ensure compatibility.

This fallback will be included at the start of every new project to prevent similar issues.

Here's a demonstration:

Without fallback:
https://www.loom.com/share/7c6acd9c3c4549f09316bcea84fa9c92

With fallback:
https://www.loom.com/share/9cad4d0804b443a28f464bb00cf0dfe3

@JonasJesus42 JonasJesus42 marked this pull request as draft November 7, 2024 20:03
@stherzada stherzada changed the title [Draft] Theme | Add Fallback in Theme Theme | Add Fallback in Theme Nov 7, 2024
@stherzada stherzada marked this pull request as ready for review November 7, 2024 20:12
}).map(([key, color]) => [key, toValue(color)] as [string, string]);

const fallbackVariables = Object.entries({
"--fallback-p": t["primary"],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Daisy UI theme uses the fallback variables as follow:

"primary": "var(--fallback-p,oklch(var(--p)/<alpha-value>))",

So, if fallback-* is used, the other variables are ignored.

Those variables should be set ONLY if oklch is not supported by browser.

See https://github.com/saadeghi/daisyui/blob/master/src/base/colors.css to a better approach:

@supports not (color: oklch(0% 0 0)) {
  :root {
    color-scheme: light;
    --fallback-p: #491eff;
    --fallback-pc: #d4dbff;

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.

4 participants