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 | Interpolation Declaration where
24 | interpolate (Decl p v) = "\{p}: \{v};"
25 | interpolate (Display None) = "display: none;"
26 | interpolate (Display Flex) = "display: flex;"
27 | interpolate (Display Grid) = "display: grid;"
28 | interpolate (Display $
Area rs cs a) = "\{renderArea rs cs a};"
31 | decl : Interpolation a => String -> a -> Declaration
32 | decl s = Decl s . interpolate
35 | prfx : Dir a -> String
36 | prfx (Left _) = "-left"
37 | prfx (Right _) = "-right"
38 | prfx (Top _) = "-top"
39 | prfx (Bottom _) = "-bottom"
43 | dirDecl : (prop : String) -> (a -> String) -> Dir a -> Declaration
45 | let vs := concat . intersperse " " . map f $
vals d
46 | in Decl "\{prop}\{prfx d}" vs
49 | dirDecl2 : (prop,suffix : String) -> (a -> String) -> Dir a -> Declaration
50 | dirDecl2 prop suffix f d =
51 | let vs := concat . intersperse " " . map f $
vals d
52 | in Decl "\{prop}\{prfx d}-\{suffix}" vs
59 | alignItems : FlexAlign -> Declaration
60 | alignItems = decl "align-items"
63 | alignSelf : FlexAlign -> Declaration
64 | alignSelf = decl "align-self"
67 | aspectRatio : Ratio -> Declaration
68 | aspectRatio = decl "aspect-ratio"
71 | backgroundColor : Color -> Declaration
72 | backgroundColor = decl "background-color"
75 | backgroundImage : (url : String) -> Declaration
76 | backgroundImage = Decl "background-image"
79 | backgroundImageGradient : Gradient -> Declaration
80 | backgroundImageGradient = decl "background-image"
83 | backgroundSize : Width -> Declaration
84 | backgroundSize = decl "background-size"
87 | border : String -> Declaration
88 | border = Decl "border"
91 | borderColor : Dir Color -> Declaration
92 | borderColor = dirDecl2 "border" "color" interpolate
95 | borderRadius : BorderRadius -> Declaration
96 | borderRadius = decl "border-radius"
99 | borderStyle : Dir BorderStyle -> Declaration
100 | borderStyle = dirDecl2 "border" "style" interpolate
103 | borderWidth : Dir BorderWidth -> Declaration
104 | borderWidth = dirDecl2 "border" "width" interpolate
107 | boxSizing : BoxSizing -> Declaration
108 | boxSizing = decl "box-sizing"
111 | color : Color -> Declaration
112 | color = decl "color"
115 | columnGap : Length -> Declaration
116 | columnGap = decl "column-gap"
119 | containerType : ContainerType -> Declaration
120 | containerType = decl "container-type"
123 | cursor : List Cursor -> Declaration
124 | cursor = decl "cursor" . fastConcat . intersperse "," . map interpolate
127 | direction : Direction -> Declaration
128 | direction = decl "direction"
131 | display : Display -> Declaration
138 | -> {auto as : Show a}
139 | -> (rows : Vect (S m) GridValue)
140 | -> (columns : Vect (S n) GridValue)
141 | -> (area : Vect (S m) (Vect (S n) a))
143 | area rs cs a = display (Area rs cs a)
146 | fill : Maybe Color -> Declaration
147 | fill Nothing = decl "fill" "none"
148 | fill (Just c) = decl "fill" c
151 | flex : String -> Declaration
155 | flexBasis : FlexBasis -> Declaration
156 | flexBasis = decl "flex-basis"
159 | flexDirection : FlexDirection -> Declaration
160 | flexDirection = decl "flex-direction"
163 | flexWrap : String -> Declaration
164 | flexWrap = Decl "flex-wrap"
167 | flexGrow : Nat -> Declaration
168 | flexGrow = Decl "flex-grow" . show
171 | flexFlow : List FlexFlow -> Declaration
172 | flexFlow = decl "flex-flow"
175 | fontFamily : String -> Declaration
176 | fontFamily = Decl "font-family"
179 | fontSize : FontSize -> Declaration
180 | fontSize = decl "font-size"
183 | fontStyle : FontStyle -> Declaration
184 | fontStyle = decl "font-style"
187 | fontWeight : FontWeight -> Declaration
188 | fontWeight = decl "font-weight"
191 | gridArea : Show a => a -> Declaration
192 | gridArea = Decl "grid-area" . showTag
195 | gridColumn : GridPosition -> Declaration
196 | gridColumn = decl "grid-column"
199 | gridRow : GridPosition -> Declaration
200 | gridRow = decl "grid-row"
203 | gridTemplateColumns : List GridValue -> Declaration
204 | gridTemplateColumns = decl "grid-template-columns"
207 | gridTemplateRows : List GridValue -> Declaration
208 | gridTemplateRows = decl "grid-template-rows"
211 | height : Width -> Declaration
212 | height = decl "height"
215 | justifyContent : FlexJustify -> Declaration
216 | justifyContent = decl "justify-content"
219 | justifySelf : FlexJustify -> Declaration
220 | justifySelf = decl "justify-self"
223 | lineHeight : LineHeight -> Declaration
224 | lineHeight = decl "line-height"
227 | listStyleType : ListStyleType -> Declaration
228 | listStyleType = decl "list-style-type"
231 | margin : Dir Length -> Declaration
232 | margin = dirDecl "margin" interpolate
235 | maxHeight : Width -> Declaration
236 | maxHeight = decl "max-height"
239 | maxWidth : Width -> Declaration
240 | maxWidth = decl "max-width"
243 | minHeight : Width -> Declaration
244 | minHeight = decl "min-height"
247 | minWidth : Width -> Declaration
248 | minWidth = decl "min-width"
251 | outlineColor : Color -> Declaration
252 | outlineColor = decl "outline-color"
255 | outlineStyle : BorderStyle -> Declaration
256 | outlineStyle = decl "outline-style"
259 | outlineWidth : BorderWidth -> Declaration
260 | outlineWidth = decl "outline-width"
263 | overflowX : Overflow -> Declaration
264 | overflowX = decl "overflow-x"
267 | overflowY : Overflow -> Declaration
268 | overflowY = decl "overflow-y"
271 | padding : Dir Length -> Declaration
272 | padding = dirDecl "padding" interpolate
275 | rowGap : Length -> Declaration
276 | rowGap = decl "row-gap"
279 | stroke : Maybe Color -> Declaration
280 | stroke Nothing = decl "stroke" "none"
281 | stroke (Just c) = decl "stroke" c
284 | strokeWidth : Width -> Declaration
285 | strokeWidth = decl "stroke-width"
288 | strokeLinecap : Linecap -> Declaration
289 | strokeLinecap = decl "stroke-linecap"
292 | strokeLinejoin : Linejoin -> Declaration
293 | strokeLinejoin = decl "stroke-linejoin"
296 | strokeMiterlimit : Double -> Declaration
297 | strokeMiterlimit = decl "stroke-miterlimit" . show
300 | textAlign : TextAlign -> Declaration
301 | textAlign = decl "text-align"
304 | textDecoration : String -> Declaration
305 | textDecoration = Decl "text-decoration"
308 | textDecorationColor : Color -> Declaration
309 | textDecorationColor = decl "text-decoration-color"
312 | textDecorationLine : TextDecorationLine -> Declaration
313 | textDecorationLine = decl "text-decoration-line"
316 | textDecorationStyle : TextDecorationStyle -> Declaration
317 | textDecorationStyle = decl "text-decoration-style"
320 | textOverflow : TextOverflow -> Declaration
321 | textOverflow = decl "text-overflow"
324 | textOverflow2 : TextOverflow -> TextOverflow -> Declaration
325 | textOverflow2 x y = Decl "text-overflow" "\{x} \{y}"
328 | width : Width -> Declaration
329 | width = decl "width"
332 | whitespace : WhiteSpace -> Declaration
333 | whitespace = decl "white-space"