pascalduez / postcss-apply

PostCSS plugin enabling custom properties sets references
The Unlicense
164 stars 12 forks source link

Only the first @apply gets the styles #34

Open enjikaka opened 7 years ago

enjikaka commented 7 years ago
:root {
  --gridify-media-information: {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    width: 100%;
    align-items: center;
    justify-content: center;
    transform: translateY(40vw);
  }
}

.type--video .media-information {
   @apply --gridify-media-information;
}

@media (orientation: portrait) and (min-aspect-ratio: 1/1) and (max-aspect-ratio: 1/1) {
   .type--album .media-information {
      @apply --gridify-media-information;
   }
}

produces;

.type--video .media-information {
   position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    width: 100%;
    align-items: center;
    justify-content: center;
    transform: translateY(40vw);
  }
}

@media (orientation: portrait) and (min-aspect-ratio: 1/1) and (max-aspect-ratio: 1/1) {
.type--album .media-information {}
}
pascalduez commented 7 years ago

Hi @enjikaka,

what version of postcss-apply are you using? The latest 0.8.0 fixes some issues with nested declarations.

No warning in console/shell? postcss-reporter is nice to have in your pipeline.

enjikaka commented 7 years ago

@pascalduez Using cssnext, it seems to be at 0.3.0 :(

Didn't get any warnings or errors no. Just an empty block.

pascalduez commented 7 years ago

It's most likely that postcss-apply will be removed from cssnext, so I doubt it will be upgraded.

You can just override it: npm i postcss-apply@latest -D.

pascalduez commented 7 years ago

@enjikaka You might be interested to know that custom property sets and the @apply rule are not in good shape, at the spec level: https://github.com/pascalduez/postcss-apply#web-platform-status

jarodtaylor commented 7 years ago

You might be interested to know that custom property sets and the @apply rule are not in good shape, at the spec level: https://github.com/pascalduez/postcss-apply#web-platform-status

That makes me sad, @pascalduez :(

It's so useful.

ZeroCho commented 7 years ago

@pascalduez I'm sad, too 😢 Is there any replacement for this among postcss plugins? postcss-loader@2 already does not support @apply feature... Or maybe any features that support mixins for cssnext?

pascalduez commented 7 years ago

@ZeroCho I don't think there's a new spec reproducing the "mixin" kind of behaviour, the promoted one is now tight to custom elements and the shadow DOM... Crawl those links in the Readme, there's a ton of infos.

There's a postcss-mixin plugin, which replicates Sass like mixins.

ZeroCho commented 7 years ago

@pascalduez Thank you! Actually I already read all those links you provided, I felt that shadow DOM and ::part things were weird, so that's why I asked you about the things between @apply and shadow DOM.

I'll try postcss-mixin! Thank you again! 😄