Skip to content

Commit 03f6ba5

Browse files
docs(unity-bootstrap-theme): update Cassie cookie consent
1 parent 9089670 commit 03f6ba5

File tree

3 files changed

+21
-35
lines changed

3 files changed

+21
-35
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
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+
}

packages/unity-bootstrap-theme/stories/molecules/cookie-consent/cookie-consent-full-screen.stories.js

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,11 @@
11
import 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";
34
import "../../../src/css/cookie-consent-full-screen.css";
45

56
export 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
};
2711
export const FullScreenBannerCookieConsent = () => {

packages/unity-bootstrap-theme/stories/molecules/cookie-consent/cookie-consent.stories.js

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,11 @@
11
import React, { useEffect } from "react";
22
import { allCookieConsentJS } from "../../../src/js/cookie-consent";
3+
import { forceReloadOfStory } from "../../../.storybook/decorators";
34
import "../../../src/css/cookie-consent.css";
45

56
export 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
};
2511
export const MaxWidthCookieConsent = () => {

0 commit comments

Comments
 (0)