Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run Scooby against Storybook stories #115

Open
andrico1234 opened this issue Mar 31, 2023 · 1 comment
Open

Run Scooby against Storybook stories #115

andrico1234 opened this issue Mar 31, 2023 · 1 comment

Comments

@andrico1234
Copy link

It would be great to provide a link to a Storybook.

Scooby can then access the Storybook, iterate over all of the stories and store the HTML to then compare as it does normally.

Here's a flow for what this could look like

%% Flowchart
graph TD
A[Run CLI]-->B{Is path a URL?}
B-->|Yes|C{Is Storybook URL}
B-->|No|D[Continue current flow...]
C-->|Yes|E[Access Storybook's iframe.html]
C-->|No|F[Access URL]
E-->G[Get stories data*]
G-->H[Create a list of story URLs to visit**]
H-->I[Access the story URL]
I-->J[Get HTML for Story***]
J-->K[Save HTML to file]
F-->K
K-->D
Loading
    • We can get this via global STORYBOOK_STORY_STORE (or something similar). And then the getStoriesJSONData function

** - URL of the stories equal to the key of the story in the JSON object.

e.g.,

const data = getStoriesJSONData;

// result
{
  "components-button--large": { ... }
}

const url = new URL("iframe.html",  "https://linktostory.com")
url.searchParams.append("id", "components-button--large")
const fullUrl = url.href

*** - We'll need to figure out how to pull out only the markup that we need.

Unknowns

  • How will we handle styles?
  • How can we determine which Storybook markup we need, and which we can discard?
@andrico1234
Copy link
Author

Here's a gist that saves the HTML for a single story:

https://gist.github.com/andrico1234/c19d90ad9377c8d516c97d7d53649fdd

Any thoughts or concerns about this approach? I'll try it out within Scooby and see how it fares

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant