Media query ordering changes when converting to object
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 38/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- javascript
- Domain
- frontend
Research direction
Start by reproducing the supplied CSS-to-object conversion and trace how media-query rules and default selectors are ordered. The fix is done when the converted object preserves the CSS cascade so the dark-mode media-query values remain effective; no specific source file or test is named in the issue.
Written by the indexing model from the issue text.
Description
I have a problem where a given rule's default definition (.leoButton.isSecondary) gets placed after the media query, which changes the behavior of the rendering. As such, the default overrides the media query, and the media query never takes effect.
Is this a known bug? Is there any known fix for this?
Input
.button.isPrimary {
--bg: var(--color-secondary-light-mode-70);
--bg-hover: var(--color-secondary-light-mode-80);
--bg-active: var(--color-secondary-light-mode-90);
--bg-focus: var(--color-secondary-light-mode-70);
--bg-loading: var(--color-secondary-light-mode-50);
--bg-disabled: var(--color-gray-70);
--color: white;
}
@media (prefers-color-scheme: dark) {
.button.isPrimary {
--bg: var(--color-secondary-dark-mode-50);
--bg-hover: var(--color-secondary-dark-mode-60);
--bg-active: var(--color-secondary-dark-mode-70);
--bg-loading: var(--color-secondary-dark-mode-60);
}
}
.button.isSecondary {
--bg: white;
--bg-active: --color-gray-20;
--color: var(--color-gray-90);
--color-hover: var(--color-secondary-light-mode-70);
--color-loading: var(--color-gray-70);
--border-width: 1px;
--border-color: var(--color-gray-30);
}
@media (prefers-color-scheme: dark) {
.button.isSecondary {
--bg: black;
--color-hover: var(--color-secondary-dark-mode-80);
}
}
Output
{
".button.isPrimary": {
"--bg": "var(--color-secondary-light-mode-70)",
"--bg-hover": "var(--color-secondary-light-mode-80)",
"--bg-active": "var(--color-secondary-light-mode-90)",
"--bg-focus": "var(--color-secondary-light-mode-70)",
"--bg-loading": "var(--color-secondary-light-mode-50)",
"--bg-disabled": "var(--color-gray-70)",
"--color": "white"
},
"@media (prefers-color-scheme: dark)": [
{
".button.isPrimary": {
"--bg": "var(--color-secondary-dark-mode-50)",
"--bg-hover": "var(--color-secondary-dark-mode-60)",
"--bg-active": "var(--color-secondary-dark-mode-70)",
"--bg-loading": "var(--color-secondary-dark-mode-60)"
}
},
{
".button.isSecondary": {
"--bg": "black",
"--color-hover": "var(--color-secondary-dark-mode-80)"
}
}
],
".button.isSecondary": {
"--bg": "white",
"--bg-active": "--color-gray-20",
"--color": "var(--color-gray-90)",
"--color-hover": "var(--color-secondary-light-mode-70)",
"--color-loading": "var(--color-gray-70)",
"--border-width": "1px",
"--border-color": "var(--color-gray-30)"
}
}
- Dominant language
- JavaScript
- Stars
- 667
- Forks
- 24
- PR merge metrics
- No merged PRs in 30d
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from postcss/postcss-js
-
.sync API Open
Difficulty 1/5 Under an hour Newbie friendliness 48/100
postcss/postcss-js#72 · 1 comment ·
-
Difficulty 4/5 3-5 days Newbie friendliness 25/100
postcss/postcss-js#64 · 3 comments ·
All issues in postcss/postcss-js
Similar issues
-
bug confirmed issue
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
open-webui/open-webui#30750 · 1 comment ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
Mend: dependency security vulnerability untriaged
Difficulty 2/5 1-3 hours Newbie friendliness 70/100