Git Product home page Git Product logo

Comments (13)

acidjazz avatar acidjazz commented on June 13, 2024 6

Hey everyone just a heads up i got a fork of stylus that properly renders @apply rules properly, give it a try please! @mehrunrasoli @olimorris

https://github.com/acidjazz/stylus

from discuss.

MartinMuzatko avatar MartinMuzatko commented on June 13, 2024 3

With @css I need to resign from using the shortcuts the preprocessor offers to me.
Why use a pre-processor then at all, if all my .styl files consist of @css {} blocks.

So no.. @css is at its best a dirty workaround, where I practically disable the pre-processor.
If I want to mix @apply together with nested rules (based on stylus syntax, not post-css @nest), or use mixins, variables etc. I need to at least double the css class definitions. So now I have my components css scattered, instead of one place.

from discuss.

acidjazz avatar acidjazz commented on June 13, 2024 2

I'm messing with different solutions to help remedy this situation, so far i've come up with a plugin that's easier on the eyes here

.kevin
  apply(bg-orange text-blue)
  border 20px solid blue

from discuss.

hybridvision avatar hybridvision commented on June 13, 2024 2

Hey @acidjazz, thanks so much for your Stylus fork! I've been using it in a project for a few months now and it has been solid. It's so nice to have Tailwind + Stylus together! 👍

from discuss.

hybridvision avatar hybridvision commented on June 13, 2024 2

Yes, good point - since @acidjazz's PR was merged into the Stylus core, this now works out of the box so this note in the documentation could be removed 🎉 The only requirement is using a Stylus version that is v0.54.6 or later...

The @screen directive still doesn't work in Stylus but there are workarounds and it's less common to need this.

from discuss.

adamwathan avatar adamwathan commented on June 13, 2024 1

from discuss.

acidjazz avatar acidjazz commented on June 13, 2024 1

i'm glad its working for ya @hybridvision !
lets get this PR merged!

from discuss.

mehrancodes avatar mehrancodes commented on June 13, 2024

@olimorris Thanks for sharing this.
But how about the situation when we want to use a state variant like hover with the @apply directive?

So if I have this style:

@css {
  .btn {
    @apply .hover\:shaddow
  }
  // OR like this
  .btn {
    @apply hover:shaddow
  }
}

It gives me this error

`@apply` cannot be used with `.hover\\\:shaddow` because `.hover\\\:shaddow` either cannot be found, or it's actual definition includes a pseudo-selector like :hover, :active, etc.

from discuss.

MartinMuzatko avatar MartinMuzatko commented on June 13, 2024

Same issue here. I also have trouble using @apply.
using @css is not really a great alternative :/

What is the proposed solution? First run postcss and then stylus?
Does stylus have a built-in function to include styles of other classes?

from discuss.

adamwathan avatar adamwathan commented on June 13, 2024

using @css is not really a great alternative :/

Why not?

What is the proposed solution? First run postcss and then stylus?

No, always run style first.

Does stylus have a built-in function to include styles of other classes?

No, only Less supports this out of the box.

from discuss.

adamwathan avatar adamwathan commented on June 13, 2024

Unfortunately that's a Stylus problem, nothing we can do about that. Personally I just use postcss-preset-env to get features like nesting, and don't use any preprocessors at all.

from discuss.

MartinMuzatko avatar MartinMuzatko commented on June 13, 2024

Of course it is not a problem of tailwind, I just hoped there were recommendations, other than that what was already said in the mentioned issue.
Thanks @adamwathan

from discuss.

tobias-kuendig avatar tobias-kuendig commented on June 13, 2024

So, I've been using tailwind today in a Vue project together with Stylus and added the following rule:

.modal
    @apply inset-0 fixed bg-white

Without noticing it at first, it looks like the apply rule is working as expected thanks to @acidjazz's PR!

Maybe it's time to update the documentation?

image

from discuss.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.