@griffel/react 1.5.5 → 1.5.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +56 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -15,6 +15,7 @@ A package with wrappers and APIs to be used with React.js.
|
|
|
15
15
|
- [`makeStaticStyles()`](#makestaticstyles)
|
|
16
16
|
- [`makeResetStyles()`](#makeresetstyles)
|
|
17
17
|
- [`createDOMRenderer()`, `RendererProvider`](#createdomrenderer-rendererprovider)
|
|
18
|
+
- [compareMediaQueries](#comparemediaqueries)
|
|
18
19
|
- [insertionPoint](#insertionpoint)
|
|
19
20
|
- [styleElementAttributes](#styleelementattributes)
|
|
20
21
|
- [`TextDirectionProvider`](#textdirectionprovider)
|
|
@@ -376,6 +377,61 @@ function App(props) {
|
|
|
376
377
|
}
|
|
377
378
|
```
|
|
378
379
|
|
|
380
|
+
### compareMediaQueries
|
|
381
|
+
|
|
382
|
+
A function with the same signature as sort functions in e.g. `Array.prototype.sort` for dynamically sorting media queries. Maps over an array of media query strings.
|
|
383
|
+
|
|
384
|
+
Griffel does not provide an opinionated default to sort media queries as the order may vary depending on the specific needs of the application.
|
|
385
|
+
|
|
386
|
+
```js
|
|
387
|
+
import { createDOMRenderer } from '@griffel/react';
|
|
388
|
+
|
|
389
|
+
const mediaQueryOrder = [
|
|
390
|
+
'only screen and (min-width: 1366px)',
|
|
391
|
+
'only screen and (min-width: 1366px)',
|
|
392
|
+
'only screen and (min-width: 1920px)',
|
|
393
|
+
];
|
|
394
|
+
|
|
395
|
+
function sortMediaQueries(a, b) {
|
|
396
|
+
return mediaQueryOrder.indexOf(a) - mediaQueryOrder.indexOf(b);
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
const renderer = createDOMRenderer(document, {
|
|
400
|
+
compareMediaQueries,
|
|
401
|
+
});
|
|
402
|
+
```
|
|
403
|
+
|
|
404
|
+
```html
|
|
405
|
+
<html>
|
|
406
|
+
<head>
|
|
407
|
+
<style media="only screen and (min-width: 1024px)" data-make-styles-bucket="m"></style>
|
|
408
|
+
<style media="only screen and (min-width: 1366px)" data-make-styles-bucket="m"></style>
|
|
409
|
+
<style media="only screen and (min-width: 1920px)" data-make-styles-bucket="m"></style>
|
|
410
|
+
</head>
|
|
411
|
+
</html>
|
|
412
|
+
```
|
|
413
|
+
|
|
414
|
+
For mobile-first methodology, you can consider using [`sort-css-media-queries`](https://github.com/dutchenkoOleg/sort-css-media-queries):
|
|
415
|
+
|
|
416
|
+
```js
|
|
417
|
+
import { createDOMRenderer } from '@griffel/react';
|
|
418
|
+
import sortCSSmq from 'sort-css-media-queries';
|
|
419
|
+
|
|
420
|
+
const renderer = createDOMRenderer(document, {
|
|
421
|
+
compareMediaQueries: sortCSSmq,
|
|
422
|
+
});
|
|
423
|
+
```
|
|
424
|
+
|
|
425
|
+
```html
|
|
426
|
+
<html>
|
|
427
|
+
<head>
|
|
428
|
+
<style media="only screen and (min-width: 1px)" data-make-styles-bucket="m"></style>
|
|
429
|
+
<style media="only screen and (min-width: 480px)" data-make-styles-bucket="m"></style>
|
|
430
|
+
<style media="only screen and (min-width: 640px)" data-make-styles-bucket="m"></style>
|
|
431
|
+
</head>
|
|
432
|
+
</html>
|
|
433
|
+
```
|
|
434
|
+
|
|
379
435
|
### insertionPoint
|
|
380
436
|
|
|
381
437
|
If specified, a renderer will insert created style tags after this element:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@griffel/react",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.6",
|
|
4
4
|
"description": "React implementation of Atomic CSS-in-JS",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
},
|
|
10
10
|
"sideEffects": false,
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@griffel/core": "^1.10.
|
|
12
|
+
"@griffel/core": "^1.10.1",
|
|
13
13
|
"tslib": "^2.1.0"
|
|
14
14
|
},
|
|
15
15
|
"peerDependencies": {
|