Git Product home page Git Product logo

Comments (6)

ccastillop avatar ccastillop commented on July 16, 2024 2

Hey @Tonksthebear

I am just sitting in front of my old 2012 mb pro, ready to start a new done-on-weekends e-commerce app with rails 6.1, hotwire and TailwindCSS. I also need a lot a few tweaks of CSS definitions for repetitive tags such as tables, forms, and specially buttons.

I think the big problem here is how can I have SM like tailwind's @apply using Sprockets. SASS has a @extend that works as @apply.

SASS has also @import to create chunks of CSS.

Therefore, I think is better to use SASS instead of helpers.
I will play around the idea...

from tailwindcss-rails.

jontebol avatar jontebol commented on July 16, 2024

I'm also wondering how to tackle the missing @apply. I love being able to use the asset pipeline instead of webpacker for tailwind, but not having @apply is a drawback for sure. Using rails-helpers/partials could work as a workaround, but doesn't feel quite as clean. Interested in how your experimentation goes @ccastillop!

from tailwindcss-rails.

leehericks avatar leehericks commented on July 16, 2024

This is interesting! 🤔
YAML? Where do you put this file?

from tailwindcss-rails.

Tonksthebear avatar Tonksthebear commented on July 16, 2024

@ccastillop I definitely get what you're saying. SASS would be best, but I assumed tailwind required the special @apply keyword because they need to do something special to actually @include the styles. So I just decided to do the quickest solution I could think of that felt relatively clean without diving into any source code.

@leehericks I have an internal gem I made for reusable components across my various projects, so I just added a namespaces config directory for that in my config directory.

config/namespace/styles.yml

Then I made a simple helper that just concats any styles from this file with the given arguments.

Ultimately though, tailwind jit mode makes the benefits of just using the node version outweigh the benefits of relying on strictly the asset pipeline. For my uses, I just use jit mode with webpacker and stick with asset pipeline for js. #50 has interesting suggestions for how to do this without webpacker (still node). I'm still using my yaml helper because I like seeing the actual classes in web inspector, vs @apply which would hide the actual classes behind the given class name (ex. .btn).

from tailwindcss-rails.

dhh avatar dhh commented on July 16, 2024

I'd be happy to see @apply implemented as a sprockets processor, if possible. Not going to rely on node for this particular gem. Please do open a PR if you end up exploring that!

from tailwindcss-rails.

Tonksthebear avatar Tonksthebear commented on July 16, 2024

Following back on this to provide some extra info. For anyone who needs @import because they aren't using a bundler, I made classy-yaml to solve this issue. It leverages YAML files in order to provide similar functionality.

from tailwindcss-rails.

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.