-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Setup Storybook for player application
I thrown away global-per-story approach, as it comes with delay between the story loads and globals (styles) are applied. Even it's subtle and will be diminished on subsequential accesses due to cache, this is not acceptable. By separating Storybook, CI time will be faster and no hack for Storybook's sandbox limitation.
- Loading branch information
Showing
7 changed files
with
122 additions
and
18 deletions.
There are no files selected for viewing
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
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,21 @@ | ||
// SPDX-FileCopyrightText: 2024 Shota FUJI <pockawoooh@gmail.com> | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
import type { StorybookConfig } from "@storybook/html-vite"; | ||
|
||
export default { | ||
framework: "@storybook/html-vite", | ||
stories: ["../../src/builder/**/*.stories.ts"], | ||
addons: ["@storybook/addon-essentials", "@storybook/addon-interactions"], | ||
core: { | ||
builder: { | ||
name: "@storybook/builder-vite", | ||
options: { | ||
viteConfigPath: new URL("../../vite.config.js", import.meta.url).pathname, | ||
}, | ||
}, | ||
disableTelemetry: true, | ||
disableWhatsNewNotifications: true, | ||
}, | ||
} satisfies StorybookConfig; |
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
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
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,7 @@ | ||
// SPDX-FileCopyrightText: 2024 Shota FUJI <pockawoooh@gmail.com> | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
import "../../src/inline.css"; | ||
import "../../src/vars.css"; | ||
import "../../src/custom_elements"; |
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
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,40 @@ | ||
// SPDX-FileCopyrightText: 2024 Shota FUJI <pockawoooh@gmail.com> | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
import { type Meta, type StoryObj } from "@storybook/html"; | ||
import { expect, userEvent, waitFor } from "@storybook/test"; | ||
|
||
export default { | ||
render() { | ||
const container = document.createElement("div"); | ||
container.style.display = "flex"; | ||
container.style.flexDirection = "column"; | ||
container.style.gap = "8px"; | ||
|
||
const output = document.createElement("output"); | ||
|
||
const button = document.createElement("button"); | ||
button.textContent = "Button"; | ||
button.type = "button"; | ||
button.addEventListener("click", () => { | ||
output.value = "Clicked"; | ||
}); | ||
|
||
container.appendChild(button); | ||
container.appendChild(output); | ||
|
||
return container; | ||
}, | ||
} satisfies Meta; | ||
|
||
type Story = StoryObj; | ||
|
||
export const Static = {} satisfies Story; | ||
|
||
export const Test = { | ||
async play({ canvas }) { | ||
await userEvent.click(canvas.getByRole("button")); | ||
await waitFor(() => expect(canvas.getByRole("status")).toHaveValue("Clicked")); | ||
}, | ||
} satisfies Story; |