-
Notifications
You must be signed in to change notification settings - Fork 0
/
functions.cljc
103 lines (92 loc) · 3.46 KB
/
functions.cljc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
(ns tornado.functions
"Everything related to CSS functions."
(:require [tornado.types]
[tornado.util :as util]
[tornado.compiler :refer [compile-expression]]
#?(:clj [tornado.macros :refer [defcssfn]]))
#?(:cljs (:require-macros [tornado.macros :refer [defcssfn]])))
(defn comma-join
"A CSSFunction util/str-comma-join compile function. Compiles the
function to a form <fn-name>(arg1, arg2, arg3, ...),"
[{:keys [compiles-to args]}]
(str compiles-to "(" (->> args (map compile-expression)
util/str-comma-join) ")"))
(defn space-join
"A CSSFunction util/str-space-join compile function. Compiles the
function to a form <fn-name>(arg1 arg2 arg3 ...),"
[{:keys [compiles-to args]}]
(str compiles-to "(" (->> args (map compile-expression)
util/str-space-join) ")"))
(defn single-arg
"A CSSFunction compile function. Presumes that only one arg is given.
If not, calls comma-join function above and gives us a warning instead."
[{:keys [compiles-to args] :as cssfn}]
(if (= (count args) 1)
(str compiles-to "(" (-> args first compile-expression) ")")
(do (println (str "Warning: A CSSFunction \"" compiles-to "\" expects to have"
" 1 argument, instead got arguments: " args))
(comma-join cssfn))))
(defn css-format-fn
"A special function for css-format which also puts additional quotes around
the parameter to enable usage of keywords."
[{:keys [args] :as cssfn}]
(if (= (count args) 1)
(str "format(\"" (-> args first compile-expression) "\")")
(do (println (str "Warning: A CSSFunction \"css-format\" expects to have"
" 1 argument, instead got arguments: " args))
(comma-join cssfn))))
; https://www.quackit.com/css/functions/
;; single arg functions
(defcssfn blur single-arg)
(defcssfn brightness single-arg)
(defcssfn contrast single-arg)
(defcssfn css-format "format" css-format-fn)
(defcssfn grayscale single-arg)
(defcssfn hue-rotate single-arg)
(defcssfn invert single-arg)
(defcssfn perspective single-arg)
(defcssfn rotate single-arg)
(defcssfn rotateX single-arg)
(defcssfn rotateY single-arg)
(defcssfn rotateZ single-arg)
(defcssfn sepia single-arg)
(defcssfn skewX single-arg)
(defcssfn skewY single-arg)
(defcssfn scaleX single-arg)
(defcssfn scaleY single-arg)
(defcssfn scaleZ single-arg)
(defcssfn translateX single-arg)
(defcssfn translateY single-arg)
(defcssfn translateZ single-arg)
;; comma-join functions
(defcssfn attr comma-join)
(defcssfn counter comma-join)
(defcssfn counters comma-join)
(defcssfn cubic-bezier comma-join)
(defcssfn css-filter "filter" comma-join)
(defcssfn hwb comma-join)
(defcssfn linear-gradient comma-join)
(defcssfn matrix comma-join)
(defcssfn matrix3d comma-join)
(defcssfn css-max "max" comma-join)
(defcssfn css-min "min" comma-join)
(defcssfn polygon comma-join)
(defcssfn radial-gradient comma-join)
(defcssfn repeating-linear-gradient comma-join)
(defcssfn repeating-radial-gradient comma-join)
(defcssfn rotate3d comma-join)
(defcssfn scale comma-join)
(defcssfn scale3d comma-join)
(defcssfn skew comma-join)
(defcssfn translate comma-join)
(defcssfn translate3d comma-join)
(defcssfn url comma-join)
(defcssfn css-var "var" comma-join)
;; space-join functions
(defcssfn calc space-join)
(defcssfn circle space-join)
(defcssfn drop-shadow space-join)
(defcssfn ellipse space-join)
(defcssfn image space-join)
(defcssfn inset space-join)
(defcssfn symbols space-join)