You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -105,6 +109,7 @@ Sometimes you want toggle between two values. In this example a menu item can sw
105
109
```
106
110
107
111
Because this pattern is so common there's a special treatment for predicate attributes (keywords ending with `?`) in styles definition.
112
+
108
113
```clojure
109
114
(defstyledMenuItem:li
110
115
{:color"grey"
@@ -114,12 +119,28 @@ Because this pattern is so common there's a special treatment for predicate attr
114
119
```
115
120
116
121
### pseudo-classes
117
-
CSS pseudo classes can be added using parent selector syntax `&` which is popular in CSS pre-processors.
122
+
123
+
CSS pseudo classes can be expressed as a keyword using parent selector syntax `&` which is popular in CSS pre-processors or as a string if selector is not a valid keyword e.g. `&:nth-child(4)`.
124
+
118
125
```clojure
119
126
(defstylesbutton [bg]
120
127
{:font-size"14px"
121
128
:background-color blue
122
-
:&:hover {:background-color light-blue}})
129
+
:&:hover {:background-color light-blue}
130
+
"&:nth-child(3)" {:color"blue"}})
131
+
```
132
+
133
+
### Nested selectors
134
+
135
+
Sometimes when you want to override library styles you may want to refer to DOM node via its class name, tag or whatever. For this purpose you can use nested CSS selectors via string key.
@@ -152,7 +173,7 @@ _NOTE: This feature is supported only for Rum/Sablono elements_
152
173
153
174
`font-face` macro allows to define custom fonts via `@font-face` CSS at-rule. The macro generates CSS string and injects it at runtime. The syntax is defined in example below.
154
175
155
-
_The macro supports referring to styles declaration in a separate *.clj namespace._
176
+
_The macro supports referring to styles declaration in a separate \*.clj namespace._
156
177
157
178
```clojure
158
179
(require '[cljss.core :refer [font-face]])
@@ -176,7 +197,7 @@ _The macro supports referring to styles declaration in a separate *.clj namespac
176
197
177
198
`inject-global` macro allows to defined global styles, such as to reset user agent default styles. The macro generates CSS string and injects it at runtime. The syntax is defined in example below.
178
199
179
-
_The macro supports referring to styles declaration in a separate *.clj namespace._
200
+
_The macro supports referring to styles declaration in a separate \*.clj namespace._
180
201
181
202
```clojure
182
203
(require '[cljss.core :refer [inject-global]])
@@ -208,28 +229,34 @@ The syntax is specified as of [CSS Media Queries Level 4 spec](https://www.w3.or
208
229
More examples of a query:
209
230
210
231
#### Boolean query
232
+
211
233
```clojure
212
234
[[:monochrome]]
213
235
```
214
236
215
237
#### Simple conditional query
238
+
216
239
```clojure
217
240
[[:max-width"460px"]]
218
241
```
219
242
220
243
#### Multiple (comma separated) queries
244
+
221
245
```clojure
222
246
[[:screen:and [:max-width"460px"]]
223
247
[:print:and [:color]]]
224
248
```
225
249
226
250
#### Basic range query
251
+
227
252
_Supported operators for range queries_ `#{'= '< '<= '> '>=}`
253
+
228
254
```clojure
229
255
'[[:max-width > "400px"]]
230
256
```
231
257
232
258
#### Complex range query
259
+
233
260
```clojure
234
261
'[["1200px" >= :max-width > "400px"]]
235
262
```
@@ -260,6 +287,7 @@ _Supported operators for range queries_ `#{'= '< '<= '> '>=}`
260
287
- `styles` a hash map of styles definition
261
288
262
289
Using [Sablono](https://github.com/r0man/sablono) templating for [React](https://facebook.github.io/react/)
290
+
263
291
```clojure
264
292
(nsexample.core
265
293
(:require [sablono.core :refer [html]]
@@ -276,6 +304,7 @@ Using [Sablono](https://github.com/r0man/sablono) templating for [React](https:/
276
304
```
277
305
278
306
Dynamically injected CSS:
307
+
279
308
```css
280
309
.css-43697 {
281
310
padding: 16px;
@@ -298,19 +327,18 @@ Because CSS is generated at compile-time it's not possible to compose styles as
When developing with Figwheel in order to deduplicate styles between reloads it is recommended to use Figwheel's `:on-jsload` hook to clean injected styles.
312
341
313
-
314
342
```clojure
315
343
:figwheel {:on-jsload example.core/on-reload}
316
344
```
@@ -338,15 +366,16 @@ Set `goog.DEBUG` to `false` to enable fast path styles injection.
338
366
_NOTE: production build enables fast pass styles injection which makes those styles invisible in `<style>` tag on a page._
339
367
340
368
## Roadmap
369
+
341
370
- Server-side rendering
342
371
343
372
## Contributing
373
+
344
374
- Pick an issue with `help wanted` label (make sure no one is working on it)
345
375
- Stick to project's code style as much as possible
346
376
- Make small commits with descriptive commit messages
347
377
- Submit a PR with detailed description of what was done
348
378
349
-
350
379
## Development
351
380
352
381
A repl for the example project is provided via [lein-figwheel](https://github.com/bhauman/lein-figwheel).
0 commit comments