garden

nmkip 2019-12-07T19:32:34.005Z

Hi, what's the most common way of using garden? Do you define all the styles inline using the css function?

(css [:body {:font-size "16px"}])

nmkip 2019-12-07T19:32:45.005300Z

or is there a way to create css classes?

nmkip 2019-12-07T19:33:19.005800Z

I found a macro names defstyles but I'm not sure how to use it

nmkip 2019-12-07T19:33:34.006100Z

also defstylesheet

nmkip 2019-12-07T19:34:21.006700Z

do you have a file full of defs like this:

(def body (css [:body {:font-size "16px"}]))

shaun-mahood 2019-12-07T20:24:08.010600Z

@nmkip I mainly use it to create my CSS file, using the defstylesheet macro. You can definitely create CSS classes. I’m on my phone right now, but should be near my computer and can post an example if you can’t figure it out before then

shaun-mahood 2019-12-07T20:25:11.012100Z

It’s really flexible, so if there’s a specific workflow you want to use it should be possible to get it working

nmkip 2019-12-07T20:30:24.012300Z

Ahh

nmkip 2019-12-07T20:30:35.012700Z

you create a clojure file to define a css file

nmkip 2019-12-07T20:30:59.013300Z

(ns todomvc.css
  (:require [garden.def :refer [defstyles]]))

(defstyles screen
  [:body {:color "red"}]
)
and then
lein garden once

nmkip 2019-12-07T20:31:04.013700Z

for example

shaun-mahood 2019-12-07T20:33:41.017700Z

Yeah, that’s a good way to do it! It works in CLJS as well - I’m generating my CSS file in CLJS and injecting it into my page so that I can hot reload it with figwheel (I’m using deps.edn and didn’t want to figure out a replacement for lein garden). I can write up how to do that if it sounds useful.

nmkip 2019-12-07T20:35:05.018700Z

Yes, later when you are near your computer 🙂 Thanks!! I prefer using deps.edn but reframe's github led me to lein hehehe

shaun-mahood 2019-12-07T20:39:48.023200Z

Yeah, most of the work in garden was done well before deps.edn existed, and re-frame is pretty straightforward to get setup in deps.edn as well.