~alcinnz/haskell-stylist

ref: b93db8b7308658745714cf326e1ba7348fca0f5e haskell-stylist/psuedoclass-plans.md -rw-r--r-- 1.8 KiB
b93db8b7 — Adrian Cochrane Implement whitespace collapse, togglable via white-space: pre/normal; 4 years ago
                                                                                
a86d830d Adrian Cochrane
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
Currently Stylish Haskell lacks support for psuedo-classes/elements, which is a significant shortcoming. So what would it take?

To start the following psuedoclasses need to be defined by the caller (mostly in implementing forms), either before or after the CSS is evaluated:

* active
* checked
* default
* defined -- selects builtin elements or "custom elements".
* disabled
* empty -- since I do not directly reference children, just parents.
* enabled
* focus
* focus-within
* hover
* indeterminate
* in-range
* invalid
* optional
* out-of-range
* read-only
* read-write
* required
* target
* valid
* visited

The pseudoelements meanwhile need to be applied after selection:
* before
* after
* cue
* first-letter
* first-line
* selection

:link, :lang(), & :root/:scope can compile down to existing selectorFuncs. 

Furthermore there's those psuedoclasses which tests the position of the element in the list.
* first-child
* first-of-type
* last-child
* last-of-type
* only-child
* only-of-type
* :nth-child()
* :nth-last-child()
* :nth-last-of-type()
* :nth-of-type()
:first-child, :first-of-type, :nth-child(), :nth-of-type() can easily be tested by traversing prev pointers.
But for only/last psuedoclasses I'd need to store additional counts.

Furthermore there's functional psuedoclasses which takes additional arguments:
* :not(selector)
* :where()/:is()
I need to compile these down myself.

I'd be tempted to output a structure mapping psuedoclasses to style objects,
after having compiled some of those as part of the selector itself.
Though the issue with that is that it prevents popular solutions for creating JavaScript-free webpages.

I guess I'd add a psuedoclass field to elements, and there's already a hook
where embedders can decide how they want to deal with it.

Sorry this document is a bit rambly!