Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0c22d89
commit dd1d4e7
Showing
20 changed files
with
147 additions
and
72 deletions.
There are no files selected for viewing
7 changes: 7 additions & 0 deletions
7
change/@griffel-core-80492b15-83a7-4ca1-8c1b-b5aeb0c3aa58.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"type": "minor", | ||
"comment": "feat: add API for styles insertion", | ||
"packageName": "@griffel/core", | ||
"email": "olfedias@microsoft.com", | ||
"dependentChangeType": "patch" | ||
} |
7 changes: 7 additions & 0 deletions
7
change/@griffel-react-13bf5fac-a88b-41ad-98fc-a8df3be96e6d.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"type": "patch", | ||
"comment": "chore: improve React 18 support", | ||
"packageName": "@griffel/react", | ||
"email": "olfedias@microsoft.com", | ||
"dependentChangeType": "patch" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { CSSRulesByBucket, GriffelInsertionFactory, GriffelRenderer } from './types'; | ||
|
||
export const insertionFactory: GriffelInsertionFactory = () => { | ||
const insertionCache: Record<string, boolean> = {}; | ||
|
||
return function insertStyles(renderer: GriffelRenderer, dir: string, cssRules: CSSRulesByBucket) { | ||
if (insertionCache[renderer.id] === undefined) { | ||
renderer.insertCSSRules(cssRules!); | ||
insertionCache[renderer.id] = true; | ||
} | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import type { CSSRulesByBucket, GriffelInsertionFactory, GriffelRenderer } from '@griffel/core'; | ||
|
||
import { canUseDOM } from './utils/canUseDOM'; | ||
import { useInsertionEffect } from './useInsertionEffect'; | ||
|
||
export const insertionFactory: GriffelInsertionFactory = () => { | ||
const insertionCache: Record<string, boolean> = {}; | ||
|
||
return function insert(renderer: GriffelRenderer, dir: string, cssRules: CSSRulesByBucket) { | ||
if (useInsertionEffect) { | ||
// Even if `useInsertionEffect` is available, we can't use it in SSR as it will not be executed | ||
if (canUseDOM()) { | ||
// eslint-disable-next-line react-hooks/rules-of-hooks | ||
useInsertionEffect(() => { | ||
renderer.insertCSSRules(cssRules!); | ||
}, [renderer, cssRules]); | ||
|
||
return; | ||
} | ||
} | ||
|
||
if (insertionCache[renderer.id] === undefined) { | ||
renderer.insertCSSRules(cssRules!); | ||
insertionCache[renderer.id] = true; | ||
} | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.