aboutsummaryrefslogtreecommitdiff
path: root/src/server/Design/Helper.hs
blob: bd11766ff33827f6a47edb47e09304bca1e08ab2 (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
{-# LANGUAGE OverloadedStrings #-}

module Design.Helper
  ( clearFix
  , defaultButton
  , iconButton
  , defaultInput
  , centeredWithMargin
  , expandBlock
  , verticalCentering
  ) where

import Prelude hiding (span)

import Clay

import Data.Monoid ((<>))

import Design.Constants
import Design.Color as C
import qualified Clay.Display as D

clearFix :: Css
clearFix =
  after & do
    content (stringContent "")
    display D.table
    clear both

defaultButton :: Color -> Color -> Size Abs -> Css
defaultButton backgroundCol textCol h = do
  backgroundColor backgroundCol
  color textCol
  borderRadius radius radius radius radius
  verticalAlign middle
  cursor pointer
  lineHeight h
  textAlign (alignSide sideCenter)

iconButton :: Color -> Color -> Size Abs -> Css
iconButton backgroundCol textCol h = do
  defaultButton backgroundCol textCol h
  i <> span ? do
    height h
    lineHeight h
  span ? do
    display inlineBlock
    marginLeft (px 20)
  i ? do
    marginLeft (px 20)
    marginRight (px 20)
  hover & i ? transform (scale 1.2 1.2)

defaultInput :: Integer -> Css
defaultInput inputHeight = do
  height (px inputHeight)
  padding (px 10) (px 10) (px 10) (px 10)
  borderRadius radius radius radius radius
  border solid (px 1) C.darkGrey
  focus & borderColor C.grey
  verticalAlign middle

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

expandBlock :: Color -> Color -> Size Abs -> Css
expandBlock headerBackground headerColor headerHeight = do
  marginBottom blockMarginBottom
  marginLeft (pct blockPercentMargin)
  marginRight (pct blockPercentMargin)
  ".header" ? do
    defaultButton headerBackground headerColor headerHeight
    width (pct 100)
    fontSize (px 18)
    borderRadius radius radius radius radius
    textAlign (alignSide sideLeft)
    position relative
    paddingLeft blockPadding
    paddingRight (px 55)

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