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
|
module HTML.Styles.Bootstrap3
( bootstrapForm, bootstrapPage, titledSideMenu
, defaultButton, smallButton, primButton
, hrefButton, hrefBlock, hrefInfoBlock
, glyphicon, homeIcon, userIcon, loginIcon, logoutIcon
) where
import HTML.Base
bootstrapForm :: String -> [String] -> String -> (String,[HtmlExp])
-> [[HtmlExp]] -> [[HtmlExp]] -> Int -> [HtmlExp] -> [HtmlExp]
-> [HtmlExp] -> [HtmlExp] -> HtmlForm
bootstrapForm rootdir styles title brandurltitle lefttopmenu righttopmenu
leftcols sidemenu header contents footer =
HtmlForm title
([formEnc "utf-8", responsiveView, icon] ++
map (\n -> formCSS (rootdir++"/css/"++n++".css")) styles)
(bootstrapBody rootdir brandurltitle lefttopmenu righttopmenu
leftcols sidemenu header contents footer)
where
responsiveView =
HeadInclude (HtmlStruct "meta"
[("name","viewport"),
("content","width=device-width, initial-scale=1.0")] [])
icon = HeadInclude (HtmlStruct "link"
[("rel","shortcut icon"),
("href",rootdir++"/img/favicon.ico")] [])
bootstrapPage :: String -> [String] -> String -> (String,[HtmlExp])
-> [[HtmlExp]] -> [[HtmlExp]] -> Int -> [HtmlExp] -> [HtmlExp]
-> [HtmlExp] -> [HtmlExp] -> HtmlPage
bootstrapPage rootdir styles title brandurltitle lefttopmenu righttopmenu
leftcols sidemenu header contents footer =
HtmlPage title
([pageEnc "utf-8",responsiveView,icon] ++
map (\n -> pageCSS (rootdir++"/css/"++n++".css")) styles)
(bootstrapBody rootdir brandurltitle lefttopmenu righttopmenu
leftcols sidemenu header contents footer)
where
responsiveView =
pageMetaInfo [("name","viewport"),
("content","width=device-width, initial-scale=1.0")]
icon = pageLinkInfo [("rel","shortcut icon"),
("href",rootdir++"/favicon.ico")]
bootstrapBody :: String -> (String,[HtmlExp]) -> [[HtmlExp]]
-> [[HtmlExp]] -> Int -> [HtmlExp] -> [HtmlExp]
-> [HtmlExp] -> [HtmlExp] -> [HtmlExp]
bootstrapBody rootdir brandurltitle lefttopmenu righttopmenu
leftcols sidemenu header contents footer =
topNavigationBar brandurltitle lefttopmenu righttopmenu ++
[blockstyle "container-fluid"
([blockstyle "row"
(if leftcols==0
then [blockstyle (bsCols 12)
(headerRow ++ contents)]
else [blockstyle (bsCols leftcols)
[blockstyle "well nav-sidebar" sidemenu],
blockstyle (bsCols (12-leftcols))
(headerRow ++ contents)])] ++
if null footer
then []
else [hrule, HtmlStruct "footer" [] footer]),
HtmlStruct "script" [("src",rootdir++"/js/jquery.min.js")] [],
HtmlStruct "script" [("src",rootdir++"/js/bootstrap.min.js")] []]
where
bsCols n = "col-sm-" ++ show n ++ " " ++ "col-md-" ++ show n
headerRow = if null header
then []
else [HtmlStruct "header" [("class","jumbotron")] header]
topNavigationBar :: (String,[HtmlExp]) -> [[HtmlExp]] -> [[HtmlExp]]
-> [HtmlExp]
topNavigationBar (brandurl,brandtitle) leftmenu rightmenu =
[blockstyle "navbar navbar-inverse navbar-fixed-top"
[blockstyle "container-fluid"
[blockstyle "navbar-header"
[HtmlStruct "button"
[("type","button"),("class","navbar-toggle collapsed"),
("data-toggle","collapse"),("data-target","#topnavbar"),
("aria-expanded","false"),("aria-controls","topnavbar")]
[textstyle "sr-only" "Toggle navigation",
textstyle "icon-bar" "",
textstyle "icon-bar" "",
textstyle "icon-bar" ""],
href brandurl brandtitle `addClass` "navbar-brand"],
HtmlStruct "div" [("id","topnavbar"),
("class","collapse navbar-collapse")]
([ulist leftmenu `addClass` "nav navbar-nav"] ++
if null rightmenu then []
else [ulist rightmenu `addClass` "nav navbar-nav navbar-right"])]]]
titledSideMenu :: String -> [[HtmlExp]] -> [HtmlExp]
title items =
(if null title
then []
else [HtmlStruct "small" [] [htxt title]]) ++
[ulist items `addClass` "nav nav-sidebar"]
defaultButton :: String -> HtmlHandler -> HtmlExp
defaultButton label handler =
button label handler `addClass` "btn btn-default"
smallButton :: String -> HtmlHandler -> HtmlExp
smallButton label handler =
button label handler `addClass` "btn btn-sm btn-default"
primButton :: String -> HtmlHandler -> HtmlExp
primButton label handler =
button label handler `addClass` "btn btn-primary"
hrefButton :: String -> [HtmlExp] -> HtmlExp
hrefButton ref hexps =
href ref hexps `addClass` "btn btn-sm btn-default"
hrefBlock :: String -> [HtmlExp] -> HtmlExp
hrefBlock ref hexps =
href ref hexps `addClass` "btn btn-sm btn-block"
hrefInfoBlock :: String -> [HtmlExp] -> HtmlExp
hrefInfoBlock ref hexps =
href ref hexps `addClass` "btn btn-info btn-block"
glyphicon :: String -> HtmlExp
glyphicon n = textstyle ("glyphicon glyphicon-"++n) ""
homeIcon :: HtmlExp
homeIcon = glyphicon "home"
userIcon :: HtmlExp
userIcon = glyphicon "user"
loginIcon :: HtmlExp
loginIcon = glyphicon "log-in"
logoutIcon :: HtmlExp
logoutIcon = glyphicon "log-out"
|