Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

feat: add Storybook starter#2381

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Closed
DustinJSilk wants to merge11 commits intoQwikDev:mainfromDustinJSilk:qwik-storybook

Conversation

DustinJSilk
Copy link
Contributor

@DustinJSilkDustinJSilk commentedDec 6, 2022
edited
Loading

What is it?

  • Feature / enhancement
  • Bug
  • Docs / tests

Description

Adds a new starter script to add Storybook to a project.

Use cases and why

    1. Regular users
    1. Library maintainers

Checklist:

  • My code follows thedeveloper guidelines of this project
  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation
  • Added new tests to cover the fix / functionality

@bolt-new-by-stackblitz
Copy link

Review PR in StackBlitz CodeflowRun & review this pull request inStackBlitz Codeflow.

@DustinJSilk
Copy link
ContributorAuthor

@manucorporat The static storybook build doesn't work with Qwik, so we're unable to deploy preview versions. Is this something you could help with?

@DustinJSilkDustinJSilk changed the titleAdd Storybook starterfeat: add Storybook starterDec 6, 2022
@manucorporat
Copy link
Contributor

yes! i would love to help, are you in discord?

@DustinJSilk
Copy link
ContributorAuthor

Yes! You can find me under DustinJSilk#5412, just sent you a message as well

@DustinJSilk
Copy link
ContributorAuthor

One more issue to note is that the@qwik-city-sw-register module fails to import when adding a QwikCityMockProvider. This is also during a static build.

Failed to resolve module specifier "@qwik-city-sw-register". Relative references must start with either "/", "./", or "../".

Copy link
Contributor

@literalpieliteralpie left a comment

Choose a reason for hiding this comment

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

I'm just a random passerby who likes Storybook and Qwik, so take my comments for what they're worth. It's exciting to see this coming!

Maybe it would be a good idea to merge this with the custom configuration now, and come back with simplifications later if we can get a storybook framework working.

(I'm slightly interested in helping make a sb framework if needed, but I don't want to promise anything because I can't guarantee I'll have time to do it)

@DustinJSilk
Copy link
ContributorAuthor

I did a little more digging around and it seems like this configuration wont work with the next versions of storybook + builder-vite.

@literalpie I've taken your advice and I'll get a PR sent to the Storybook repository ASAP

@DustinJSilk
Copy link
ContributorAuthor

I did a little more digging around and it seems like this configuration wont work with the next versions of storybook + builder-vite.

@literalpie I've taken your advice and I'll get a PR sent to the Storybook repository ASAP

Actually scratch that, it works quite well with the@storybook/html-vite framework. There's some issues to work through with the static build still however

@DustinJSilk
Copy link
ContributorAuthor

Fixed storybook dependencies to7.0.0-beta.8.beta.9+ can't run static builds:storybookjs/storybook#20307.

Final issue remaining is HMR - or finding a way to refresh the iframe when a component updates

@literalpie
Copy link
Contributor

I made astorybook-framework-qwik library and released a0.0.1 version mostly based on the changes here.

I think having a framework package will be beneficial so improvements can be made to the configuration without consumers needing to change anything.

If you continue with this PR as is, I can make a follow-up to utilize the framework package (or you can use it now if you want)

@DustinJSilk
Copy link
ContributorAuthor

@literalpie, yes that would be nice, have you tried sending a PR to storybook to get it merged in and officially supported there?

@literalpie
Copy link
Contributor

@DustinJSilk Based onthis comment, I think they prefer to let framework packages stabilize before they pull them into the monorepo. I'm guessing at a minimum, we should add better documentation, types, and follow the steps in documentation from that PR more closely (I'll try to circle back soon and do that soon)
We can probably contact them before then to let them know about the framework (one of the steps recommended in that guide), but I think I'd prefer to wait until at least refreshing works before advertising this too widely.

@literalpie
Copy link
Contributor

Hi, an update on progress with this: I've made a few new releases of my framework (0.0.3 is the latest right now). It now refreshes stories when code changes are made. Otherwise, it basically behaves the same as the setup in this starter.

I posted in the Storybook Discord, and they pointed me in a direction I can go to try gettingnpx storybook init working with storybook-framework-qwik outside the monorepo. I plan to get that set up in the next few days.

I think my ideal setup would be thatqwik add storybook is basically just an alias fornpx storybook init so we can avoid maintaining the logic in multiple places.

renevall reacted with thumbs up emoji

@DustinJSilk
Copy link
ContributorAuthor

@literalpie I've updated this PR to include your library, well done!
Feel free to suggest any changes

Copy link
Contributor

@literalpieliteralpie left a comment

Choose a reason for hiding this comment

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

Looks good. One possible suggestions


const config: StorybookConfig = {
addons: ['@storybook/addon-essentials'],
stories: ['../src/**/*.stories.mdx', '../src/**/*.stories.@(js|jsx|ts|tsx)'],
Copy link
Contributor

Choose a reason for hiding this comment

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

The storybook cli scaffolds*.mdx for all frameworks (not*.stories.mdx). I'm guessing this is becausestories.mdx is a special pattern that will make the file declare stories rather than just be documentation.
Picking up all mdx files can cause conflicts with Qwik-city mdx though, so havingsome explicit indicator that mdx is for storybook, not qwik city is important (because Qwik-city mdx will only work with Qwik component, and SB mdx will only work with react components).
I think a "storybook" prefix gets the explicit marking, without triggering the special behavior ofstories.mdx.

Suggested change
stories:['../src/**/*.stories.mdx','../src/**/*.stories.@(js|jsx|ts|tsx)'],
stories:['../src/**/*.storybook.mdx','../src/**/*.stories.@(js|jsx|ts|tsx)'],

But, because of some limitations, I'm planning on just doing*.mdx in the storybook CLI qwik integration like other frameworks. I'll need to add documentation to warn about the Qwik-city conflict potential. You could do that if you want to match how the sb cli will eventually work (based on my current guess).

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Usingstories.mdx is therecommended approach to defining stories in mdx files. So this should keep it consistent with what storybook users expect and avoids adding Qwik mdx files as stories. There is of course still the issue of any mdx files in the routes folder being turned into a page but I think thats fine for now as most stories will be on a component level.

What is the special behaviour from a.stories.mdx file that we're trying to avoid by using.storybook.mdx?

Copy link
Contributor

Choose a reason for hiding this comment

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

in astories.mdx file, any story you reference will get added to the navigation. If you already declared the story in astories.tsx file, this will cause duplicates.
with any other pattern, you can reference the stories in the mdx without adding them to the side bar.
I suppose it could go either way, but I defer to the default instorybook CLI

@literalpie
Copy link
Contributor

Qwik support has been added to the storybook CLI. You can now add storybook to a qwik project withnpx storybook@next init. Is there a way to have a starter script in the Qwik CLI just run another script?
You could also update the documentation to link tothe Storybook documentation (maybe at the end of the "usage" section would be a good place). It doesn't have any Qwik-specific content, and it just falls back to React examples, but I'll work on adding that soon.

zanettin and DustinJSilk reacted with hooray emoji

@zanettin
Copy link
Contributor

zanettin commentedJan 24, 2023
edited
Loading

image

great job 🎉 thanks a lot!
just have recognized that no qwik logo is visible on the SB docs page atm.

literalpie reacted with thumbs up emoji

@DustinJSilk
Copy link
ContributorAuthor

Closing this PR since the documentation & configuration exists in the storybook repository and in storybook-framework-qwik.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

1 more reviewer

@literalpieliteralpieliteralpie approved these changes

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

4 participants

@DustinJSilk@manucorporat@literalpie@zanettin

[8]ページ先頭

©2009-2025 Movatter.jp