Fork me on GitHub
#biff
<
2022-05-15
>
robertfw08:05:36

A question about the tailwind integration - am I correct in reading the code that tailwind is only going to process HTML from anything listed under the :static key on the features map? That is, if I return some HTML snippet from a handler listed under :routes, any tailwind classes used won't get compiled?

jeffparker15:05:20

Are you defining new tailwind classes in resources/tailwind.css, for example .btn and .btn-secondary here? https://github.com/jacobobryant/platypub/blob/62c8d46989c96b4ce064d26bb9721576017a37da/resources/tailwind.css#L28 They get compiled and are available throughout, I believe. See also how to add custom styles in resources/tailwind.config.js if you're creating completely new styles : https://tailwindcss.com/docs/adding-custom-styles

robertfw16:05:57

No, nothing custom so far (though that would be a workaround I suppose). Just want to confirm that I'd need to somehow inform tailwind of any classes being used outside of :static

robertfw16:05:14

the wheels are turning in my head about some macro that wraps any html, in production it just evaluates back into e.g. a def but in dev mode it registers any elements/classes it sees and spits them all out into a file that can be shown to the tailwind compiler

Jacob O'Bryant17:05:29

Tailwind will read all code, not just code included under :static. see this line: https://github.com/jacobobryant/biff/blob/3ed303c1d5f26eef54f1561404e6e226c7978347/example/resources/tailwind.config.js#L3 tailwind doesn't parse the Clojure code, it just uses regex to look for classes within any files in the src directory.

Jacob O'Bryant17:05:01

an implication of that is that you shouldn't do something like [:div {:class (str "text-" "red")} "hello"] because it would break the regex

robertfw17:05:28

Oh, excellent! I was misunderstanding then, I thought tailwind made links between elements and the classes they used, e.g. "I see a <p> using someClass so I need to emit p.someClass. Glad to hear it's more general than that. Thanks!

🙂 1
Jacob O'Bryant17:05:51

you're welcome!