Skip to content

Commit

Permalink
fix: multiple stories because of Storybook bug (#1269)
Browse files Browse the repository at this point in the history
  • Loading branch information
BoxedFruits committed Feb 9, 2023
1 parent 9836998 commit 5f012aa
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 51 deletions.
5 changes: 0 additions & 5 deletions .storybook/preview.ts

This file was deleted.

14 changes: 14 additions & 0 deletions .storybook/preview.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import React from 'react'
import './index.css'

export const parameters = {
layout: 'fullscreen',
}

export const decorators = [
(Story) => (
<React.Suspense fallback={null}>
<Story />
</React.Suspense>
),
]
4 changes: 2 additions & 2 deletions .storybook/stories/Billboard.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ BillboardStory.args = {
BillboardStory.storyName = 'Planes'

export const BillboardTextStory = ({ follow, lockX, lockY, lockZ }) => (
<React.Suspense fallback={null}>
<>
<Billboard follow={follow} lockX={lockX} lockY={lockY} lockZ={lockZ} position={[0.5, 2.05, 0.5]}>
<Text fontSize={1} outlineWidth={'5%'} outlineColor="#000000" outlineOpacity={1}>
box
Expand All @@ -76,7 +76,7 @@ export const BillboardTextStory = ({ follow, lockX, lockY, lockZ }) => (
</Billboard>

<OrbitControls enablePan={true} zoomSpeed={0.5} />
</React.Suspense>
</>
)

BillboardTextStory.args = {
Expand Down
14 changes: 5 additions & 9 deletions .storybook/stories/CameraShake.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,8 @@ function Scene() {

export const CameraShakeStory = ({ ...args }) => (
<>
<React.Suspense fallback={null}>
<CameraShake {...args} />
<Scene />
</React.Suspense>
<CameraShake {...args} />
<Scene />
</>
)

Expand All @@ -95,11 +93,9 @@ export const CameraShakeWithOrbitControlsStory = ({ ...args }) => {
const controlsRef = React.useRef<OrbitControlsImpl>(null)
return (
<>
<React.Suspense fallback={null}>
<OrbitControls ref={controlsRef} />
<CameraShake {...args} controls={controlsRef} />
<Scene />
</React.Suspense>
<OrbitControls ref={controlsRef} />
<CameraShake {...args} controls={controlsRef} />
<Scene />
</>
)
}
Expand Down
46 changes: 20 additions & 26 deletions .storybook/stories/Environment.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,11 @@ export default {

export const EnvironmentStory = ({ background, preset, blur }) => (
<>
<React.Suspense fallback={null}>
<Environment preset={preset} background={background} blur={blur} />
<mesh>
<torusKnotGeometry args={[1, 0.5, 128, 32]} />
<meshStandardMaterial metalness={1} roughness={0} />
</mesh>
</React.Suspense>
<Environment preset={preset} background={background} blur={blur} />
<mesh>
<torusKnotGeometry args={[1, 0.5, 128, 32]} />
<meshStandardMaterial metalness={1} roughness={0} />
</mesh>
<OrbitControls autoRotate />
</>
)
Expand All @@ -54,17 +52,15 @@ EnvironmentStory.storyName = 'Default'

export const EnvironmentFilesStory = ({ background }) => (
<>
<React.Suspense fallback={null}>
<Environment
background={background}
path={`cube/`}
files={[`px.png`, `nx.png`, `py.png`, `ny.png`, `pz.png`, `nz.png`]}
/>
<mesh>
<torusKnotGeometry args={[1, 0.5, 128, 32]} />
<meshStandardMaterial metalness={1} roughness={0} />
</mesh>
</React.Suspense>
<Environment
background={background}
path={`cube/`}
files={[`px.png`, `nx.png`, `py.png`, `ny.png`, `pz.png`, `nz.png`]}
/>
<mesh>
<torusKnotGeometry args={[1, 0.5, 128, 32]} />
<meshStandardMaterial metalness={1} roughness={0} />
</mesh>
<OrbitControls autoRotate />
</>
)
Expand All @@ -77,14 +73,12 @@ EnvironmentFilesStory.storyName = 'Files'

export const EnvironmentGroundStory = ({ preset, height, radius }) => (
<>
<React.Suspense fallback={null}>
<Environment ground={{ height, radius }} preset={preset} />
<mesh position={[0, 5, 0]}>
<boxGeometry args={[10, 10, 10]} />
<meshStandardMaterial metalness={1} roughness={0} />
</mesh>
<ContactShadows resolution={1024} position={[0, 0, 0]} scale={100} blur={2} opacity={1} far={10} />
</React.Suspense>
<Environment ground={{ height, radius }} preset={preset} />
<mesh position={[0, 5, 0]}>
<boxGeometry args={[10, 10, 10]} />
<meshStandardMaterial metalness={1} roughness={0} />
</mesh>
<ContactShadows resolution={1024} position={[0, 0, 0]} scale={100} blur={2} opacity={1} far={10} />
<OrbitControls autoRotate />
<PerspectiveCamera position={[40, 40, 40]} makeDefault />
</>
Expand Down
6 changes: 1 addition & 5 deletions .storybook/stories/GizmoHelper.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -136,11 +136,7 @@ const GizmoHelperStoryImpl = ({
)
}

export const GizmoHelperStory = (props) => (
<React.Suspense fallback={null}>
<GizmoHelperStoryImpl {...props} />
</React.Suspense>
)
export const GizmoHelperStory = (props) => <GizmoHelperStoryImpl {...props} />

GizmoHelperStory.args = args
GizmoHelperStory.argTypes = argTypes
Expand Down
4 changes: 2 additions & 2 deletions .storybook/stories/Image.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ function TextureWrapper({ ...args }) {

export const ImageStory = ({ url, ...args }) => {
return (
<React.Suspense fallback={null}>
<>
<TextureWrapper {...args} />
<Image url={url?.[0] || '/images/living-room-2.jpg'} scale={[6, 4, 1]} position={[0, 0, 0]} {...args} />
</React.Suspense>
</>
)
}

Expand Down
4 changes: 2 additions & 2 deletions .storybook/stories/Svg.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export const SvgSt: FC<SvgStoryProps> = ({ svg, fillWireframe, strokesWireframe,
updateArgs({ src: `${url}/${svg || svgRecord.Tiger}` })
}, [svg])
return (
<Suspense fallback={null}>
<>
<Svg
{...props}
position={[-70, 70, 0]}
Expand All @@ -94,6 +94,6 @@ export const SvgSt: FC<SvgStoryProps> = ({ svg, fillWireframe, strokesWireframe,
strokeMaterial={{ wireframe: strokesWireframe }}
/>
<gridHelper args={[160, 10]} rotation={[MathUtils.DEG2RAD * 90, 0, 0]} />
</Suspense>
</>
)
}

1 comment on commit 5f012aa

@vercel
Copy link

@vercel vercel bot commented on 5f012aa Feb 9, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.