MadLittleMods / MadLittleMods/postcss-css-variables

When mixing vars with MQs, vars fallback if not redeclared

Open
#52 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
551
Forks
63
PR merge metrics
No merged PRs in 30d

Description

Quite a confusing title, I apologise. Essentially, if a variable is declared and altered in a MQ and then mixed in the same declaration as one that isn't, it falls back to its original value.

```
:root {
--gutter: 1rem;
--gutterLarge: 2rem;

@include mq(tablet) {
--gutter: 1.5rem;
--gutterLarge: 3rem;
}

@include mq(desktop) {
--gutterLarge: 4rem;
}
}

div {
padding: var(--gutter) var(--gutterLarge);
}
```

This will output:

```
div {
padding: 1rem 2rem;
}

@media (min-width: 46.25em) {
div {
padding: 1.5rem 3rem;
}
}

@media (min-width: 61.25em) {
div {
padding: 1rem 4rem;
}
}
```

I would expect the last one to be `1.5rem 4rem`.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the provided Sass-like input and comparing the generated CSS at the desktop breakpoint with the reported expectation. Trace the variable resolution and media-query handling from the plugin's entry point; done means the desktop output retains `--gutter`'s tablet value while applying the desktop `--gutterLarge` value, without regressing the other output.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
frontend, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.