Fork me on GitHub
#garden
<
2019-12-07
>
nmkip19:12:34

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"}])

nmkip19:12:45

or is there a way to create css classes?

nmkip19:12:19

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

nmkip19:12:34

also defstylesheet

nmkip19:12:21

do you have a file full of defs like this:

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

shaun-mahood20:12:08

@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-mahood20:12:11

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

nmkip20:12:35

you create a clojure file to define a css file

nmkip20:12:59

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

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

nmkip20:12:04

for example

shaun-mahood20:12:41

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.

nmkip20:12:05

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

shaun-mahood20:12:48

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.