clojurescript 2025-03-12

Is there a datetime type or wrapper that works for clojure and script? I've a bit of plain data analysis code in a .cljc file and have to do a bit of datetime based sorting -- pains me to have to switch it over to cljs just for that....

Came here to post this exact option 😄 We use it with great success.

Aha great - thank you both, on behalf of my inner anal retentive

👍 3

Any tailwind users, now would be a good time to ensure we get all use cases (and syntax sugars) officially covered: https://github.com/tailwindlabs/tailwindcss/pull/17087

I'm not a Tailwind user, but out of curiosity - how would extraction work for the following cases?

[:div {:class (when active? :active)} ...}

[:div {:class [:a [:b [:c :d]]]} ...]

(let [cls (cond
            a :a
            b :b)]
  [:div {:class cls} ...])

That is a good question. The tailwind folks are also asking:

In general, class names are regular values that can be fully dynamic. They can come from a local data transformation or from an opaque function. Someone could even be constructing them from symbols, or from data coming from the backend. So there's definitely no way to have a full list for the generic case. Although I suspect the same is true for JS. Partially why I'm not a huge fan of the class extraction approach. :) Not sure how useful it is, but I'd probably extract all the classes I actually use to a separate namespace that's required everywhere and explicitly feed Tailwind classnames from that namespace. That way, things are much more explicit, there's no "magic".

That would also "fix" the issue where Tailwind classes aren't valid keywords, so you have to mix keywords and strings or to rely on just strings.

Also if anyone knows a good clojurescript playground, he has asked me this on Discord: ‘’’ Do you know if there is any clojurescript playground for in the browser that actually works? All the ones listed on the official website are dead. https://clojurescript.org/community/resources#online-clojurescript-repls ‘’’

Klipse works for me, albeit I had to tell my browser to ignore some SSL error. Quite some time ago I made https://cljs.io/ - it still works, although it hasn't been updated since I made it.

But I don't know of anything that has the capacity to add libraries and render UI. Just plain REPL.

Ah, and there's also https://squint-cljs.github.io/squint/. Although it's not quite CLJS. For example, keywords actually become strings.

I am not a big fan of magic either, but I have to say that class extraction works amazingly well for Clojure in tailwind 3. Tailwind 4 barely worked at all for me.

I assume that it works well only because the way you create classes is rather tame. Or the matching is done via any kinds of strings in the compiled JS.

Yeah, trying to upgrade to the big changes in 4 was kind of what started this whole thing. Using the new CDN's (I also use Daisy UI) works just fine but any kind of compile step has been buggy

@p-himik obviously dynamic classes won't work, but I've been pleased to find it working with strings, keywords and symbols all over the place. I point it at the Clojure source files. It's fast too.

Oh, I didn't mean stuff like (keyword (str "a" "b")). I meant (if x :cls1 cls2). Given that in the linked discussion there's talk about specific class properties, it seems that even such plain dynamic usages go out the window.

No, that works well in v3

In that case, v3 probably looks at every single class-looking token in the code and potentially ends up bundling more classes than needed. But that's probably not a big deal.

If that's the case, and if my assumption about :class and :className based on the linked discussion is correct, maybe it's an option to avoid looking at the values of particular attributes in v4 and instead approach CLJS code in the same exact way as in v3 - without differentiating attributes and the rest of the code.

I think I'm going to move off of tailwind, it is getting more annoying than React with all the constant changes. In another project at work we used girouette and that worked better, and you can configure it to have the same type of classes.

Not clear to me which tailwind version this was merged in, but I've just updated to tailwind 4.0.15 in one project that was having class extraction issues and seems to be resolved.... I'm cautiously optimistic (though the initial issue appeared to have a random element -- another project with identical build config wasn't having any issues previously).

the playground is using tailwind 3, here's the code source https://github.com/roman01la/clojurescript-studio