0 | module CyBy.UI.CSS.Rules
3 | import CyBy.UI.CSS.Classes
4 | import CyBy.UI.CSS.Vars
6 | import Derive.Prelude
7 | import IO.Async.Logging
8 | import Text.CSS.Cursor
9 | import Text.HTML.DomID
10 | import Text.HTML.Ref
11 | import Text.HTML.Tag
12 | import Web.Async.Widget.Types
15 | %language ElabReflection
17 | data Tag = Util | Templates | Elems | Info | Draw | Dot
19 | %runElab derive "Tag" [Show,Eq]
22 | formValues : List Selector
24 | [ elem Li > elem Div
25 | , elem Li > class widget
26 | , elem Li > elem Input
27 | , elem Li > elem Select
31 | widgetSelectors : List Selector
32 | widgetSelectors = [Elem Button, Elem Input, Elem Select, Class widget]
38 | parameters {auto v : Vars}
40 | gridGaps : Declarations
41 | gridGaps = [rowGap 0.5.em, columnGap 0.5.em]
44 | hpadded : Declaration
45 | hpadded = padding (VH 0.px v.padding)
48 | hbpadded : Declaration
49 | hbpadded = padding (THB 0.px v.padding v.padding)
52 | padded : Declaration
53 | padded = padding (All v.padding)
57 | widgetRegular : Declarations
59 | [ backgroundColor widgetBG
63 | ] ++ border1 Current ++ exactHeight v.widgetHeight ++ centerRow
68 | wactive : Declarations
69 | wactive = [backgroundColor activeBG, color activeFG]
73 | whovered : Declarations
74 | whovered = [backgroundColor hoverBG]
79 | wfocus : Declarations
80 | wfocus = [borderWidth $
All 2.px]
84 | winvalid : Declarations
85 | winvalid = [color v.errorColor]
89 | wmissing : Declarations
90 | wmissing = [color missingFG]
94 | wdisabled : Declarations
96 | [color disabledFG, backgroundColor disabledBG, borderColor (All disabledBG)]
100 | sectionBorder : Declarations
101 | sectionBorder = round8 :: borderHB1 headerBG
104 | sectionHeader : Declarations
106 | backgroundColor headerBG
110 | :: padding (VH v.smallPadding v.padding)
111 | :: exactHeight v.titleHeight
115 | sectionList : Declarations
116 | sectionList = [flex1, overflowY Auto, hbpadded] ++ stretchSepCol
119 | vsep : Declarations
121 | margin (VH v.barSepMargin 0.px)
123 | :: borderRadius v.barSepRadius
124 | :: exactHeight v.barSepWidth
127 | hsep : Declarations
129 | margin (VH 0.px v.barSepMargin)
131 | :: borderRadius v.barSepRadius
132 | :: exactWidth v.barSepWidth
135 | iconDecl : Declarations
136 | iconDecl = [noPadding, aspectRatio 1]
139 | roundIconDecl : Declarations
140 | roundIconDecl = round :: iconDecl
142 | levelRule : LogLevel -> Color -> Rule n
144 | class (level l) [fontWeight Normal, color c, width v.levelWidth]
146 | validIcon : Color.Color -> Declarations
149 | , height v.widgetHeight
151 | , position Absolute
160 | parameters {auto v : Vars}
163 | widgetRules : Selector -> Rules
165 | [ sel s $
hpadded :: widgetRegular
166 | , sel [s, Hover] whovered
167 | , sel [s, FocusVisible] wfocus
168 | , sel [s, boolAttr active] wactive
169 | , sel (elem Section > (elem Header > s)) [backgroundColor widgetInvertBG, color widgetInvertFG]
170 | , sel (elem Section > (elem Header > [s,Hover])) [backgroundColor hoverInvertBG]
171 | , sel [s, Disabled] wdisabled
172 | , sel [s, Invalid] winvalid
173 | , sel [s, attr (validity {s = ()}) (Invalid "")] winvalid
174 | , sel [s, attr (validity {s = ()}) Missing] wmissing
180 | [ elem Html [height 100.perc, width 100.perc]
186 | , backgroundColor bg
189 | , containerType Size
192 | , elem Header [noMargin]
193 | , elem Ul [noMargin, noPadding, decl "list-style" "none"]
196 | , elem Label [display Flex , alignItems Center]
198 | , class sep $
[backgroundColor bar, height v.formSepWidth]
199 | , class spacer [flex1]
200 | , elem A [color widgetFG]
209 | [cast v.bardim, 1.fr, cast v.bardim]
210 | [cast v.bardim, 4.fr, 1.fr]
211 | [ [Dot, Util, Util ]
212 | , [Elems, Draw, Info ]
213 | , [Dot, Templates, Templates]
219 | :: position Absolute
220 | :: inset (All 0.px)
230 | , Container "width < 1440px" [class sketcher [fontSize v.smallFont]]
231 | , Container "width < 1024px" [class sketcher [fontSize v.xsmallFont]]
232 | , Container "width < 768px" [class sketcher [fontSize v.xxsmallFont]]
235 | , class moleculeCanvas $
239 | :: outlineStyle None
242 | :: border1 compBorder
245 | , sel [class moleculeCanvas, boolAttr active]
246 | [ backgroundColor v.gray.c100
247 | , borderColor (All activeBG)
249 | , attribute dragMode Dragging [cursor [Move]]
250 | , attribute dragMode Rotating
251 | [cursor [URL_ "data:image/png;base64,\{rotate}", Cursor.Auto]]
254 | , class drawUtils $
gridArea Util :: centerSepRow
255 | , class drawTemplates $
gridArea Templates :: centerSepRow
256 | , class drawElems $
gridArea Elems :: centerSepCol
257 | , class drawInfo $
[containerType Size, gridArea Rules.Info] ++ stretchSepCol
258 | , sel (class drawUtils > class sep) hsep
259 | , sel (class drawElems > class sep) vsep
260 | , sel (class drawTemplates > class sep) hsep
263 | , elem Section $
overflow Hidden :: stretchSepCol ++ sectionBorder
264 | , sel (elem Section > elem Header) sectionHeader
265 | , sel (elem Section > elem Ul) sectionList
266 | , class drawDetails [containerType Size, flex2]
269 | , class drawLog [fontSize v.smallFont, containerType Size, flex1]
270 | , levelRule Fatal v.errorColor
271 | , levelRule Error v.errorColor
272 | , levelRule Warn v.warnColor
273 | , levelRule Info v.infoColor
274 | , levelRule Debug v.debugColor
275 | , levelRule Trace v.traceColor
282 | [ elem Li startSepRow
283 | , sel (elem Li > elem Label) [width v.formLblWidth, fontWeight Bold]
284 | , Sel formValues [flex1]
285 | , Container "width < 300px"
286 | [ elem Li startSepCol
287 | , sel (elem Li > elem Label) [width 100.perc]
288 | , Sel formValues [noflex]
296 | (widgetSelectors >>= widgetRules) ++
297 | [ class icon iconDecl
298 | , class roundIcon roundIconDecl
299 | , class elem [fontWeight Bold, justifyContent Center]
300 | , class pseIcon [decl "letter-spacing" "-2px"]
301 | , sel [elem Button, Hover] [cursor [Pointer]]
302 | , sel [elem Button, Disabled] [cursor [NotAllowed]]
303 | , sel [class widget, Hover] [cursor [Pointer]]
304 | , sel [class widget, Disabled] [cursor [NotAllowed]]
305 | , sel [elem Select, Hover] [cursor [Pointer]]
306 | , sel [elem Select, Disabled] [cursor [NotAllowed]]
307 | , sel [elem Input, attr type File] [display None]
308 | , class iconPlaceholder [display None]
309 | , class iconMissing $
validIcon missingFG
310 | , class iconError $
validIcon v.errorColor
311 | , class validatedInput $
position Relative :: flexRow
312 | , sel (class validatedInput > elem Input) [flex1]
313 | , sel (elem Li > class validatedInput) [flex1]
314 | , class deleteIcon $
color v.secondary.c600 :: roundIconDecl
315 | , class okIcon roundIconDecl
316 | , class addIcon roundIconDecl
321 | all = general ++ components ++ forms ++ widgets
324 | draw = class sketcher [padded] :: all
327 | main = traverse_ (putStrLn . interpolate) (draw @{defaultVars})