@griffel/react 1.5.1 → 1.5.2

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.
Files changed (2) hide show
  1. package/README.md +73 -2
  2. package/package.json +2 -2
package/README.md CHANGED
@@ -10,11 +10,13 @@ A package with wrappers and APIs to be used with React.js.
10
10
  - [Pseudo & class selectors, at-rules, global styles](#pseudo--class-selectors-at-rules-global-styles)
11
11
  - [Keyframes (animations)](#keyframes-animations)
12
12
  - [CSS Fallback Properties](#css-fallback-properties)
13
+ - [RTL support](#rtl-support)
13
14
  - [`mergeClasses()`](#mergeclasses)
14
15
  - [`makeStaticStyles()`](#makestaticstyles)
15
16
  - [`makeResetStyles()`](#makeresetstyles)
16
17
  - [`createDOMRenderer()`, `RendererProvider`](#createdomrenderer-rendererprovider)
17
18
  - [styleElementAttributes](#styleelementattributes)
19
+ - [`TextDirectionProvider`](#textdirectionprovider)
18
20
  - [Shorthands](#shorthands)
19
21
  - [`shorthands.border`](#shorthandsborder)
20
22
  - [`shorthands.borderBottom`, `shorthands.borderTop`, `shorthands.borderLeft`, `shorthands.borderRight`](#shorthandsborderbottom-shorthandsbordertop-shorthandsborderleft-shorthandsborderright)
@@ -133,8 +135,6 @@ const useClasses = makeStyles({
133
135
  });
134
136
  ```
135
137
 
136
-
137
-
138
138
  ### CSS Fallback Properties
139
139
 
140
140
  Any CSS property accepts an array of values which are all added to the styles.
@@ -150,6 +150,54 @@ const useClasses = makeStyles({
150
150
  });
151
151
  ```
152
152
 
153
+ ### RTL support
154
+
155
+ Griffel uses [rtl-css-js](https://github.com/kentcdodds/rtl-css-js) to perform automatic flipping of properties and values in Right-To-Left (RTL) text direction defined by `TextDirectionProvider`.
156
+
157
+ ```js
158
+ import { makeStyles } from '@griffel/react';
159
+
160
+ const useClasses = makeStyles({
161
+ root: {
162
+ paddingLeft: '10px',
163
+ },
164
+ });
165
+ ```
166
+
167
+ ⬇️⬇️⬇️
168
+
169
+ ```css
170
+ /* Will be applied in LTR */
171
+ .frdkuqy {
172
+ padding-left: 10px;
173
+ }
174
+ /* Will be applied in RTL */
175
+ .f81rol6 {
176
+ padding-right: 10px;
177
+ }
178
+ ```
179
+
180
+ You can also control which rules you don't want to flip by adding a `/* @noflip */` CSS comment to your rule:
181
+
182
+ ```js
183
+ import { makeStyles } from '@griffel/react';
184
+
185
+ const useClasses = makeStyles({
186
+ root: {
187
+ paddingLeft: '10px /* @noflip */',
188
+ },
189
+ });
190
+ ```
191
+
192
+ ⬇️⬇️⬇️
193
+
194
+ ```css
195
+ /* Will be applied in LTR & RTL */
196
+ .f6x5cb6 {
197
+ padding-left: 10px;
198
+ }
199
+ ```
200
+
153
201
  ## `mergeClasses()`
154
202
 
155
203
  > 💡 **It is not possible to simply concatenate classes returned by `useClasses()`.**
@@ -341,6 +389,29 @@ const renderer = createDOMRenderer(targetDocument, {
341
389
  });
342
390
  ```
343
391
 
392
+ ## `TextDirectionProvider`
393
+
394
+ `TextDirectionProvider` is used to determine the text direction for style computation. The default text direction is Left-To-Right (LTR).
395
+
396
+ ```jsx
397
+ import { TextDirectionProvider } from '@griffel/react';
398
+
399
+ function App() {
400
+ return (
401
+ <>
402
+ <TextDirectionProvider>
403
+ {/* Inner components will have styles for LTR */}
404
+ {/* ... */}
405
+ </TextDirectionProvider>
406
+ <TextDirectionProvider dir="rtl">
407
+ {/* Inner components will have styles for RTL */}
408
+ {/* ... */}
409
+ </TextDirectionProvider>
410
+ </>
411
+ );
412
+ }
413
+ ```
414
+
344
415
  ## Shorthands
345
416
 
346
417
  `shorthands` provides a set of functions to mimic [CSS shorthands](https://developer.mozilla.org/en-US/docs/Web/CSS/Shorthand_properties) and improve developer experience as [CSS shorthands are not supported](https://griffel.js.org/react/guides/limitations#css-shorthands-are-not-supported) by Griffel.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@griffel/react",
3
- "version": "1.5.1",
3
+ "version": "1.5.2",
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.8.3",
12
+ "@griffel/core": "^1.9.0",
13
13
  "tslib": "^2.1.0"
14
14
  },
15
15
  "peerDependencies": {