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

Support for Astro components #18356

Open
mgielda opened this issue May 30, 2022 · 40 comments
Open

Support for Astro components #18356

mgielda opened this issue May 30, 2022 · 40 comments

Comments

@mgielda
Copy link

mgielda commented May 30, 2022

Is your feature request related to a problem? Please describe
Astro is a new framework focusing on mostly static sites. It has its own template syntax, very much like jsx.

Describe the solution you'd like
Add ability to include .astro components in your Storybook.

Are you able to assist to bring the feature to reality?
I don't believe I will have the bandwidth / ability to do that - but flagging since I assume more people may be interested.

Additional context
https://astro.build

@mgielda mgielda changed the title Support Astro Support for Astro components May 30, 2022
@PeteJStewart
Copy link

I'd also love to see this! Would it be down to Storybook core team to develop this, or the Astro team / community?

@DD10654
Copy link

DD10654 commented Sep 5, 2022

I was just trying out Astro, and I just realized that it does not have support for storybook, which is something I use in next.js, although I think for react components inside astro (using @astro/react) it could work

@dankonobre
Copy link

It would be awesome to use storybook with astro pages.

@germanz
Copy link

germanz commented Oct 14, 2022

I wonder whether v7.0 being on Vite makes it easier to integrate Astro components 🤔

@dubem-design
Copy link

dubem-design commented Oct 21, 2022

I have not had any serious issues yet using Storybook with Astrojs. My observations thou

  1. Install storybook using vite as a builder: npx sb init --builder @storybook/builder-vite (It will depect your framework - Vue 3)
  2. Install tailwindcss Seperately: yarn add tailwindcss & postcss
  3. Add this plugin: @storybook/addon-postcss
  4. Include it into: /.storybook/main.js under addons
  5. Import your styles into /.storybook/preview.js
  6. Import Astro vue components from your /src/components folder to make stories
  7. Use this: mv ./dist/design-system/assets/* ./dist/assets/ if you have trouble seeing the contents of the iframe

That's all

@markpinero
Copy link

I have not had any serious issues yet using Storybook with Astrojs. My observations thou

  1. Install storybook using vite as a builder: npx sb init --builder @storybook/builder-vite (It will depect your framework - Vue 3)
  2. Install tailwindcss Seperately: yarn add tailwindcss & postcss
  3. Add this plugin: @storybook/addon-postcss
  4. Include it into: /.storybook/main.js under addons
  5. Import your styles into /.storybook/preview.js
  6. Import Astro vue components from your /src/components folder to make stories
  7. Use this: mv ./dist/design-system/assets/* ./dist/assets/ if you have trouble seeing the contents of the iframe

That's all

This ticket's in reference to rendering .astro components

@dubem-design
Copy link

Oh, understood. Support for .astro components would be great

@wireless25
Copy link

Is there anything happening soon regarding this topic? Somebody knows, if this is discussed among Storybook/Astro Teams?

@prodkt
Copy link

prodkt commented Feb 26, 2023

This is one of those open tickets I've checked back in on 20 time or so. Excessively you might say. It's safe to say Astro isn't going to be tossed from our bag of tools anytime soon. In fact it's quickly become the favorite faster than I've personally ever seen. Therefore I'm leaving sentiment finally with a +1 to this.

@sam-moreton
Copy link

I need this so badly!

@egriff38
Copy link

Astro uses vite and vite-node together to monitor SSR changes. Storybook works by bootstrapping the UI rendering on top of the existing storybook platform so that it can render the stories in iframes. I get the feeling that trying to bootstrap everything Astro does on top of storybook isn't a simple task, especially for a framework that's still finding its footing.

What may be possible is to leverage the UI of Storybook and bootstrap story creation through Astro itself. I actually think it would be very nice if Storybook switched its underlying rendering to Astro across the board, since Astro is already setting itself up to be the defacto framework for island architecture, which complements storybook's test-in-isolation philosophy very nicely.

@michael-andreuzza
Copy link

+1

@JReinhold JReinhold self-assigned this Mar 5, 2023
@JReinhold
Copy link
Contributor

We're collaborating closely with the Astro team on this, but it's not an easy feat. The main obstacle right now is that Astro doesn't expose a programatic way to render an Astro component, the only way to render a .astro file right now is through the Astro CLI in an Astro application.

But I know the Astro team is currently hard at work on this exact issue. It remains to be seen whether or not the first iteration of it will be compatible with Storybook's current way of rendering components - mainly that we always do client-side rendering - but it's at least a step in the right direction.

@shilman shilman added the astro label Mar 6, 2023
@raremiroir
Copy link

Also in deep need of this integration! +1

@peter-rosal-the-bean-counter

Eagerly anticipating this arrival

@chasm
Copy link

chasm commented May 24, 2023

Yes, please.

@tysonhummel
Copy link

Also waiting for this.

@ziriuz84
Copy link

It will be awesome!

@cashewna
Copy link

Yes please!

@Natetronn
Copy link

This would be awesome! Following...

@chanwoong528
Copy link

Hoping to be integrated with AstroJS.

@isaquedev
Copy link

Still hoping that integration can happen in the future

@gtabuada
Copy link

I would love to have this integration. Astro is currently most used web tooling, and is unlikely to go away soon.

@james2doyle
Copy link

There is an issue on the Astro repo to track the feature in Astro that would enable support for systems like Storybook.

Basically you can't just render an Astro component on its own right now. You need the entire context of the Astro system. This API would allow you to do that outside the context of an Astro "app".

@shilman
Copy link
Member

shilman commented Sep 15, 2023

It's definitely on our radar. We'll reach out the Astro team to try and expedite withastro/roadmap#533 once we've committed to supporting it on the Storybook side!

@westtrade
Copy link

Still waiting!)

@silveltman
Copy link

+1

1 similar comment
@MaximSavin
Copy link

+1

@flavianh
Copy link

flavianh commented Mar 7, 2024

@shilman how can we contribute to help?

@rxlxnd
Copy link

rxlxnd commented Mar 15, 2024

+1 hope this can be worked out

@Ayfri
Copy link

Ayfri commented Mar 22, 2024

Any update ?

@xkeshav
Copy link

xkeshav commented May 10, 2024

this is great. is someone woking on it?
aal the way search storybook and it takes us to storyblok :D

@rburgst
Copy link

rburgst commented May 16, 2024

I have an astro project with preact components. I am linking in my preact components into storybook, however, the image loading within astro is different from storybook (in astro importing an svg icon produces an object with width, height, src while in storybook I just get a string with the value that is in the src in astro).

@marekbrze
Copy link

Astro finally released a way to render components in isolation ❤️🚀 hopefully it will enable moving this Storybook feature ❤️🙌

https://github.com/withastro/astro/releases/tag/astro%404.9.0

@abiriadev
Copy link
Contributor

abiriadev commented May 26, 2024

It's still in the early stages, and as far as I know, they don't support props yet (though I might be wrong).

@marekbrze
Copy link

marekbrze commented May 26, 2024

@abiriadev yup, but I am super happy that something finally started to happen in this area 🙌

@abiriadev
Copy link
Contributor

@marekbrze Of course, I'm excited about this update too! However, it isn't as straightforward as it seems.

I did an experiment(repo) and realized that Storybook can't render Astro components on the client(you would probably see a "externalized for browser" warning from vite).

Perhaps the ideal renderer should use techniques similar to RSC support?

@Gold240sx
Copy link

Following

1 similar comment
@AguacateContreras
Copy link

Following

@marekbrze
Copy link

marekbrze commented Sep 24, 2024

I found this fresh project that can be useful until Storybook supports Astro components:

https://github.com/ocavue/astrobook

Edit: the downside is that it needs to be a separate instance than the Astro project, but hopefully it will change in the future

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

No branches or pull requests