-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
@thunderstore/cyberstorm-nextjs: add stories for NewTabs
Refs TS-1979
- Loading branch information
Showing
1 changed file
with
48 additions
and
0 deletions.
There are no files selected for viewing
48 changes: 48 additions & 0 deletions
48
apps/cyberstorm-storybook/stories/components/NewTabs.stories.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import { StoryFn, Meta } from "@storybook/react"; | ||
import { NewTabs } from "@thunderstore/cyberstorm"; | ||
import { usePromise } from "@thunderstore/use-promise"; | ||
import { Suspense } from "react"; | ||
import { faCog, faFlag, faThumbsUp } from "@fortawesome/pro-solid-svg-icons"; | ||
|
||
const meta = { | ||
title: "Cyberstorm/Components/Tabs", | ||
component: NewTabs, | ||
} as Meta<typeof NewTabs>; | ||
|
||
const promiseLoader = () => | ||
new Promise<void>((resolve) => setTimeout(() => resolve(), 2000)).then( | ||
() => "Content loaded and cached." | ||
); | ||
|
||
const AsyncContent = () => { | ||
const content = usePromise(promiseLoader, []); | ||
return <p>{content}</p>; | ||
}; | ||
|
||
const Template: StoryFn<typeof NewTabs> = () => ( | ||
<NewTabs defaultActive="defaultTab"> | ||
<NewTabs.Tab name="firstTab" label="First" icon={faCog}> | ||
<h1>First tab</h1> | ||
<p>Not the default, though</p> | ||
</NewTabs.Tab> | ||
|
||
<NewTabs.Tab name="defaultTab" label="Second" icon={faThumbsUp}> | ||
<h1>Second tab</h1> | ||
<p>Shown by default when the page loads</p> | ||
</NewTabs.Tab> | ||
|
||
<NewTabs.Tab name="disabled" label="Disabled" icon={faFlag} disabled> | ||
<p>You will never see this</p> | ||
</NewTabs.Tab> | ||
|
||
<NewTabs.Tab name="async" label="Async"> | ||
<Suspense fallback={<p>Loading...</p>}> | ||
<AsyncContent /> | ||
</Suspense> | ||
</NewTabs.Tab> | ||
</NewTabs> | ||
); | ||
|
||
const NewTabsStory = Template.bind({}); | ||
|
||
export { meta as default, NewTabsStory as NewTabs }; |