postcss / postcss-nested

PostCSS plugin to unwrap nested rules like how Sass does it.
MIT License
1.15k stars 66 forks source link

@page at-rule could be allowed to nest #75

Closed niksajanjic closed 5 years ago

niksajanjic commented 6 years ago

https://developer.mozilla.org/en-US/docs/Web/CSS/%40page https://www.w3.org/TR/css3-page/#using-named-pages

Is it possible to allow nesting for @page at-rule. Right now we have to write the rule like this:

@page {
  padding: 20px;
}

@page:first {
  padding: 10px;
}

It would be nice to allow us to write:

@page {
  padding: 20px;

  &:first {
    padding: 10px;
  }
}

Same goes with named @page at-rules:

@page report {
  padding: 20px;

  &:first {
    padding: 10px;
  }
}

Unfortunatelly, I can see an issue arrising with this example though:

@page {
  @top {
    padding: 20px;
  }
}

@page:first {
  @top {
    padding: 10px;
  }
}

Nested rules could be written something like this:

@page {
  @top {
    padding: 20px;
  }

  &:first {
    @top {
      padding: 10px;
    }
  }
}

So this might not be that straigthforward feature to implement. Just trying to start a discussion if this feature makes sense.

ai commented 6 years ago

To be honest I afraid to do it. It is not really expected behavior.

Maybe we should implement it in separated PostCS plugins? postcss-page-nested?

niksajanjic commented 6 years ago

Makes sense that it is a separate plugin, in which case this isn't an issue of this plugin and it could probably be closed. Unfortunately, I'm not competent enough to write postcss-page-nested at the moment.