clojurescript

Brian Hicks 2026-02-10T21:46:13.403639Z

this might be silly, but… is there a way to set a style class on a hiccup/reagent/re-frame component the way you'd do with ^{:key some-key}? We have a transition function and it would eliminate a whole bunch of layout issues if we could add/remove classes of child nodes instead of wrapping in some arbitrary div.

p-himik 2026-02-10T22:10:12.210479Z

Can you elaborate on the transition function?

Brian Hicks 2026-02-10T22:11:41.384939Z

I'm not hugely up on it, but it seems to add and remove classes based on timeouts. Right now it's wrapping the children in a div which has these applied when necessary, which of course can do things like setting up new stacking contexts.

Brian Hicks 2026-02-10T22:11:52.319379Z

basically we use it to swoosh things on and off the page

p-himik 2026-02-10T22:14:12.464819Z

I'm afraid I still don't get the problem at all. What prevents you from just passing the right classes down to children? How would using metadata solve anything?

Brian Hicks 2026-02-10T22:14:53.081949Z

it's used to wrap a bunch of components, and IIUC we don't want to modify every single one to accept classes. (But yeah… that's probably the right way to go.)

p-himik 2026-02-10T22:18:04.186579Z

I see. Metadata cannot work here because it would require either magically passing className all the way down to React elements that result in DOM nodes, or modifying the DOM tree after it has been rendered. Yes, passing the classes around is the way to go. Alternatively, there are styling systems, CSS-in-JS. In at least some, you can define a particular class for a component, pass it down or hard-code it, and override what the class means at run time. But a huge overkill just for this task if you don't already use something like that.

Brian Hicks 2026-02-10T22:34:49.440009Z

all makes sense. Thank you 🙏

👍 1
2026-02-10T23:59:36.158099Z

It might seem absurd to modify the hiccup after a subroutine has composed it, but Clojure(Script) is super for data processing and hiccup is just data.

p-himik 2026-02-11T06:51:22.432539Z

That would require turning children components' hiccup into function calls.