@@ -61,20 +61,95 @@ instance isStringSelector :: IsString Selector where
61
61
" ." -> Selector (Refinement [Class $ drop 1 s]) Star
62
62
_ -> Selector (Refinement [] ) (Elem s)
63
63
64
+ -- | The star selector applies to all elements.
65
+ -- | Maps to `*` in CSS.
64
66
star :: Selector
65
67
star = Selector (Refinement [] ) Star
66
68
69
+ -- | Select elements by name.
67
70
element :: String -> Selector
68
71
element e = Selector (Refinement [] ) (Elem e)
69
72
73
+ -- | The deep selector composer.
74
+ -- | Maps to `sel1 sel2` in CSS.
70
75
deep :: Selector -> Selector -> Selector
71
76
deep a b = Selector (Refinement [] ) (Deep a b)
72
77
infix 6 deep as **
73
78
79
+ -- | The child selector composer.
80
+ -- | Maps to `sel1 > sel2` in CSS.
74
81
child :: Selector -> Selector -> Selector
75
82
child a b = Selector (Refinement [] ) (PathChild a b)
76
83
infix 6 child as |>
77
84
85
+ -- | The adjacent selector composer.
86
+ -- | Maps to `sel1 + sel2` in CSS.
87
+ adjacent :: Selector -> Selector -> Selector
88
+ adjacent a b = Selector (Refinement [] ) (Adjacent a b)
89
+ infix 6 child as |+
90
+
91
+ -- | The filter selector composer, adds a filter to a selector.
92
+ -- | Maps to something like `sel#filter`, `sel.filter` or `sel:filter` in CSS,
93
+ -- | depending on the filter.
78
94
with :: Selector -> Refinement -> Selector
79
95
with (Selector (Refinement fs) e) (Refinement ps) = Selector (Refinement (fs <> ps)) e
80
96
infix 6 with as ##
97
+
98
+ -- | Filter elements by id.
99
+ byId :: String -> Refinement
100
+ byId = Refinement <<< pure <<< Id
101
+
102
+ -- | Filter elements by class.
103
+ byClass :: String -> Refinement
104
+ byClass = Refinement <<< pure <<< Class
105
+
106
+ -- | Filter elements by pseudo selector or pseudo class.
107
+ -- | The preferred syntax is to use `:pseudo-selector` or
108
+ -- | use one of the predefined ones from `CSS.Pseudo`.
109
+ pseudo :: String -> Refinement
110
+ pseudo = Refinement <<< pure <<< Pseudo
111
+
112
+ -- | Filter elements by pseudo selector functions.
113
+ -- | The preferred way is to use one of the predefined functions from `CSS.Pseudo`.
114
+ func :: String -> Array String -> Refinement
115
+ func f = Refinement <<< pure <<< PseudoFunc f
116
+
117
+ -- | Filter elements based on the presence of a certain attribute.
118
+ attr :: String -> Refinement
119
+ attr = Refinement <<< pure <<< Attr
120
+
121
+ -- | Filter elements based on the presence of a
122
+ -- | certain attribute with the specified value.
123
+ attrVal :: String -> String -> Refinement
124
+ attrVal a = Refinement <<< pure <<< AttrVal a
125
+ infix 6 with as @=
126
+
127
+ -- | Filter elements based on the presence of a certain attribute that
128
+ -- | begins with the selected value.
129
+ attrBegins :: String -> String -> Refinement
130
+ attrBegins a = Refinement <<< pure <<< AttrBegins a
131
+ infix 6 with as ^=
132
+
133
+ -- | Filter elements based on the presence of a certain attribute that
134
+ -- | ends with the specified value.
135
+ attrEnds :: String -> String -> Refinement
136
+ attrEnds a = Refinement <<< pure <<< AttrEnds a
137
+ infix 6 with as $=
138
+
139
+ -- | Filter elements based on the presence of a certain attribute that contains
140
+ -- | the specified value as a substring.
141
+ attrContains :: String -> String -> Refinement
142
+ attrContains a = Refinement <<< pure <<< AttrContains a
143
+ infix 6 with as *=
144
+
145
+ -- | Filter elements based on the presence of a certain attribute that
146
+ -- | have the specified value contained in a space separated list.
147
+ attrSpace :: String -> String -> Refinement
148
+ attrSpace a = Refinement <<< pure <<< AttrSpace a
149
+ infix 6 with as ~=
150
+
151
+ -- | Filter elements based on the presence of a certain attribute that
152
+ -- | have the specified value contained in a hyphen separated list.
153
+ attrHyph :: String -> String -> Refinement
154
+ attrHyph a = Refinement <<< pure <<< AttrHyph a
155
+ infix 6 with as |=
0 commit comments