0 | module Text.CSS.Declaration
3 | import Text.CSS.Color
5 | import Text.CSS.Flexbox
6 | import Text.CSS.Gradient
8 | import Text.CSS.Length
9 | import Text.CSS.ListStyleType
10 | import Text.CSS.Percentage
11 | import Text.CSS.Property
16 | data Declaration : Type where
17 | Decl : (property, value : String) -> Declaration
18 | Display : Display -> Declaration
21 | Interpolation Declaration where
22 | interpolate (Decl p v) = "\{p}: \{v};"
23 | interpolate (Display Flex) = "display: flex;"
24 | interpolate (Display Grid) = "display: grid;"
25 | interpolate (Display $
Area rs cs a) = "\{renderArea rs cs a};"
28 | decl : Interpolation a => String -> a -> Declaration
29 | decl s = Decl s . interpolate
32 | prfx : Dir a -> String
33 | prfx (Left _) = "-left"
34 | prfx (Right _) = "-right"
35 | prfx (Top _) = "-top"
36 | prfx (Bottom _) = "-bottom"
40 | dirDecl : (prop : String) -> (a -> String) -> Dir a -> Declaration
42 | let vs := concat . intersperse " " . map f $
vals d
43 | in Decl "\{prop}\{prfx d}" vs
46 | dirDecl2 : (prop,suffix : String) -> (a -> String) -> Dir a -> Declaration
47 | dirDecl2 prop suffix f d =
48 | let vs := concat . intersperse " " . map f $
vals d
49 | in Decl "\{prop}\{prfx d}-\{suffix}" vs
56 | alignItems : FlexAlign -> Declaration
57 | alignItems = decl "align-items"
60 | alignSelf : FlexAlign -> Declaration
61 | alignSelf = decl "align-self"
64 | backgroundColor : Color -> Declaration
65 | backgroundColor = decl "background-color"
68 | backgroundImage : (url : String) -> Declaration
69 | backgroundImage = Decl "background-image"
72 | backgroundImageGradient : Gradient -> Declaration
73 | backgroundImageGradient = decl "background-image"
76 | backgroundSize : Width -> Declaration
77 | backgroundSize = decl "background-size"
80 | border : String -> Declaration
81 | border = Decl "border"
84 | borderColor : Dir Color -> Declaration
85 | borderColor = dirDecl2 "border" "color" interpolate
88 | borderRadius : BorderRadius -> Declaration
89 | borderRadius = decl "border-radius"
92 | borderStyle : Dir BorderStyle -> Declaration
93 | borderStyle = dirDecl2 "border" "style" interpolate
96 | borderWidth : Dir BorderWidth -> Declaration
97 | borderWidth = dirDecl2 "border" "width" interpolate
100 | boxSizing : BoxSizing -> Declaration
101 | boxSizing = decl "box-sizing"
104 | color : Color -> Declaration
105 | color = decl "color"
108 | columnGap : Length -> Declaration
109 | columnGap = decl "column-gap"
112 | direction : Direction -> Declaration
113 | direction = decl "direction"
116 | display : Display -> Declaration
120 | flex : String -> Declaration
124 | flexBasis : FlexBasis -> Declaration
125 | flexBasis = decl "flex-basis"
128 | flexDirection : FlexDirection -> Declaration
129 | flexDirection = decl "flex-direction"
132 | flexWrap : String -> Declaration
133 | flexWrap = Decl "flex-wrap"
136 | flexGrow : Nat -> Declaration
137 | flexGrow = Decl "flex-grow" . show
140 | flexFlow : List FlexFlow -> Declaration
141 | flexFlow = decl "flex-flow"
144 | fontFamily : String -> Declaration
145 | fontFamily = Decl "font-family"
148 | fontSize : FontSize -> Declaration
149 | fontSize = decl "font-size"
152 | fontWeight : FontWeight -> Declaration
153 | fontWeight = decl "font-weight"
156 | gridArea : AreaTag a => a -> Declaration
157 | gridArea = Decl "grid-area" . showTag
160 | gridColumn : GridPosition -> Declaration
161 | gridColumn = decl "grid-column"
164 | gridRow : GridPosition -> Declaration
165 | gridRow = decl "grid-row"
168 | gridTemplateColumns : List GridValue -> Declaration
169 | gridTemplateColumns = decl "grid-template-columns"
172 | gridTemplateRows : List GridValue -> Declaration
173 | gridTemplateRows = decl "grid-template-rows"
176 | height : Width -> Declaration
177 | height = decl "height"
180 | justifyContent : FlexJustify -> Declaration
181 | justifyContent = decl "justify-content"
184 | justifySelf : FlexJustify -> Declaration
185 | justifySelf = decl "justify-self"
188 | listStyleType : ListStyleType -> Declaration
189 | listStyleType = decl "list-style-type"
192 | margin : Dir Length -> Declaration
193 | margin = dirDecl "margin" interpolate
196 | maxHeight : Width -> Declaration
197 | maxHeight = decl "max-height"
200 | maxWidth : Width -> Declaration
201 | maxWidth = decl "max-width"
204 | minHeight : Width -> Declaration
205 | minHeight = decl "min-height"
208 | minWidth : Width -> Declaration
209 | minWidth = decl "min-width"
212 | overflowX : Overflow -> Declaration
213 | overflowX = decl "overflow-x"
216 | overflowY : Overflow -> Declaration
217 | overflowY = decl "overflow-y"
220 | padding : Dir Length -> Declaration
221 | padding = dirDecl "padding" interpolate
224 | rowGap : Length -> Declaration
225 | rowGap = decl "row-gap"
228 | textAlign : TextAlign -> Declaration
229 | textAlign = decl "text-align"
232 | textDecoration : String -> Declaration
233 | textDecoration = Decl "text-decoration"
236 | textDecorationColor : Color -> Declaration
237 | textDecorationColor = decl "text-decoration-color"
240 | textDecorationLine : TextDecorationLine -> Declaration
241 | textDecorationLine = decl "text-decoration-line"
244 | textDecorationStyle : TextDecorationStyle -> Declaration
245 | textDecorationStyle = decl "text-decoration-style"
248 | textOverflow : TextOverflow -> Declaration
249 | textOverflow = decl "text-overflow"
252 | textOverflow2 : TextOverflow -> TextOverflow -> Declaration
253 | textOverflow2 x y = Decl "text-overflow" "\{x} \{y}"
256 | width : Width -> Declaration
257 | width = decl "width"
260 | whitespace : WhiteSpace -> Declaration
261 | whitespace = decl "white-space"