File tree Expand file tree Collapse file tree 3 files changed +9
-4
lines changed
src/components/ThemeProvider Expand file tree Collapse file tree 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';
66import { StyleStore } from '../stores/StyleStore.js' ;
77import { useIsomorphicLayoutEffect } from './useIsomorphicLayoutEffect.js' ;
88
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 ) {
1014 const { staticCssInjected, componentsMap } = useSyncExternalStore (
1115 StyleStore . subscribe ,
1216 StyleStore . getSnapshot ,
1317 StyleStore . getServerSnapshot
1418 ) ;
1519
1620 useIsomorphicLayoutEffect ( ( ) => {
17- const shouldInject = ! staticCssInjected ;
21+ const shouldInject = options ?. alwaysInject || ! staticCssInjected ;
1822 if ( shouldInject ) {
1923 createOrUpdateStyle ( styles , 'data-ui5wcr-component' , componentName ) ;
2024 StyleStore . mountComponent ( componentName ) ;
Original file line number Diff line number Diff line change 4141 "license" : " Apache-2.0" ,
4242 "sideEffects" : [
4343 " ./dist/Assets.js" ,
44- " ./dist/json-imports/*"
44+ " ./dist/json-imports/*" ,
45+ " ./dist/css/index.css"
4546 ],
4647 "scripts" : {
4748 "clean" : " rimraf dist tmp wrappers ssr" ,
Original file line number Diff line number Diff line change @@ -20,7 +20,7 @@ import { styleData } from './ThemeProvider.css.js';
2020function ThemeProviderStyles ( ) {
2121 const uniqueId = useIsomorphicId ( ) ;
2222 useStylesheet ( styleData , `${ ThemeProvider . displayName } -${ uniqueId } ` ) ;
23- useStylesheet ( ui5WcVariablesStyleData , `${ ThemeProvider . displayName } -css-vars-${ uniqueId } ` ) ;
23+ useStylesheet ( ui5WcVariablesStyleData , `${ ThemeProvider . displayName } -css-vars-${ uniqueId } ` , { alwaysInject : true } ) ;
2424 return null ;
2525}
2626
You can’t perform that action at this time.
0 commit comments