File tree 3 files changed +9
-4
lines changed
src/components/ThemeProvider
3 files changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -6,15 +6,19 @@ import { useSyncExternalStore } from 'use-sync-external-store/shim/index.js';
6
6
import { StyleStore } from '../stores/StyleStore.js' ;
7
7
import { useIsomorphicLayoutEffect } from './useIsomorphicLayoutEffect.js' ;
8
8
9
- export function useStylesheet ( styles : StyleDataCSP , componentName : string ) {
9
+ interface UseStyleSheetOptions {
10
+ alwaysInject ?: boolean ;
11
+ }
12
+
13
+ export function useStylesheet ( styles : StyleDataCSP , componentName : string , options ?: UseStyleSheetOptions ) {
10
14
const { staticCssInjected, componentsMap } = useSyncExternalStore (
11
15
StyleStore . subscribe ,
12
16
StyleStore . getSnapshot ,
13
17
StyleStore . getServerSnapshot
14
18
) ;
15
19
16
20
useIsomorphicLayoutEffect ( ( ) => {
17
- const shouldInject = ! staticCssInjected ;
21
+ const shouldInject = options ?. alwaysInject || ! staticCssInjected ;
18
22
if ( shouldInject ) {
19
23
createOrUpdateStyle ( styles , 'data-ui5wcr-component' , componentName ) ;
20
24
StyleStore . mountComponent ( componentName ) ;
Original file line number Diff line number Diff line change 35
35
"license" : " Apache-2.0" ,
36
36
"sideEffects" : [
37
37
" ./dist/Assets.js" ,
38
- " ./dist/json-imports/*"
38
+ " ./dist/json-imports/*" ,
39
+ " ./dist/css/index.css"
39
40
],
40
41
"scripts" : {
41
42
"clean" : " rimraf dist tmp wrappers" ,
Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ let _versionInfoInjected = false;
16
16
function ThemeProviderStyles ( ) {
17
17
const uniqueId = useId ( ) ;
18
18
useStylesheet ( styleData , `${ ThemeProvider . displayName } -${ uniqueId } ` ) ;
19
- useStylesheet ( ui5WcVariablesStyleData , `${ ThemeProvider . displayName } -css-vars-${ uniqueId } ` ) ;
19
+ useStylesheet ( ui5WcVariablesStyleData , `${ ThemeProvider . displayName } -css-vars-${ uniqueId } ` , { alwaysInject : true } ) ;
20
20
return null ;
21
21
}
22
22
You can’t perform that action at this time.
0 commit comments