garden

fenton 2020-01-31T20:31:35.001600Z

anyone know how to write the garden clojurescript for grid-areas? in css they look like:

grid-template-areas: 
      ".  .  hd hd   hd   hd   hd   hd   ."
      "sd sd sd main main main main main main"
      "sd sd sd  ft  ft   ft   ft   ft   ft";
i tried something like:
:grid-template-areas
     [".  .  hd hd   hd   hd   hd   hd   ."
      "sd sd sd main main main main main main"
      "sd sd sd  ft  ft   ft   ft   ft   ft"]
but no dice.

noprompt 2020-01-31T20:41:47.001900Z

Can you elaborate?

fenton 2020-01-31T22:03:36.003100Z

well see the plain css one is three strings, terminated by a semi-colon... I'm not sure how to express three strings in clojurescript... tried putting them in a vector...but...

fenton 2020-01-31T22:08:45.003600Z

I think I can just escape the double quotes like so:

[:.wrapper
    {
     :display "grid"
     :grid-template-areas 
"
     \".  .  hd hd   hd   hd   hd   hd   .\"
      \"sd sd sd main main main main main main\"
      \"sd sd sd  ft  ft   ft   ft   ft   ft\"
"
     }]

noprompt 2020-01-31T22:10:48.004600Z

I see. I’m not familiar with this. Another, perhaps more robust, way to do that would be to use pr-str.

noprompt 2020-01-31T22:13:01.006200Z

(defn grid-template-areas [areas]
  {:grid-template-areas (reduce str (map pr-str areas))})
where areas are the strings in the vectors you gave.

noprompt 2020-01-31T22:13:47.006700Z

If you need them separated somehow you can use clojure.string/join instead of (reduce str ,,,)

fenton 2020-01-31T22:14:01.007Z

yeah, that works and looks better

(pr-str ".  .  hd hd   hd   hd   hd   hd   ."
             "sd sd sd main main main main main main"
             "sd sd sd  ft  ft   ft   ft   ft   ft")

noprompt 2020-01-31T22:14:30.007400Z

Awesome!

noprompt 2020-01-31T22:14:54.008100Z

Heh, I didn’t know you could pass multiple args to pr-str. 😄

fenton 2020-01-31T22:15:18.008400Z

yeah, i just dropped the vector as, yeah cool right! thank you very much sir! 🙂