From 26d84c23bbda30059cae9afe4a081d4f764cf448 Mon Sep 17 00:00:00 2001 From: Donavan-Ross Costaras Date: Tue, 12 Sep 2023 13:12:50 +0100 Subject: [PATCH 1/3] . --- src/lambdaisland/ornament.cljc | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/src/lambdaisland/ornament.cljc b/src/lambdaisland/ornament.cljc index 8089314..d920867 100644 --- a/src/lambdaisland/ornament.cljc +++ b/src/lambdaisland/ornament.cljc @@ -103,8 +103,7 @@ - `:fonts`: map from keyword to font stack (comman separated string) - `:components`: sequence of Girouette components, each a map with `:id` (keyword), `:rules` (string, instaparse, can be omitted), and - `:garden` (map, or function taking instaparse results and returning Garden - map) + `:garden` (map, vector, or function; see below for details) - `:tw-version`: which Girouette defaults to use, either based on Tailwind v2, or v3. Valid values: 2, 3. @@ -112,20 +111,20 @@ generate a rule of the form `token-id = <'token-id'>`. `:garden` can be a function, in which case it receives a map with a - `:compoent-data` key containing the instaparse parse tree. Literal maps or + `:component-data` key containing the instaparse parse tree. Literal maps or vectors are wrapped in a function, in case the returned Garden is fixed. The resulting Garden styles are processed again as in `defstyled`, so you can use other Girouette or other tokens in there as well. Use `[:&]` for returning - multiple tokens/maps/stylesUse `[:&]` for returning multiple - tokens/maps/styles. + multiple tokens/maps/styles. By default these are added to the Girouette defaults, which are in terms - based on the Tailwind defaults. We still default to v2 (to avoid breaking - changes), but you can opt-in to Tailwind v3 by adding `:tw-version 3`. Use - meta-merge annotations (e.g. `{:colors ^:replace {...}}`) to change that - behaviour." + based on the Tailwind defaults. Use meta-merge annotations (e.g. `{:colors + ^:replace {...}}`) to change that behaviour. We still default to v2 (to + avoid breaking changes), but you can opt-in to Tailwind v3 by adding + `:tw-version 3`." [{:keys [components colors fonts tw-version] - :or {tw-version 2}}] + :or {tw-version 2} + :as configuration}] (let [{:keys [components colors fonts]} (meta-merge/meta-merge (case tw-version From 8b061e15a4bde2fa6bfe02552dd34c9d61cdd0c7 Mon Sep 17 00:00:00 2001 From: Donavan-Ross Costaras Date: Tue, 12 Sep 2023 13:15:08 +0100 Subject: [PATCH 2/3] . --- src/lambdaisland/ornament.cljc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/lambdaisland/ornament.cljc b/src/lambdaisland/ornament.cljc index d920867..43c560c 100644 --- a/src/lambdaisland/ornament.cljc +++ b/src/lambdaisland/ornament.cljc @@ -659,9 +659,11 @@ css-class (classname-for varsym) [docstring & styles] (if (string? (first styles)) styles (cons nil styles)) [styles fn-tails] (split-with (complement fn-tail?) styles) + qualified-symbol (qualify-sym &env tagname) tag (if (keyword? tagname) tagname - (get-in @registry [(qualify-sym &env tagname) :tag])) + (or (get-in @registry [qualified-symbol :tag]) + qualified-symbol)) rules (cond (keyword? tagname) (vec styles) From 320999cfaf35faab6734997a3bc165bbd6b4f03e Mon Sep 17 00:00:00 2001 From: Donavan-Ross Costaras Date: Tue, 12 Sep 2023 13:16:31 +0100 Subject: [PATCH 3/3] Add options store to capture all user tokens/config --- src/lambdaisland/ornament.cljc | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/lambdaisland/ornament.cljc b/src/lambdaisland/ornament.cljc index 43c560c..ce54f6e 100644 --- a/src/lambdaisland/ornament.cljc +++ b/src/lambdaisland/ornament.cljc @@ -46,6 +46,11 @@ props-registry (atom {}))) +#?(:clj + (defonce ^{:doc "Store of passed in custom options/tokens"} + options + (atom {:pretty-print? false}))) + (def ^:dynamic *strip-prefixes* "Prefixes to be stripped from class names in generated CSS" nil) @@ -148,6 +153,7 @@ :fonts (into (empty fonts) (map (juxt (comp name key) val)) fonts)})] + (swap! options merge configuration) (reset! girouette-api (girouette/make-api components @@ -479,7 +485,7 @@ (into [(str "." (classname this))] (process-rules rules))) (css [this] (gc/compile-css - {:pretty-print? false} + {:pretty-print? (:pretty-print? @options)} (as-garden this))) (rules [_] rules) (tag [_] tag)