aboutsummaryrefslogtreecommitdiff
path: root/server/src/Design/Helper.hs
blob: 9bf7878541d537ee49c017242dd04d5dd74366ca (plain)
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
module Design.Helper
  ( clearFix
  , button
  , waitable
  , input
  , centeredWithMargin
  , verticalCentering
  ) where

import           Prelude          hiding (span)

import           Clay             hiding (button, input)

import           Design.Color     as Color
import           Design.Constants

clearFix :: Css
clearFix =
  after & do
    content (stringContent "")
    display displayTable
    clear both

button :: Color -> Color -> Size a -> (Color -> Color) -> Css
button backgroundCol textCol h focusOp = do
  display flex
  alignItems center
  justifyContent center
  backgroundColor backgroundCol
  padding (px 0) (px 10) (px 0) (px 10)
  color textCol
  borderRadius radius radius radius radius
  verticalAlign middle
  cursor pointer
  lineHeight h
  height h
  textAlign (alignSide sideCenter)
  hover & backgroundColor (focusOp backgroundCol)
  focus & backgroundColor (focusOp backgroundCol)
  waitable

waitable :: Css
waitable = do
  svg # ".loader" ? display none
  ".waiting" & do
    ".content" ? do
      display flex
      fontSize (px 0)
      opacity 0
    svg # ".loader" ? do
      display block
      rotateKeyframes
      rotateAnimation

input :: Double -> Css
input h = do
  height (px h)
  padding (px 10) (px 10) (px 10) (px 10)
  borderRadius radius radius radius radius
  border solid (px 1) Color.dustyGray
  focus & borderColor Color.silver
  verticalAlign middle

centeredWithMargin :: Css
centeredWithMargin = do
  width (pct blockPercentWidth)
  marginLeft auto
  marginRight auto

verticalCentering :: Css
verticalCentering = do
  position absolute
  top (pct 50)
  "transform" -: "translateY(-50%)"

rotateAnimation :: Css
rotateAnimation = do
  animationName "rotate"
  animationDuration (sec 1)
  animationTimingFunction easeOut
  animationIterationCount infinite

rotateKeyframes :: Css
rotateKeyframes = keyframes
  "rotate"
  [ (0, "transform" -: "rotate(0deg)")
  , (100, "transform" -: "rotate(360deg)")
  ]