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 @@ -34,12 +34,18 @@ export const compact = [
3434
3535export const ThemeDecorator : Decorator = ( Story , ctx ) => {
3636 const { theme, compact } = ctx . globals ;
37+ const [ cssLoaded , setCssLoaded ] = React . useState ( false ) ;
3738 const themeName = theme . split ( '.' ) . length < 3 ? 'generic' : theme . split ( '.' ) [ 0 ] ;
3839 const cssFileHref = `css/dx.${ theme } ${ compact ? '.compact' : '' } .css`
3940 return (
40- < div className = { `dx-theme-${ themeName } -typography storybook-theme-decorator` } >
41- < link rel = "stylesheet" href = { cssFileHref } />
42- < Story />
41+ < div key = { cssFileHref } className = { `dx-theme-${ themeName } -typography storybook-theme-decorator` } >
42+ < link
43+ rel = "stylesheet"
44+ href = { cssFileHref }
45+ onLoad = { ( ) => setCssLoaded ( true ) }
46+ onError = { ( ) => setCssLoaded ( true ) }
47+ />
48+ { cssLoaded && < Story /> }
4349 </ div >
4450 ) ;
4551}
You can’t perform that action at this time.
0 commit comments