Skip to content

Commit d9efa19

Browse files
chore(unity-react-core): storybook docs should only render react example
1 parent c3f1e27 commit d9efa19

File tree

2 files changed

+9
-30
lines changed

2 files changed

+9
-30
lines changed

packages/unity-react-core/.storybook/decorators.tsx

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@ declare interface ContainerProps {
1818

1919
const Full:ContainerComponent<ContainerProps, any> = forwardRef((props, ref) => {
2020
return (
21-
<div ref={ref} id="html-root" className="col uds-full-width" {...props}/>
21+
<div ref={ref} className="col uds-full-width" {...props}/>
2222
)});
2323

2424
const UdsContainer:ContainerComponent<ContainerProps, any> = forwardRef((props, ref) => {
2525
return (
2626
<div className="container">
2727
<div className="row">
28-
<div ref={ref} id="html-root" className="uds-container" {...props}/>
28+
<div ref={ref} className="uds-container" {...props}/>
2929
</div>
3030
</div>
3131
)});
@@ -34,21 +34,22 @@ export const withContainer: Decorator = (
3434
StoryFn,
3535
{
3636
args,
37-
globals: { framework = "react" },
37+
globals,
3838
parameters: { layout = "fullscreen" },
39+
viewMode,
3940
}
4041
) => {
42+
let { framework = "react" } = globals;
43+
// Doc page will only render react framework
44+
if(viewMode === "docs") {
45+
framework = "react";
46+
}
4147
const isBootstrap = framework === "bootstrap";
42-
const isReact = !isBootstrap;
4348
const root = React.useRef(null as any);
4449

4550
const emit = useChannel({ "HTML/CodeUpdated": () => {} });
4651

47-
48-
4952
const mount = () => {
50-
// console.log("sb mounting");
51-
5253
if (root.current) {
5354
if (isBootstrap) {
5455
// custom events created by eventSpy.js to allow storybook to dispatch load events after the page is loaded
@@ -58,7 +59,6 @@ export const withContainer: Decorator = (
5859

5960
emit("HTML/CodeUpdated", { code: root.current.innerHTML });
6061
}
61-
6262
}
6363

6464
const unmount = () => {
@@ -77,19 +77,10 @@ export const withContainer: Decorator = (
7777
}
7878
}
7979

80-
81-
82-
83-
84-
85-
86-
8780
useEffect(() => {
8881
// @ts-ignore
8982
if (!window.unloading) {
9083
mount()
91-
} else {
92-
9384
}
9485
return unmount
9586
}, [StoryFn, args, framework]);
@@ -116,5 +107,3 @@ export const withContainer: Decorator = (
116107
export const globalDecorators = [
117108
withContainer
118109
];
119-
120-

packages/unity-react-core/.storybook/preview.jsx

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@ import "@asu/unity-bootstrap-theme/src/js/unity-bootstrap-theme.js";
77
import { globalDecorators } from "./decorators.tsx";
88
import { Container } from "./docPage.tsx";
99

10-
11-
const sourceCodeRootSelector = "#html-root";
12-
1310
const parameters = {
1411
controls: { expanded: true },
1512
argTypes: {
@@ -29,13 +26,6 @@ const parameters = {
2926
},
3027
],
3128
},
32-
html: {
33-
prettier: {
34-
tabWidth: 4,
35-
htmlWhitespaceSensitivity: "ignore",
36-
},
37-
root: sourceCodeRootSelector,
38-
},
3929
docs: {
4030
// Table of contents stopped working, so I disabled it.
4131
// If we can figure out how to get it working again, we can re-enable it.

0 commit comments

Comments
 (0)