mirror of
https://github.com/penpot/penpot.git
synced 2025-02-15 03:28:25 -05:00
Merge pull request #3760 from penpot/niwinz-develop-styles-macro-fix
🐛 Fix unexpected exception on style related macros
This commit is contained in:
commit
967c89a2d3
1 changed files with 10 additions and 10 deletions
|
@ -7,6 +7,7 @@
|
||||||
(ns app.main.style
|
(ns app.main.style
|
||||||
"A fonts loading macros."
|
"A fonts loading macros."
|
||||||
(:require
|
(:require
|
||||||
|
[app.common.exceptions :as ex]
|
||||||
[clojure.core :as c]
|
[clojure.core :as c]
|
||||||
[clojure.data.json :as json]
|
[clojure.data.json :as json]
|
||||||
[clojure.java.io :as io]
|
[clojure.java.io :as io]
|
||||||
|
@ -37,16 +38,19 @@
|
||||||
(interpose " ")
|
(interpose " ")
|
||||||
(apply str)))
|
(apply str)))
|
||||||
|
|
||||||
|
(defn- read-json-file
|
||||||
|
[path]
|
||||||
|
(or (ex/ignoring (-> (slurp (io/resource path))
|
||||||
|
(json/read-str :key-fn keyword)))
|
||||||
|
{}))
|
||||||
|
|
||||||
(defmacro css
|
(defmacro css
|
||||||
"Uses a css-modules defined data for real class lookup, then concat
|
"Uses a css-modules defined data for real class lookup, then concat
|
||||||
all classes with space in the same way as `css*`."
|
all classes with space in the same way as `css*`."
|
||||||
[& selectors]
|
[& selectors]
|
||||||
(let [fname (-> *ns* meta :file)
|
(let [fname (-> *ns* meta :file)
|
||||||
path (str (subs fname 0 (- (count fname) 4)) "css.json")
|
path (str (subs fname 0 (- (count fname) 4)) "css.json")
|
||||||
data (-> (slurp (io/resource path))
|
data (read-json-file path)]
|
||||||
(json/read-str :key-fn keyword)
|
|
||||||
(or {}))]
|
|
||||||
|
|
||||||
(if (symbol? (first selectors))
|
(if (symbol? (first selectors))
|
||||||
`(if ~(with-meta (first selectors) {:tag 'boolean})
|
`(if ~(with-meta (first selectors) {:tag 'boolean})
|
||||||
(css* ~@(binding [*css-data* data]
|
(css* ~@(binding [*css-data* data]
|
||||||
|
@ -60,9 +64,7 @@
|
||||||
;; Get the associated styles will be module.cljs => module.css.json
|
;; Get the associated styles will be module.cljs => module.css.json
|
||||||
(let [fname (-> *ns* meta :file)
|
(let [fname (-> *ns* meta :file)
|
||||||
path (str (subs fname 0 (- (count fname) 4)) "css.json")]
|
path (str (subs fname 0 (- (count fname) 4)) "css.json")]
|
||||||
(-> (slurp (io/resource path))
|
(read-json-file path)))
|
||||||
(json/read-str :key-fn keyword)
|
|
||||||
(or {}))))
|
|
||||||
|
|
||||||
(def ^:private xform-css-case
|
(def ^:private xform-css-case
|
||||||
(comp
|
(comp
|
||||||
|
@ -117,9 +119,7 @@
|
||||||
[& params]
|
[& params]
|
||||||
(let [fname (-> *ns* meta :file)
|
(let [fname (-> *ns* meta :file)
|
||||||
path (str (subs fname 0 (- (count fname) 4)) "css.json")
|
path (str (subs fname 0 (- (count fname) 4)) "css.json")
|
||||||
data (-> (slurp (io/resource path))
|
data (read-json-file path)]
|
||||||
(json/read-str :key-fn keyword)
|
|
||||||
(or {}))]
|
|
||||||
|
|
||||||
(if (symbol? (first params))
|
(if (symbol? (first params))
|
||||||
`(if ~(with-meta (first params) {:tag 'boolean})
|
`(if ~(with-meta (first params) {:tag 'boolean})
|
||||||
|
|
Loading…
Add table
Reference in a new issue