File tree Expand file tree Collapse file tree
apps/react-storybook/.storybook/themes Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -38,6 +38,7 @@ export const ThemeDecorator: Decorator = (Story, ctx) => {
3838
3939 const [ prevTheme , setPrevTheme ] = React . useState < string | null > ( null ) ;
4040 const [ prevCompact , setPrevCompact ] = React . useState < boolean | null > ( null ) ;
41+ const [ cssLoaded , setCssLoaded ] = React . useState ( false ) ;
4142
4243 React . useEffect ( ( ) => {
4344 if ( prevTheme !== null && prevCompact !== null ) {
@@ -54,9 +55,14 @@ export const ThemeDecorator: Decorator = (Story, ctx) => {
5455 const cssFileHref = `css/dx.${ theme } ${ compact ? '.compact' : '' } .css` ;
5556
5657 return (
57- < div className = { `dx-theme-${ themeName } -typography storybook-theme-decorator` } >
58- < link rel = "stylesheet" href = { cssFileHref } />
59- < Story />
58+ < div key = { cssFileHref } className = { `dx-theme-${ themeName } -typography storybook-theme-decorator` } >
59+ < link
60+ rel = "stylesheet"
61+ href = { cssFileHref }
62+ onLoad = { ( ) => setCssLoaded ( true ) }
63+ onError = { ( ) => setCssLoaded ( true ) }
64+ />
65+ { cssLoaded && < Story /> }
6066 </ div >
6167 ) ;
6268}
You can’t perform that action at this time.
0 commit comments