less / less.js

Less. The dynamic stylesheet language.
http://lesscss.org
Apache License 2.0
16.99k stars 3.41k forks source link

Media query express support #3735

Closed woody-li closed 7 months ago

woody-li commented 2 years ago

A new range syntax introduced in Media Queries Level 4.

The syntax allow query expresses, includes range express.

But i got an error when using the syntax.

To reproduce:

@media (400px <= width <= 700px) {
    .main-box {
        display: flex;
    }
}

Current behavior:

less: Missing closing ')' in file test.less line no. 1

Expected behavior:

Convert to css with the syntax correctly

Environment information:

mud1tx commented 1 year ago

I think I can work on this issue. Can you please give some details about the issue?

woody-li commented 1 year ago

@mud1tx Thanks for your reply. I'd like to provide something, but I don't know what to provide.

matthew-dean commented 1 year ago

@mud1tx This isn't a bug, it's technically a feature request. So what needs to be added is support for range syntax in media queries. This would need to support merging as well.

That is, right now Less transforms this:

@media screen {
  @media (min-width: 1023px) {
    .selector {
      color: blue;
    }
  }
}

...into...

  @media screen and (min-width: 1023px) {
    .selector {
      color: blue;
    }
  }

So, tests would need to be added to convert:

@media (400px <= width) {
  @media (width <= 700px) {
    .main-box {
        display: flex;
    }
  }
}

into:

@media (400px <= width) and (width <= 700px) {
    .main-box {
        display: flex;
    }
}
jiadesen commented 1 year ago

me too

[vite:css] [less] Missing closing ')'

jiadesen commented 1 year ago

https://github.com/stylelint/stylelint/pull/6742

woody-li commented 7 months ago

The range syntax seems has been supported in version 4.2.0 by PR https://github.com/less/less.js/pull/3811