summaryrefslogtreecommitdiff
path: root/src/WWW/Css.hs
blob: 05aec62e4630cc510b52e9ba0eb74c5a60ceb853 (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
module WWW.Css where

import Control.Monad
import Clay
import Clay.Flexbox qualified as F
import Clay.Stylesheet
import Data.Foldable (fold)
import Data.Text (Text)
import Diagrams.Attributes (SomeColor)

import WWW.Colors qualified as G



colorVariables :: G.Gruvbox SomeColor -> Css
colorVariables gb = do
    fold $ key <$> (("--" <>) <$> G.gruvboxVar) <*> gb
    key "--html-bg" $ G._bg1 gb
    key "--href" $ G._orange gb
    key "--href-hover" $ G._orange' gb
    key "--hr" $ G._gray gb
    key "--code-bg" $ G._bg gb


rootColors :: Css
rootColors = do
    ":root[color-mode=light]" ? do
        colorVariables G.gruvboxLightH
    ":root[color-mode=dark]" ? do
        colorVariables G.gruvboxDarkH

general :: Css
general = do
    html ? do
        fontFamily [ "Fira Sans" ] [ sansSerif ]
        backgroundColor $ cvar "html-bg"
        color $ cvar "fg"
        margin (em 1) auto auto auto
    body ? do
        backgroundColor $ cvar "bg"
        join4 margin auto
        maxWidth (cm 30)
        border (px 1) solid $ cvar "fg"
        join4 padding $ em 1
    a ? do
        color $ cvar "href"
        textDecoration underline
        hover & do
            color $ cvar "href-hover"
    header ? do
        padding nil nil nil nil
        margin nil nil nil nil
        fontSize $ em 1
        fontWeight bold
        textDecoration none
    footer ? do
        clear both
        paddingTop $ px 10
        paddingBottom $ px 15
        fontWeight bold
        hr ? do
            borderTop (px 3) double $ cvar "hr"
            borderBottomWidth 0
        a ? do
            textDecoration none
            color $ cvar "footer-href"
        a # hover ? do
            textDecoration underline
            color $ cvar "footer-href-hover"
    code ? do
        fontFamily [ "Fira Code" ] [ monospace ]
        backgroundColor $ cvar "code-bg"
        join4 padding $ px 2


someClasses :: Css
someClasses = do
    ".pull-left" ? do
        float floatLeft
    ".pull-right" ? do
        float floatRight

menu :: Css
menu = do
    clear both
    display block
    "width" -: "100%"
    margin 0 0 (em 1) 0
    color $ cvar "bg"
    backgroundColor $ cvar "fg"
    "overflow" -: "hidden"
    a ? do
        display block
        float floatLeft
        padding (px 5) (px 10) (px 5) (px 10)
        color $ cvar "bg"
    a # hover ? do
        color $ cvar "href-hover"




-- helpers

join3 :: Monad m => m (m (m a)) -> m a
join3 = join . join

join4 :: Monad m => m (m (m (m a))) -> m a
join4 = join . join3

cvar :: Text -> Color
cvar n = Other $ value $ "var(--" <> n <> ")"
-- root :: Css
-- root = do
--     ":root" ? do
--         "--