Skip to content
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

Mosaic theme is using the same color for both light and dark modes #640

Closed
origami-z opened this issue Aug 30, 2024 · 1 comment · Fixed by #647
Closed

Mosaic theme is using the same color for both light and dark modes #640

origami-z opened this issue Aug 30, 2024 · 1 comment · Fixed by #647
Assignees
Labels
bug Something isn't working

Comments

@origami-z
Copy link
Contributor

One example -

[data-mode=light] ._651s9q6c, [data-mode=dark] ._651s9q6d, [data-mode=light] ._651s9q6e:hover, [data-mode=light] ._651s9q6e[data-dp-hover=true], [data-mode=dark] ._651s9q6f:hover, [data-mode=dark] ._651s9q6f[data-dp-hover=true], [data-mode=light] ._651s9q6g:visited, [data-mode=dark] ._651s9q6h:visited {
    color: var(--mosaic-color-dark-navigable-headingLink-regular);
}

I tracked it down around here:

export const linkColorProperties = defineProperties({
conditions: {
...lightModeConditions,
lightModeHover: { selector: `${lightMode} &:hover, ${lightMode} &[data-dp-hover="true"]` },
darkModeHover: { selector: `${darkMode} &:hover, ${darkMode} &[data-dp-hover="true"]` },
lightModeDisabled: { selector: `${lightMode} &:disabled` },
darkModeDisabled: { selector: `${darkMode} &:disabled` }
},
defaultCondition: 'lightMode',
properties: {
color: [
...Object.values(vars.color.light.navigable.link),
...Object.values(vars.color.dark.navigable.link)
]
}
});

Could also be around

export const lightModeConditions = {
lightMode: { selector: `${lightMode} &` },
darkMode: { selector: `${darkMode} &` }
};

...lightModeConditions,

@origami-z
Copy link
Contributor Author

origami-z commented Sep 2, 2024

Each property (e.g. ...Object.values(vars.color.light.navigable.documentLink),) in properties are defined for all possible conditions, which generated CSS listed on the issue.

I tried (see below) defining separate light and dark properties, and pass them to createSprinkles, however, vanilla-extract will throw build error. It seems that color property available values are only resolved to whichever is passed in 2nd, maybe somewhere internally some overrides happened..?

export const lightDocumentLinkColorProperties = defineProperties({
  conditions: {
    ...lightModeCondition,
    lightModeHover: { selector: `${lightMode} &:hover, ${lightMode} &[data-dp-hover="true"]` },
    lightModeVisited: { selector: `${lightMode} &:visited` },
    lightModeDisabled: { selector: `${lightMode} &:disabled` }
  },
  defaultCondition: false,
  properties: {
    color: [...Object.values(vars.color.light.navigable.documentLink)]
  }
});
export const darkDocumentLinkColorProperties = defineProperties({
  conditions: {
    ...darkModeCondition,
    darkModeHover: { selector: `${darkMode} &:hover, ${darkMode} &[data-dp-hover="true"]` },
    darkModeVisited: { selector: `${darkMode} &:visited` },
    darkModeDisabled: { selector: `${darkMode} &:disabled` }
  },
  defaultCondition: false,
  properties: {
    color: [...Object.values(vars.color.dark.navigable.documentLink)]
  }
});

export const documentLinkColorSprinkles = createSprinkles(
  lightDocumentLinkColorProperties,
  darkDocumentLinkColorProperties
);

with error

errors: [
    {
      detail: SprinklesError: "color" has no value "var(--mosaic-color-light-navigable-documentLink-regular)". Possible values are "var(--mosaic-color-dark-navigable-documentLink-regular)", "var(--mosaic-color-dark-navigable-documentLink-hover)", "var(--mosaic-color-dark-navigable-documentLink-disabled)", "var(--mosaic-color-dark-navigable-documentLink-visited)"

To debug change in theme, needs to run 4 dev processes

  1. cd packages/theme && yarn dev
  2. cd packages/components && yarn dev
  3. cd packages/site-preset-styles && yarn dev
  4. cd packages/site && yarn serve

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant