0 | module Text.CSS.Declaration
4 | import Text.CSS.Color
5 | import Text.CSS.Cursor
7 | import Text.CSS.Flexbox
8 | import Text.CSS.Gradient
10 | import Text.CSS.Length
11 | import Text.CSS.ListStyleType
12 | import Text.CSS.Percentage
13 | import Text.CSS.Property
18 | data Declaration : Type where
19 | Decl : (property, value : String) -> Declaration
20 | Display : Display -> Declaration
23 | 0 Declarations : Type
24 | Declarations = List Declaration
27 | Interpolation Declaration where
28 | interpolate (Decl p v) = "\{p}: \{v};"
29 | interpolate (Display None) = "display: none;"
30 | interpolate (Display InlineBlock) = "display: inline-block;"
31 | interpolate (Display Flex) = "display: flex;"
32 | interpolate (Display Grid) = "display: grid;"
33 | interpolate (Display $
Area rs cs a) = "\{renderArea rs cs a};"
36 | decl : Interpolation a => String -> a -> Declaration
37 | decl s = Decl s . interpolate
40 | prfx : Dir a -> String
41 | prfx (Left _) = "-left"
42 | prfx (Right _) = "-right"
43 | prfx (Top _) = "-top"
44 | prfx (Bottom _) = "-bottom"
48 | dirDecl : (prop : String) -> (a -> String) -> Dir a -> Declaration
50 | let vs := concat . intersperse " " . map f $
vals d
51 | in Decl "\{prop}\{prfx d}" vs
54 | dirDecl2 : (prop,suffix : String) -> (a -> String) -> Dir a -> Declaration
55 | dirDecl2 prop suffix f d =
56 | let vs := concat . intersperse " " . map f $
vals d
57 | in Decl "\{prop}\{prfx d}-\{suffix}" vs
64 | alignItems : FlexAlign -> Declaration
65 | alignItems = decl "align-items"
68 | alignSelf : FlexAlign -> Declaration
69 | alignSelf = decl "align-self"
72 | aspectRatio : Ratio -> Declaration
73 | aspectRatio = decl "aspect-ratio"
76 | backgroundColor : Color -> Declaration
77 | backgroundColor = decl "background-color"
80 | backgroundImage : (url : String) -> Declaration
81 | backgroundImage = Decl "background-image"
84 | backgroundImageGradient : Gradient -> Declaration
85 | backgroundImageGradient = decl "background-image"
88 | backgroundSize : Width -> Declaration
89 | backgroundSize = decl "background-size"
92 | border : String -> Declaration
93 | border = Decl "border"
96 | borderColor : Dir Color -> Declaration
97 | borderColor = dirDecl2 "border" "color" interpolate
100 | borderRadius : BorderRadius -> Declaration
101 | borderRadius = decl "border-radius"
104 | borderTopLeftRadius : BorderRadius -> Declaration
105 | borderTopLeftRadius = decl "border-top-left-radius"
108 | borderTopRightRadius : BorderRadius -> Declaration
109 | borderTopRightRadius = decl "border-top-right-radius"
112 | borderBottomLeftRadius : BorderRadius -> Declaration
113 | borderBottomLeftRadius = decl "border-bottom-left-radius"
116 | borderBottomRightRadius : BorderRadius -> Declaration
117 | borderBottomRightRadius = decl "border-bottom-right-radius"
120 | borderStyle : Dir BorderStyle -> Declaration
121 | borderStyle = dirDecl2 "border" "style" interpolate
124 | borderWidth : Dir BorderWidth -> Declaration
125 | borderWidth = dirDecl2 "border" "width" interpolate
128 | boxSizing : BoxSizing -> Declaration
129 | boxSizing = decl "box-sizing"
132 | color : Color -> Declaration
133 | color = decl "color"
136 | columnGap : Length -> Declaration
137 | columnGap = decl "column-gap"
140 | containerType : ContainerType -> Declaration
141 | containerType = decl "container-type"
144 | cursor : List Cursor -> Declaration
145 | cursor = decl "cursor" . fastConcat . intersperse "," . map interpolate
148 | direction : Direction -> Declaration
149 | direction = decl "direction"
152 | display : Display -> Declaration
159 | -> {auto as : Show a}
160 | -> (rows : Vect (S m) GridValue)
161 | -> (columns : Vect (S n) GridValue)
162 | -> (area : Vect (S m) (Vect (S n) a))
164 | area rs cs a = display (Area rs cs a)
167 | fill : Maybe Color -> Declaration
168 | fill Nothing = decl "fill" "none"
169 | fill (Just c) = decl "fill" c
172 | flex : String -> Declaration
176 | flexBasis : FlexBasis -> Declaration
177 | flexBasis = decl "flex-basis"
180 | flexDirection : FlexDirection -> Declaration
181 | flexDirection = decl "flex-direction"
184 | flexWrap : String -> Declaration
185 | flexWrap = Decl "flex-wrap"
188 | flexGrow : Nat -> Declaration
189 | flexGrow = Decl "flex-grow" . show
192 | flexFlow : List FlexFlow -> Declaration
193 | flexFlow = decl "flex-flow"
196 | fontFamily : String -> Declaration
197 | fontFamily = Decl "font-family"
200 | fontSize : FontSize -> Declaration
201 | fontSize = decl "font-size"
204 | fontStyle : FontStyle -> Declaration
205 | fontStyle = decl "font-style"
208 | fontWeight : FontWeight -> Declaration
209 | fontWeight = decl "font-weight"
212 | gridArea : Show a => a -> Declaration
213 | gridArea = Decl "grid-area" . showTag
216 | gridColumn : GridPosition -> Declaration
217 | gridColumn = decl "grid-column"
220 | gridRow : GridPosition -> Declaration
221 | gridRow = decl "grid-row"
224 | gridTemplateColumns : List GridValue -> Declaration
225 | gridTemplateColumns = decl "grid-template-columns"
228 | gridTemplateRows : List GridValue -> Declaration
229 | gridTemplateRows = decl "grid-template-rows"
232 | height : Width -> Declaration
233 | height = decl "height"
236 | justifyContent : FlexJustify -> Declaration
237 | justifyContent = decl "justify-content"
240 | justifySelf : FlexJustify -> Declaration
241 | justifySelf = decl "justify-self"
244 | lineHeight : LineHeight -> Declaration
245 | lineHeight = decl "line-height"
248 | listStyleType : ListStyleType -> Declaration
249 | listStyleType = decl "list-style-type"
252 | margin : Dir Length -> Declaration
253 | margin = dirDecl "margin" interpolate
256 | maxHeight : Width -> Declaration
257 | maxHeight = decl "max-height"
260 | maxWidth : Width -> Declaration
261 | maxWidth = decl "max-width"
264 | minHeight : Width -> Declaration
265 | minHeight = decl "min-height"
268 | minWidth : Width -> Declaration
269 | minWidth = decl "min-width"
272 | opacity : Percentage -> Declaration
273 | opacity = decl "opacity"
276 | outlineOffset : Length -> Declaration
277 | outlineOffset = decl "outline-offset"
280 | outlineColor : Color -> Declaration
281 | outlineColor = decl "outline-color"
284 | outlineStyle : BorderStyle -> Declaration
285 | outlineStyle = decl "outline-style"
288 | outlineWidth : BorderWidth -> Declaration
289 | outlineWidth = decl "outline-width"
292 | overflow : Overflow -> Declaration
293 | overflow = decl "overflow"
296 | overflowX : Overflow -> Declaration
297 | overflowX = decl "overflow-x"
300 | overflowY : Overflow -> Declaration
301 | overflowY = decl "overflow-y"
304 | padding : Dir Length -> Declaration
305 | padding = dirDecl "padding" interpolate
308 | position : Position -> Declaration
309 | position = decl "position"
312 | bottom : Pos -> Declaration
313 | bottom = decl "bottom"
316 | left : Pos -> Declaration
320 | top : Pos -> Declaration
324 | right : Pos -> Declaration
325 | right = decl "right"
328 | inset : Dir Pos -> Declaration
329 | inset = dirDecl "inset" interpolate
332 | resize : Resize -> Declaration
333 | resize = decl "resize"
336 | rowGap : Length -> Declaration
337 | rowGap = decl "row-gap"
340 | stroke : Maybe Color -> Declaration
341 | stroke Nothing = decl "stroke" "none"
342 | stroke (Just c) = decl "stroke" c
345 | scrollbarGutter : ScrollbarGutter -> Declaration
346 | scrollbarGutter = decl "scrollbar-gutter"
349 | strokeWidth : Width -> Declaration
350 | strokeWidth = decl "stroke-width"
353 | strokeLinecap : Linecap -> Declaration
354 | strokeLinecap = decl "stroke-linecap"
357 | strokeLinejoin : Linejoin -> Declaration
358 | strokeLinejoin = decl "stroke-linejoin"
361 | strokeMiterlimit : Double -> Declaration
362 | strokeMiterlimit = decl "stroke-miterlimit" . show
365 | textAlign : TextAlign -> Declaration
366 | textAlign = decl "text-align"
369 | textDecoration : String -> Declaration
370 | textDecoration = Decl "text-decoration"
373 | textDecorationColor : Color -> Declaration
374 | textDecorationColor = decl "text-decoration-color"
377 | textDecorationLine : TextDecorationLine -> Declaration
378 | textDecorationLine = decl "text-decoration-line"
381 | textDecorationStyle : TextDecorationStyle -> Declaration
382 | textDecorationStyle = decl "text-decoration-style"
385 | textOverflow : TextOverflow -> Declaration
386 | textOverflow = decl "text-overflow"
389 | textOverflow2 : TextOverflow -> TextOverflow -> Declaration
390 | textOverflow2 x y = Decl "text-overflow" "\{x} \{y}"
393 | visibility : Visibility -> Declaration
394 | visibility = decl "visibility"
397 | width : Width -> Declaration
398 | width = decl "width"
401 | whitespace : WhiteSpace -> Declaration
402 | whitespace = decl "white-space"