File tree Expand file tree Collapse file tree 3 files changed +21
-35
lines changed
packages/unity-bootstrap-theme
stories/molecules/cookie-consent Expand file tree Collapse file tree 3 files changed +21
-35
lines changed Original file line number Diff line number Diff line change 1+ import React , { useEffect } from "react" ;
2+
3+ export const forceReloadOfStory = ( storyFn , context ) => {
4+ useEffect ( ( ) => {
5+ setTimeout ( ( ) => {
6+ context . globals . shouldReload = true ;
7+ } , 100 ) ;
8+ return ( ) => {
9+ if ( context . globals . shouldReload ) {
10+ window . location . reload ( ) ;
11+ }
12+ } ;
13+ } , [ ] ) ;
14+
15+ return storyFn ( ) ;
16+ }
Original file line number Diff line number Diff line change 11import React , { useEffect } from "react" ;
2- import { allCookieConsentJS } from "../../../src/js/cookie-consent-full-screen.js" ;
2+ import { forceReloadOfStory } from "../../../.storybook/decorators" ;
3+ import { allCookieConsentJS } from "../../../src/js/cookie-consent-full-screen" ;
34import "../../../src/css/cookie-consent-full-screen.css" ;
45
56export default {
67 title : "Molecules/Cookie Consent" ,
7- // Forces reload of the story to keep css and js from persisting between stories
8- decorators : [
9- ( storyFn , context ) => {
10- useEffect ( ( ) => {
11- // document.querySelector("body")?.classList.add("bg-gray-2");
12- setTimeout ( ( ) => {
13- context . globals . shouldReload = true ;
14- } , 100 ) ;
15- return ( ) => {
16- // document.querySelector("body")?.classList.remove("bg-gray-2");
17- if ( context . globals . shouldReload ) {
18- window . location . reload ( ) ;
19- }
20- } ;
21- } , [ ] ) ;
22- return storyFn ( ) ;
23- } ,
24- ] ,
8+ decorators : [ forceReloadOfStory ] ,
259 parameters : { controls : { disable : true } } ,
2610} ;
2711export const FullScreenBannerCookieConsent = ( ) => {
Original file line number Diff line number Diff line change 11import React , { useEffect } from "react" ;
22import { allCookieConsentJS } from "../../../src/js/cookie-consent" ;
3+ import { forceReloadOfStory } from "../../../.storybook/decorators" ;
34import "../../../src/css/cookie-consent.css" ;
45
56export default {
67 title : "Molecules/Cookie Consent" ,
7- // Forces reload of the story to keep css and js from persisting between stories
8- decorators : [
9- ( storyFn , context ) => {
10- useEffect ( ( ) => {
11- setTimeout ( ( ) => {
12- context . globals . shouldReload = true ;
13- } , 100 ) ;
14- return ( ) => {
15- if ( context . globals . shouldReload ) {
16- window . location . reload ( ) ;
17- }
18- } ;
19- } , [ ] ) ;
20- return storyFn ( ) ;
21- } ,
22- ] ,
8+ decorators : [ forceReloadOfStory ] ,
239 parameters : { controls : { disable : true } } ,
2410} ;
2511export const MaxWidthCookieConsent = ( ) => {
You can’t perform that action at this time.
0 commit comments