forked from originrose/greenhouse
-
Notifications
You must be signed in to change notification settings - Fork 0
/
fx.clj
64 lines (56 loc) · 2.05 KB
/
fx.clj
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
(ns greenhouse.fx
(:require
[garden.core :refer [css]]
[garden.stylesheet :refer [at-media]]
[garden.units :as u :refer [px pt em percent]]
[garden.color :as color :refer [hsl rgb]]
[greenhouse.grid :refer [direction->side opposite-side]]))
(defn rounded
[& {:keys [radius top-left top-right bottom-right bottom-left]}]
(list
(if (and radius (pos? radius))
{:-webkit-border-radius (px radius)
:-moz-border-radius (px radius)
:border-radius (px radius)}
(merge {}
(if top-right
{:-webkit-border-top-right-radius (px top-right)
:border-top-right-radius (px top-right)
:-moz-border-radius-topright (px top-right)}
{})
(if bottom-right
{:-webkit-border-bottom-right-radius (px bottom-right)
:-moz-border-radius-bottomright (px bottom-right)
:border-bottom-right-radius (px bottom-right)}
{})
(if bottom-left
{:-webkit-border-bottom-left-radius (px bottom-left)
:-moz-border-radius-bottomleft (px bottom-left)
:border-bottom-left-radius (px bottom-left)}
{})
(if top-left
{:-webkit-border-top-left-radius (px top-left)
:-moz-border-radius-topleft (px top-left)
:border-top-left-radius (px top-left)}
{}))
;:.background-clip(padding-box)
)))
(defn border-side
[side]
(keyword (str "border-" (name side))))
(def orthogonal
{:right [:top :bottom]
:left [:top :bottom]
:bottom [:left :right]
:top [:left :right]})
(defn arrow
[& {:keys [direction size color]
:or {direction :right size 10 color :black}}]
(let [opposite (opposite-side direction)
[a b] (orthogonal direction)]
(list
{:width 0
:height 0
(border-side opposite) [[(px size) :solid color]]
(border-side a) [[(px size) :solid :transparent]]
(border-side b) [[(px size) :solid :transparent]]})))