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

feat: Add Storybook support and Typography #11

Open
wants to merge 27 commits into
base: main
Choose a base branch
from

Conversation

XavierGeerinck
Copy link

Overview

This PR introduces the following:

Storybook Support

Introduction

Storybook is a frontend workshop for building UI components and pages in isolation. Used by large corporations around the world such as Microsoft, Shopify, AirBnB, Monday and many more.

It provides the following advantages:

  • Storybook allows for easy development and testing of individual UI components in isolation, making it easier to catch and fix bugs early in the development process.
  • It provides a central place to store and organize all of the components in a project, making it easy for developers to find and reuse existing components.
  • It provides a way to document and showcase the components in a project, making it easier for designers and other stakeholders to understand and use them.
  • It allows for easy collaboration between developers and designers, as they can both access and test the components in the same environment.
  • It can integrate with other tools like Jest and Enzyme for testing, and Webpack for building and bundling, making it a flexible and powerful tool for development teams.

Why Storybook

Beside the advantages listed before, the reason I am submitting Storybook is because it allows visibility to be improved as well. As an amazing repository, this can be published on the Storybook websites for others to discover and use.

Preview

msedge_wzqvDnUO8q

Typography Abstraction

To adhere to corporate theming, common HTML elements are often override. Since this repository provides a starting point for Typography, I decided to integrate Typography as an abstraction. Users can simply utilize the capitalized elements and add their own classes or stylings as they would do so otherwise.

Example:

import { UL, LI } from "@/components/ui/typography";

<UL className="my-6 ml-6 list-disc [&>li]:mt-2">
    <LI>1st level of puns: 5 gold coins</LI>
    <LI>2nd level of jokes: 10 gold coins</LI>
    <LI>3rd level of one-liners : 20 gold coins</LI>
</UL>

Note

This PR also added a shameless "Thank You" message for contributing back. Open for opinions on this one.

Checklist

  • Updated Documentation

GitHub

Signed-off-by: Xavier Geerinck [email protected]

Signed-off-by: Xavier Geerinck <[email protected]>
@vercel
Copy link

vercel bot commented Jan 25, 2023

Someone is attempting to deploy a commit to a Personal Account owned by @shadcn on Vercel.

@shadcn first needs to authorize it.

@vercel
Copy link

vercel bot commented Jan 27, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
ui ❌ Failed (Inspect) Jul 18, 2023 7:04am
1 Ignored Deployment
Name Status Preview Comments Updated (UTC)
next-template ⬜️ Ignored (Inspect) Visit Preview Jul 18, 2023 7:04am

@XavierGeerinck
Copy link
Author

@shadcn anything that should change for this to get approved?

@shadcn
Copy link
Collaborator

shadcn commented Feb 3, 2023

@XavierGeerinck I'll check it out.

I've only used Storybook on one or two projects so wondering how much maintenance work this is going to require moving forward.

@XavierGeerinck
Copy link
Author

XavierGeerinck commented Feb 3, 2023

Perfect! Looking forward to it :)

Regarding to the maintenance, I think it in the end is always going to be minimal seeing that it just requires a story file to be included for the different components which is the documentation of the component itself.

Personally, I would even argue that Storybook could become main for this project as its community adopted in the way how large organization manage and document their components. The documentation must be created anyways, and storybook standardized that (and offers test suites in more advanced functionality as well)

As an example, including the Microsoft: https://master--628d031b55e942004ac95df1.chromatic.com/ and Shopify: https://main--5d559397bae39100201eedc1.chromatic.com/ components

@pedroapfilho
Copy link
Contributor

It would be cool to add the addon: @storybook/addon-a11y

@its-monotype
Copy link
Contributor

Maybe https:/tajo/ladle instead?

@pedroapfilho
Copy link
Contributor

To be honest, I didn't understand why you offered ladle, but then I saw that a11y has the name Testing on their description, but I only use it to see if the components are accessible or not, like this:

https:/storybookjs/storybook/blob/main/addons/a11y/docs/screenshot.png

@shadcn
Copy link
Collaborator

shadcn commented Feb 15, 2023

Hi everyone. Thanks for your work on this.

This is looking good. I'm open to merging it.

However we might need help with maintenance going forward.

Anyone here willing to help (from time to time) on Storybook-related issues?

@pedroapfilho
Copy link
Contributor

I can help with it, as I want to also update the version of storybook here, and I have to maintain it on other codebases too

@svict4
Copy link

svict4 commented Mar 23, 2023

Ah cool I'm glad I stopped and checked, as I was in the middle of generating these myself. Would love to get this merged 🙏 Upkeep should be fairly minimal

@JiajiaHuang
Copy link

I hope it can be merged as soon as possible, looking forward to it.

@jlorezz
Copy link

jlorezz commented Apr 14, 2023

Hi everyone. Thanks for your work on this.

This is looking good. I'm open to merging it.

However we might need help with maintenance going forward.

Anyone here willing to help (from time to time) on Storybook-related issues?

I would be open to helping with storybook as well. I used it in a couple of projects. Really great choice of adding this.

@@ -70,11 +93,13 @@
"remark-code-import": "^1.1.1",
"remark-gfm": "^3.0.1",
"shiki": "^0.12.1",
"tailwindcss": "^3.1.7",
"typescript": "^4.5.3",
"storybook": "^7.0.0-beta.33",
Copy link

@jlorezz jlorezz Apr 14, 2023

Choose a reason for hiding this comment

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

Suggested change
"storybook": "^7.0.0-beta.33",
"storybook": "^7.0.4",

storybook v.7 is now out of beta. https://storybook.js.org/blog/storybook-7-0/

@DarlonHenrique
Copy link

i would love this merge, im trying to do this integration between storybook and shadcn from scratch right now, please @shadcn 🙏

@JSON-FS
Copy link

JSON-FS commented Jun 13, 2023

I also approve of the Storybook support. However, the code in this PR is now deprecated. Storybook has deprecated defining stories in MDX files

@MildTomato
Copy link

Just wanted to say I came here hoping to use these for our own storybook.
Think it's a good idea to provide stories somehow. makes component development easier to pick up for us.

@winkerVSbecks
Copy link

Hi everyone. Thanks for your work on this.

This is looking good. I'm open to merging it.

However we might need help with maintenance going forward.

Anyone here willing to help (from time to time) on Storybook-related issues?

@shadcn 👋🏽 I'm part of the Storybook DX team. Happy to help out with any Storybook related issues.

@winkerVSbecks
Copy link

@XavierGeerinck if you're okay, I'm happy to upgrade to 7.0, convert stories into tsx and enable autodocs

@johnbchron
Copy link

@lloydrichards is there an easy way to utilize the storybook content for a project before it gets fully merged/integrated?

@lloydrichards
Copy link

lloydrichards commented Jul 16, 2023

@lloydrichards is there an easy way to utilize the storybook content for a project before it gets fully merged/integrated?

I think the easiest way would be to just copy and paste the stories you need from the Files Change in the PR here and change the import {} from "@/registry/default/ui/..." to wherever you have your components. If you want to download them all at once, then it might be faster to fork the repo and just open the PR#11 branch 👍

feat(storybook): ✨ added storybook files to registry and CLI
import type { StorybookConfig } from "@storybook/nextjs"

const config: StorybookConfig = {
stories: ["../stories/**/*.mdx", "../stories/**/*.stories.@(js|jsx|ts|tsx)"],
Copy link

Choose a reason for hiding this comment

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

Suggested change
stories: ["../stories/**/*.mdx", "../stories/**/*.stories.@(js|jsx|ts|tsx)"],
stories: ["../stories/**/*.mdx", "../stories/**/*.stories.@(js|jsx|ts|tsx)", "../registry/stories/**/*.stories.@(js|jsx|ts|tsx)"],

I had to add this to get the components to show up in the storybook.

@leah-potato
Copy link

Another +1 from me. Storybook would allow me to programmatically sync our design system to Figma.

@ShaunEvening
Copy link

Hey friends 👋 @XavierGeerinck @shadcn

Just your friendly neighbourhood Storybook maintainer here looking to see if there's anything I can do to lend a hand on this effort 🧑‍🔧

@pedroapfilho
Copy link
Contributor

@integrayshaun I'm pretty sure, at this point, that you can fork this branch and create a PR for main.

@lloydrichards
Copy link

I would love some more movement on this or just remake it and hope it gets noticed again... i guess being #11 out of 1379 PR's has some visibility issues.

I've also created several more stories for the missing components in other projects recently so if things start moving then i can add those to this or the new PR ❤️

@ShaunEvening
Copy link

@pedroapfilho @lloydrichards

I'm more than happy to put together a new up-to-date PR based on the great work done here but I don't want to go over @XavierGeerinck if they still want to finish this PR up :)

@csartor
Copy link

csartor commented Sep 8, 2023

Just wanted to note that I'm very, VERY much looking forward to this, as we are integrating this with a modern workflow for the updated version of our product.

  • react/next
  • shadcn
  • tailwind UI
  • figma -> tokens studio -> supernova (DSM/token exporters)
  • storybook integration as source of truth for components (which also integrates with supernova/figma)

Only one piece of the puzzle missing... Can't wait!

@alemesa
Copy link

alemesa commented Sep 12, 2023

👍 looking forward to this too, my case is similar to @csartor

  • nx monorepo with multiple react/next repos
  • zustand
  • figma design system + supernova
  • global components using tailwind + shadcn-ui + storybook

@Jared-Dahlke
Copy link

i too will find great joy if i can opt in to auto-creating stories with the cli

@lloydrichards
Copy link

I've forked this PR and removed the typography component to try and better scope the PR and get shadcn's attention and momentum into seeing whats needed to get this implemented. I'll try play a more active role in maintaining and adding any additional commits from others 🤞

@csartor
Copy link

csartor commented Sep 20, 2023

I've forked this PR and removed the typography component to try and better scope the PR and get shadcn's attention and momentum into seeing whats needed to get this implemented. I'll try play a more active role in maintaining and adding any additional commits from others 🤞

You rock!!

@d-ivashchuk
Copy link

d-ivashchuk commented Oct 19, 2023

I have been using shadcn-ui quite intensively lately and just wanted to offer free lost-pixel.com visual regression testing runs on our platform if this gets merged. So, answering the question about maintenance, I would be happy to help with the maintenance of storybook issues & and visual regression tests(that would come for free with the storybook) maintenance as well.

Excited about this PR 🙌🏼

subtitle="Default background color of <body />...etc"
colors={{
background: "hsl(var(--background))",
oreground: "hsl(var(--foreground))",
Copy link

Choose a reason for hiding this comment

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

Small mistake

Choose a reason for hiding this comment

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

Thanks, I updated this in the color.stories.mdx for the #1561 👍

@aleczratiu
Copy link

Any updates here if this will be merged soon?

@lloydrichards
Copy link

Any updates here if this will be merged soon?

The forked version of this (#1561) has been added to the roadmap under the next milestone so Im hoping to hear an update soon 🥳

subtitle="Default background color of <body />...etc"
colors={{
background: "hsl(var(--background))",
oreground: "hsl(var(--foreground))",
Copy link

Choose a reason for hiding this comment

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

You have a typo here.

Copy link

@lloydrichards lloydrichards Nov 30, 2023

Choose a reason for hiding this comment

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

Thanks, I updated this in the color.stories.mdx for the #1561 👍

🙏

@zeahoo
Copy link

zeahoo commented Dec 5, 2023

Hello there, Is there any plan to merge this cool feature?

@0xRapid
Copy link

0xRapid commented Dec 30, 2023

Will this be merged anytime soon? :)

@ShaunEvening
Copy link

@0xRapid the work is now actively happening on #1561.

@shadcn maybe we should close this in favour of the other PR

@sudarshan-mane
Copy link

Any update on this?

@ruymon
Copy link

ruymon commented Mar 6, 2024

Any update on this?

Hey, @sudarshan-mane
It was moved over to #1561

@sohamnandi77
Copy link

@XavierGeerinck Storybook controls are not being auto generated in this PR, can you please look into it ?

@simon-v-swyftx
Copy link

@sohamnandi77 look at #1561 instead

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: www enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.