aboutsummaryrefslogtreecommitdiff
path: root/src/server/Design/Global.hs
blob: 7d2b7b64ccb5be7d9ef7f51a720f648c7b28d763 (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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
{-# LANGUAGE OverloadedStrings #-}

module Design.Global
  ( globalDesign
  ) where

import Data.Monoid ((<>))

import Clay
import qualified Clay.Display as D

import Data.Text.Lazy (Text)

import Design.Color as C
import Design.Media

globalDesign :: Text
globalDesign = renderWith compact [] global

iconFontSize :: Size Abs
iconFontSize = px 32

radius :: Size Abs
radius = px 3

blockPadding :: Size Abs
blockPadding = px 15

blockMarginBottom :: Size Abs
blockMarginBottom = px 50

global :: Css
global = do

  body ? do
    position relative
    minWidth (px 550)
    fontFamily ["Cantarell"] [sansSerif]

  header ? do
    let headerHeight = 150

    h1 ? do
      fontSize (px 45)
      textAlign (alignSide sideCenter)
      color C.red
      lineHeight (px headerHeight)

    button # ".signOut" ? do
      let iconHeight = 50
      let sideMargin = ((headerHeight - iconHeight) `Prelude.div` 2) + 5
      position absolute
      top (px sideMargin)
      right (pct 2)
      height (px iconHeight)
      lineHeight (px iconHeight)
      backgroundColor C.white
      color C.red
      fontSize iconFontSize
      hover & transform (scale 1.2 1.2)

  ".loggedIn" ? do
    let inputHeight = 40

    form ? do
      centeredWithMargin
      marginBottom blockMarginBottom
      clearFix

      ".name" <> ".cost" ? do
        position relative
        width (pct 49)
        label ? do
          fontWeight bold
          display inlineBlock
          width (px 60)
          textAlign (alignSide sideCenter)
          backgroundColor C.darkGrey
          color C.white
          height (px inputHeight)
          lineHeight (px inputHeight)
          fontSize (px 22)
          verticalAlign middle
          cursor cursorText
          borderRadius (px 0) radius radius (px 0)
        input ? do
          defaultInput inputHeight
          borderRadius radius (px 0) (px 0) radius
        "input:focus + label" ? backgroundColor C.grey

      ".name" ? do
        float floatLeft
        width (pct 40)
        input ? width (pct 75)
        label ? width (pct 20)
        paddingRight (pct 5)

      ".cost" ? do
        float floatLeft
        width (pct 25)
        input ? width (pct 65)
        label ? width (pct 30)
        paddingRight (pct 5)

      button # ".frequency" ? do
        fontSize (pct 90)
        float floatLeft
        width (pct 15)
        marginRight (pct 5)

        (".punctual" <> ".monthly") ? do
          defaultButton C.lightGrey C.darkGrey (inputHeight `Prelude.div` 2)
          ".selected" & do
            backgroundColor C.blue
            color C.white

        ".punctual" ? borderRadius radius radius 0 0
        ".monthly" ? borderRadius 0 0 radius radius

      button # ".add" ? do
        defaultButton C.red C.white inputHeight
        float floatLeft
        width (pct 15)

      ".name.error" <> ".cost.error" ? do
        input ? borderColor C.redError
        label ? backgroundColor C.redError
        "input:focus + label" ? backgroundColor C.redError

      ".errorMessage" ? do
        position absolute
        color C.redError
        top (px (inputHeight + 10))
        left (px 0)

    ".expandables" ? do
      centeredWithMargin
      clearFix

      ".monthlyPayments" ? do
        marginBottom blockMarginBottom

        largeScreen $ do
          float floatLeft
          width (pct 55)

        button # ".count" ? do
          width (pct 100)
          fontSize (px 18)
          defaultButton C.blue C.white inputHeight
          borderRadius radius radius radius radius
          textAlign (alignSide sideLeft)
          position relative
          paddingLeft blockPadding
          paddingRight blockPadding

          ".expand" ? do
            float floatRight
            marginTop (px (-2))

        ".detail" &
          button # ".count" ?
            borderRadius radius radius 0 0

      ".exceedingPayers" ? do
        backgroundColor C.green
        color C.white
        fontSize (px 18)
        borderRadius radius radius radius radius
        marginBottom blockMarginBottom
        paddingLeft blockPadding
        paddingRight blockPadding

        largeScreen $ do
          float floatRight
          width (pct 40)

        ".exceedingPayer" ? do
          lineHeight (px inputHeight)
          ".userName" ? marginRight (px 10)

    ".table" ? do
      display D.table
      width (pct 100)
      textAlign (alignSide (sideCenter))
      "border-spacing" -: "10 px"

      ".header" <> ".row" ? display tableRow
      let headerHeight = (px 70)
      let rowHeight = (px 60)

      ".header" ? do
        fontWeight bold
        backgroundColor C.red
        color C.white
        fontSize iconFontSize
        lineHeight headerHeight

      ".row" ? do
        fontSize (px 20)
        cursor pointer
        lineHeight rowHeight
        nthChild "odd" & backgroundColor C.lightGrey
        ".edition" & do
          backgroundColor C.paymentFocus
          ".delete" ? visibility visible

      ".cell" ? do
        display tableCell
        ".category" & width (pct 40)
        ".cost" & do
          width (pct 17)
          ".refund" & color C.greenSuccess
        ".user" & width (pct 20)
        ".date" & do
          width (pct 20)
          smallScreen $ do
            ".shortDate" ? display inline
            ".longDate" ? display none
          largeScreen $ do
            ".shortDate" ? display none
            ".longDate" ? display inline
        ".delete" & do
          width (pct 3)
          height rowHeight
          textAlign (alignSide sideCenter)
          backgroundColor C.red
          visibility hidden
          button ? do
            width (pct 100)
            height (pct 100)
            color C.white

    ".pages" ? do
      padding (px 30) (px 30) (px 30) (px 30)
      textAlign (alignSide (sideCenter))
      clearFix

      ".page" ? do
        display inlineBlock
        border solid (px 2) C.darkGrey
        color C.darkGrey
        borderRadius radius radius radius radius
        marginRight (px 10)
        let h = 50
        paddingLeft (px 10)
        paddingRight (px 10)
        height (px h)
        lineHeight (px h)
        textAlign (alignSide (sideCenter))
        fontWeight bold

        ":not(.current)" & cursor pointer

        ".current" & do
          borderColor C.red
          color C.red

  ".signIn" ? do

    form ? do
      let inputHeight = 50
      width (px 500)
      marginTop (px 50)
      marginLeft auto
      marginRight auto

      input ? do
        defaultInput inputHeight
        display block
        width (pct 100)
        marginBottom (px 10)

      button ? do
        defaultButton C.red C.white inputHeight
        display block
        width (pct 100)

    ".result" ? do
      marginTop (px 40)
      textAlign (alignSide sideCenter)
      ".success" ? color C.greenSuccess
      ".error" ? color C.redError

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

defaultButton :: Color -> Color -> Integer -> Css
defaultButton backgroundCol textCol pxHeight = do
  backgroundColor backgroundCol
  color textCol
  borderRadius radius radius radius radius
  verticalAlign middle
  cursor pointer
  height (px pxHeight)
  lineHeight (px pxHeight)
  textAlign (alignSide sideCenter)

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 90)
  marginLeft auto
  marginRight auto