Fork me on GitHub
#hyperfiddle
<
2023-02-25
>
adamfrey16:02:17

I am attempting to use the shadow-css library with electric. Shadow-css has one main macro css which outputs a class string (https://github.com/thheller/shadow-css#using-the-css-macro). When I try to use that macro and write:

(dom/h1 (dom/props {:class (css {:color "red"})})
            (dom/text "minimal todo list"))
I get this error:
(def electric-main
   8 |   (hyperfiddle.electric/boot ; Electric macroexpansion - Clojure to signals compiler
---------^----------------------------------------------------------------------
 Can't take value of macro shadow.css/css
Is that expected behavior at this point? Or is there a different way I could use this library with electric?

👀 2
Dustin Getz17:02:42

trying to repro

J17:02:37

I like put the styles in a global map as:

(def styles
  {:my-component/container (css :flex)
   :my-component/title (css :text-gray-800)})
And in electric component:
(dom/h1 (dom/props {:class (styles :my-component/title)}))
This method works perfectly with electric

adamfrey17:02:10

true, but then I have to give names to everything, which I'd prefer not to be required to do everywhere

Dustin Getz17:02:09

i've reproduced but don't understand it, will need to pass it on to the team

Geoffrey Gaillard17:02:16

This is a bug in the handling of :class . :class can take a string or a collection of strings. Here the props macro thinks (css ...) is a list of classes.

💡 2
adamfrey17:02:26

ah, I see. ok, I can workaround for now with J's suggestion until there's a fix. Thanks for looking into this so quickly!

🙂 2
Geoffrey Gaillard09:02:55

This is fixed on latest master