Skip to content

Conversation

puckowski
Copy link
Contributor

What:

Fix for issue #4242 that builds upon #4333 to add support for @layer at-rule.

Why:

The @layer at-rule has 94.47% (https://caniuse.com/mdn-css_at-rules_layer) browser support can support for the at-rule can benefit Less users.

Checklist:

  • Documentation
  • Added/updated unit tests
  • Code complete

* Add support for layer at-rule.
* Add tests for layer at-rule.
@dosubot dosubot bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Apr 7, 2025
Copy link
Member

@matthew-dean matthew-dean left a comment

Choose a reason for hiding this comment

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

LGTM!

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Apr 12, 2025
@luangong
Copy link

Hi! Does it support the following syntax?

@import "..." layer(...);

See @import - CSS | MDN.

@puckowski
Copy link
Contributor Author

Merging to avoid re-review and to keep future review scope small.

I have code for a separate PR to add support for:

@import url("theme.css") layer(theme);
@import url("features.css") layer(features) supports(display: grid);
@import url("responsive.css") layer(responsive) supports(display: flex) screen and (max-width: 768px);
@import url("print.css") layer(print) print;

@puckowski puckowski merged commit 36626c8 into less:master Apr 15, 2025
7 checks passed
@puckowski
Copy link
Contributor Author

Created a PR #4340 for supporting the following syntax:

@import url("theme.css") layer(theme);
@import url("features.css") layer(features) supports(display: grid);
@import url("responsive.css") layer(responsive) supports(display: flex) screen and (max-width: 768px);
@import url("print.css") layer(print) print;

@matthew-dean
Copy link
Member

@puckowski Hey, I figured out today you missed part of the @layer syntax, and it's currently causing a parsing error. Just wondered if you wanted to take a look.

You can do:

@layer framework.layout {
  p {
    margin-block: 1rem;
  }
}

See: https://developer.mozilla.org/en-US/docs/Web/CSS/@layer

@puckowski
Copy link
Contributor Author

puckowski commented Aug 10, 2025

@matthew-dean #4351 with #4349 should resolve that issue pending a release to npm (4.4.1).

This less:

@layer framework.layout {
    p {
        margin-block: 1rem;
    }
}

becomes this CSS:

@layer framework.layout {
  p {
    margin-block: 1rem;
  }
}

on latest master.

@matthew-dean
Copy link
Member

matthew-dean commented Aug 19, 2025

@puckowski Oh! My bad. I guess I missed publishing. Done.

@puckowski
Copy link
Contributor Author

Thank you for publishing @matthew-dean I did a quick test of 4.4.1 from a fresh install and it seems resolve the above @layer syntax issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lgtm This PR has been approved by a maintainer size:L This PR changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants