This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-01-30
Channels
- # announcements (20)
- # asami (26)
- # babashka (10)
- # babashka-sci-dev (18)
- # beginners (81)
- # biff (6)
- # calva (6)
- # cider (1)
- # clerk (1)
- # clj-kondo (34)
- # clojure (50)
- # clojure-belgium (1)
- # clojure-berlin (6)
- # clojure-europe (20)
- # clojure-nl (1)
- # clojure-norway (22)
- # clojure-uk (2)
- # clojurescript (1)
- # clr (4)
- # community-development (3)
- # data-science (8)
- # datomic (3)
- # gratitude (1)
- # honeysql (6)
- # instaparse (2)
- # jobs (1)
- # jobs-discuss (13)
- # kaocha (7)
- # london-clojurians (1)
- # lsp (6)
- # malli (8)
- # matcher-combinators (9)
- # missionary (3)
- # nbb (8)
- # off-topic (20)
- # pathom (16)
- # polylith (2)
- # practicalli (3)
- # rdf (1)
- # re-frame (7)
- # reagent (3)
- # releases (2)
- # reveal (6)
- # rewrite-clj (22)
- # shadow-cljs (64)
- # tools-build (7)
- # xtdb (13)
Anyone here have experience using the class-tools
extension for htmx? https://htmx.org/extensions/class-tools/ On paper, it looks like a great and simple fit with Tailwind classes, but I've encountered a few twists in my explorations, and I wouldn't mind comparing notes.
Here are the 2 rough edges I stumbled upon, which I think I have solutions for, but I'm not convinced they're the best solutions. Let's say I want to make a <div>
that blushes when its first added to the DOM. It changes its background color briefly, to draw the eye. It seems I could do that with something like this: [:div {:class "ease-in-out transition-colors duration-1000" :classes "add bg-rose-400, remove bg-rose-400:2s"} "I'm new here!"]
The first peril is this: https://github.com/bigskysoftware/htmx/issues/917 Currently, it doesn't look like class-tools
handles a series of operations all that well. Fortunately the source code for class-tools
is small and straight-forward enough that even with my meager JS skills I was able to implement the changes suggested in the issue with a local copy. I essentially replaced a bunch of var
s with let
s and pulled all the setTimeout
s out into their own functions and it all seems to work.
The second issue, I suspect, has to do with how Tailwind searches the code for the presence of Tailwind classes. If I'm not using bg-rose-400
anywhere else in my code, it won't appear in the stylesheet that Tailwind prepares. class-tools
needs things to be written exactly this way "add bg-rose-400, remove bg-rose-400:2s"
where that ,
immediately follows the first bg-rose-400
and the :2s
immediately follows the second. No spaces. And I'm wondering if that's throwing Tailwind off the scent.
:thinking_face: Might explore a hyperscript solution to this instead.
tailwind's safelist thing should do the trick for the second issue: https://clojurians.slack.com/archives/C013Y4VG20J/p1673008653251949?thread_ts=1672911679.562159&cid=C013Y4VG20J
Sounds like @1cg
would be down for a pull request if you wanted to submit the changes you already implemented! https://github.com/bigskysoftware/htmx/issues/917#issuecomment-1139131300
I've never done a pull request before! A new adventure! Time to read up on how that works.
I was thinking about using Tailwind's safelist feature. Especially since it's a color property and I'm already considering adding a bunch of those to the safelist to allow for user customization.
Inspired by the advice to use a map given https://tailwindcss.com/docs/content-configuration#dynamic-class-names, I've also been considering writing some Clojure that collects all the classes I want along with how I want them added, removed, or toggled, and then writes the class-tools
runs for me.