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
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
c9231b6
Storybook support
XavierGeerinck Jan 25, 2023
0dbdb2d
Merge branch 'main' into main
XavierGeerinck Feb 3, 2023
3b57205
Merge branch 'main' into main
XavierGeerinck Feb 7, 2023
0d7f2e8
Merge branch 'main' into pr/11
lloydrichards Jul 10, 2023
6a3b815
build(storybook): :arrow_up: upgrade Storybook to v7.0.26
lloydrichards Jul 10, 2023
e7dbc99
refactor(storybook): :recycle: move stories out of /registry
lloydrichards Jul 10, 2023
45ffb77
refactor(storybook): :arrow_up: change to @storybook/nextjs
lloydrichards Jul 10, 2023
571aadd
fix(storybook): :bug: fix single story in mdx
lloydrichards Jul 10, 2023
ece54dd
Merge pull request #1 from lloydrichards/feat/storybook
XavierGeerinck Jul 10, 2023
5131221
fix(storybook): :bug: get tailwind and nextjs working with storybook
lloydrichards Jul 11, 2023
5921875
refactor(storybook): :recycle: changed stories from MDX to CSF3
lloydrichards Jul 11, 2023
a24215c
ci: :green_heart: format prettier
lloydrichards Jul 11, 2023
84c0a9e
ci: :green_heart: lock unist-builder to v3.0.0
lloydrichards Jul 11, 2023
9f5d957
Merge pull request #2 from lloydrichards/refactor/storybook_with_CSF3
XavierGeerinck Jul 12, 2023
1c13f67
chore: :recycle: nit fixes for dependancies and comments
lloydrichards Jul 13, 2023
25460a0
revert(docs): :rewind: restore ReadMe
lloydrichards Jul 13, 2023
4f7ccde
feat(ui): :sparkles: added typography for NewYork style
lloydrichards Jul 13, 2023
bbb8e95
fix(storybook): :bug: globally set font variable
lloydrichards Jul 13, 2023
efd499a
build: :arrow_up: upgrade storybook to v7.0.27
lloydrichards Jul 13, 2023
ff06d1a
ci: :green_heart: formatted preview.tsx
lloydrichards Jul 13, 2023
a13d5ab
Merge pull request #3 from lloydrichards/fix/nits
XavierGeerinck Jul 14, 2023
26b29c2
docs: :memo: fix readme to same as main
lloydrichards Jul 15, 2023
6f14b89
feat(storybook): :sparkles: add color story
lloydrichards Jul 15, 2023
218d6e4
feat(storybook): :sparkles: added storybook files to registry and CLI
lloydrichards Jul 16, 2023
658ae41
fix: :white_check_mark: fix get-config.test.ts
lloydrichards Jul 16, 2023
3917370
Merge pull request #5 from lloydrichards/feat/storybook-cli
XavierGeerinck Jul 18, 2023
94ee191
Merge pull request #4 from lloydrichards/doc/fix_docs
XavierGeerinck Jul 18, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,21 @@ Beautifully designed components built with Radix UI and Tailwind CSS.
- [x] ~Navigation Menu~
- [x] ~Figma~

## Get Started
## Storybook

Storybook is supported so that you can easily select the correct component and view its properties

![Storybook Preview](apps/www/public/demo/storybook.png)

To open Storybook, run the following:

```bash
cd apps/www
npm i
npm run storybook
```

Choose a reason for hiding this comment

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

Since the Shadcn/ui v0.2.3 the Readme is a lot more minimalistic. Might be better to move these instruction from the Readme.md and instead into the actual app/www 🤷

## Use in your own project

Starting a new project? Check out the Next.js template.

Expand All @@ -32,6 +46,7 @@ npx create-next-app -e https://github.com/shadcn/next-template
- Icons from [Lucide](https://lucide.dev)
- Dark mode with `next-themes`
- Automatic import sorting with `@ianvs/prettier-plugin-sort-imports`
- Storybook support (Thanks [@XavierGeerinck](https://twitter.com/XavierGeerinck))

### Tailwind CSS Features

Expand Down
Binary file added apps/www/.storybook/fonts/Inter.ttf
Binary file not shown.
45 changes: 45 additions & 0 deletions apps/www/.storybook/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
const path = require("path")
const { mergeConfig } = require("vite")
module.exports = {
features: {
storyStoreV7: true,
},
stories: ["../components/**/*.stories.@(js|jsx|ts|tsx|mdx)"],
addons: [
"@storybook/addon-links",
"@storybook/addon-essentials",
"@storybook/addon-interactions",
/**
* Enable TailwindCSS JIT mode
* NOTE: fix Storybook issue with PostCSS@8
* @see https://github.com/storybookjs/storybook/issues/12668#issuecomment-773958085
*/
{
name: "@storybook/addon-postcss",

Choose a reason for hiding this comment

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

Hey there! 👋

My name is Shaun, a Storybook maintainer and super stoked to see this PR <3

I just have a few notes that will hopefully make this a little easier :D

@storybook/addon-postcss is meant for webpack builders only and since you're using the @storybook/react-vite framework below, this has no affect.

options: {
// Note: Settings are picked up from postcss.config.cjs
postcssLoaderOptions: {
implementation: require("postcss"),
},
},
},
Copy link

@lloydrichards lloydrichards Jul 3, 2023

Choose a reason for hiding this comment

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

Suggested change
{
name: "@storybook/addon-postcss",
options: {
// Note: Settings are picked up from postcss.config.cjs
postcssLoaderOptions: {
implementation: require("postcss"),
},
},
},
{
name: "@storybook/addon-styling",
options: {
postCss: true,
},
},

In my current projects with Tailwind and Storybook with NextJS, i'm using the @storybook/addon-styling plugin to get postcss working. Maybe @integrayshaun has another suggestion, but i know this works (also need to add the global styles to .storybook/preview.tsx)

Choose a reason for hiding this comment

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

Hey @lloydrichards 👋

In this case, since they’re using the vite builder, no options are needed to make this all work out of the box :)

It can still be used for theme switching purposes though 💪

],

framework: {
name: "@storybook/react-vite",
options: {},
},
viteFinal: async (config, { configType }) => {
return mergeConfig(config, {
resolve: {
alias: {
"@": path.resolve(__dirname, "../"),
"next/image": path.resolve(__dirname, "./stubs/NextImage.tsx"),
},
},
})
},
docs: {
autodocs: true,
},
}
14 changes: 14 additions & 0 deletions apps/www/.storybook/preview-head.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<script>
window.global = window;
</script>

<style>
@font-face {
font-family: 'Inter';
src: url('./.storybook/fonts/Inter.ttf') format('truetype');
}

* {
font-family: "Inter", sans-serif !important;
}
</style>
13 changes: 13 additions & 0 deletions apps/www/.storybook/preview.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// import "tailwindcss/tailwind.css";
import "../styles/mdx.css"
import "../styles/globals.css"

export const parameters = {
actions: { argTypesRegex: "^on[A-Z].*" },
controls: {
matchers: {
color: /(background|color)$/i,
date: /Date$/,
},
},
}
5 changes: 5 additions & 0 deletions apps/www/.storybook/stubs/NextImage.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import React from "react";
// import Image from "next/image";
// const NextImage = (props) => <Image unoptimized {...props} />;
const NextImage = (props) => <img {...props} />;
export default NextImage;
34 changes: 34 additions & 0 deletions apps/www/components/ui/accordion.stories.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { Meta, Story } from "@storybook/addon-docs";

import {
Accordion,
AccordionContent,
AccordionItem,
AccordionTrigger,
} from "@/components/ui/accordion";

<Meta title="Accordion" component={Accordion} />

# Accordion

<Accordion type="single" collapsible>
<AccordionItem value="item-1">
<AccordionTrigger>Is it accessible?</AccordionTrigger>
<AccordionContent>
Yes. It adheres to the WAI-ARIA design pattern.
</AccordionContent>
</AccordionItem>
<AccordionItem value="item-2">
<AccordionTrigger>Is it styled?</AccordionTrigger>
<AccordionContent>
Yes. It comes with default styles that matches the other components'
aesthetic.
</AccordionContent>
</AccordionItem>
<AccordionItem value="item-3">
<AccordionTrigger>Is it animated?</AccordionTrigger>
<AccordionContent>
Yes. It's animated by default, but you can disable it if you prefer.
</AccordionContent>
</AccordionItem>
</Accordion>
38 changes: 38 additions & 0 deletions apps/www/components/ui/alert-dialog.stories.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { Meta, Story } from "@storybook/addon-docs";

import {
AlertDialog,
AlertDialogAction,
AlertDialogCancel,
AlertDialogContent,
AlertDialogDescription,
AlertDialogFooter,
AlertDialogHeader,
AlertDialogTitle,
AlertDialogTrigger,
} from "@/components/ui/alert-dialog";

import { Button } from "@/components/ui/button";

<Meta title="Alert Dialog" component={AlertDialog} />

# Alert Dialog

<AlertDialog>
<AlertDialogTrigger asChild>
<Button variant="outline">Open</Button>
</AlertDialogTrigger>
<AlertDialogContent>
<AlertDialogHeader>
<AlertDialogTitle>Are you sure absolutely sure?</AlertDialogTitle>
<AlertDialogDescription>
This action cannot be undone. This will permanently delete your account
and remove your data from our servers.
</AlertDialogDescription>
</AlertDialogHeader>
<AlertDialogFooter>
<AlertDialogCancel>Cancel</AlertDialogCancel>
<AlertDialogAction>Continue</AlertDialogAction>
</AlertDialogFooter>
</AlertDialogContent>
</AlertDialog>
18 changes: 18 additions & 0 deletions apps/www/components/ui/aspect-ratio.stories.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { Meta, Story } from "@storybook/addon-docs";

import Image from "next/image";

import { AspectRatio } from "@/components/ui/aspect-ratio";

<Meta title="Aspect Ratio" component={AspectRatio} />

# Aspect Ratio

<AspectRatio ratio={16 / 9} className="bg-slate-50 dark:bg-slate-800">
<Image
src="https://images.unsplash.com/photo-1576075796033-848c2a5f3696?w=800&dpr=2&q=80"
alt="Photo by Alvaro Pinot"
fill
className="rounded-md object-cover"
/>
</AspectRatio>
12 changes: 12 additions & 0 deletions apps/www/components/ui/avatar.stories.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { Meta, Story } from "@storybook/addon-docs";

import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar";

<Meta title="Avatar" component={Avatar} />

# Avatar

<Avatar>
<AvatarImage src="https://github.com/shadcn.png" />
<AvatarFallback>CN</AvatarFallback>
</Avatar>
41 changes: 41 additions & 0 deletions apps/www/components/ui/button.stories.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { Meta, Story } from "@storybook/addon-docs";

import { Button } from "@/components/ui/button";
import { Mail, Loader2 } from "lucide-react";

<Meta title="Button" component={Button} />

# Button

<Story name="Default">
<Button>Button</Button>
</Story>

<Story name="Outline">
<Button variant="outline">Outline</Button>
</Story>

<Story name="Subtle">
<Button variant="subtle">Subtle</Button>
</Story>

<Story name="Ghost">
<Button variant="ghost">Ghost</Button>
</Story>

<Story name="Link">
<Button variant="link">Link</Button>
</Story>

<Story name="With Icon">
<Button>
<Mail className="mr-2 h-4 w-4" /> Login with Email
</Button>
</Story>

<Story name="Loading">
<Button disabled>
<Loader2 className="mr-2 h-4 w-4 animate-spin" />
Please wait
</Button>
</Story>
36 changes: 36 additions & 0 deletions apps/www/components/ui/checkbox.stories.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { Meta, Story } from "@storybook/addon-docs";

import { Checkbox } from "@/components/ui/checkbox";

<Meta title="Checkbox" component={Checkbox} />

# Checkbox

<Story name="With text">
<div className="items-top flex space-x-2">
<Checkbox id="terms1" />
<div className="grid gap-1.5 leading-none">
<label
htmlFor="terms1"
className="text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"
>
Accept terms and conditions
</label>
<p className="text-sm text-slate-500 dark:text-slate-400">
You agree to our Terms of Service and Privacy Policy.
</p>
</div>
</div>
</Story>

<Story name="Disabled">
<div className="flex items-center space-x-2">
<Checkbox id="terms2" disabled />
<label
htmlFor="terms2"
className="text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"
>
Accept terms and conditions
</label>
</div>
</Story>
75 changes: 75 additions & 0 deletions apps/www/components/ui/collapsible.stories.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
import { Meta, Story } from "@storybook/addon-docs"
import { ChevronsUpDown, Plus, X } from "lucide-react"

import { Button } from "@/components/ui/button"
import {
Collapsible,
CollapsibleContent,
CollapsibleTrigger,
} from "@/components/ui/collapsible"

<Meta title="Collapsible" component={Collapsible} />

# Collapsible

<Story name="Closed">
<Collapsible
open={false}
onOpenChange={() => {}}
className="w-[350px] space-y-2"
>
<div className="flex items-center justify-between space-x-4 px-4">
<h4 className="text-sm font-semibold">
@peduarte starred 3 repositories
</h4>
<CollapsibleTrigger asChild>
<Button variant="ghost" size="sm" className="w-9 p-0">
<ChevronsUpDown className="h-4 w-4" />
<span className="sr-only">Toggle</span>
</Button>
</CollapsibleTrigger>
</div>
<div className="rounded-md border border-slate-200 px-4 py-3 font-mono text-sm dark:border-slate-700">
@radix-ui/primitives
</div>
<CollapsibleContent className="space-y-2">
<div className="rounded-md border border-slate-200 px-4 py-3 font-mono text-sm dark:border-slate-700">
@radix-ui/colors
</div>
<div className="rounded-md border border-slate-200 px-4 py-3 font-mono text-sm dark:border-slate-700">
@stitches/react
</div>
</CollapsibleContent>
</Collapsible>
</Story>

<Story name="Opened">
<Collapsible
open={true}
onOpenChange={() => {}}
className="w-[350px] space-y-2"
>
<div className="flex items-center justify-between space-x-4 px-4">
<h4 className="text-sm font-semibold">
@peduarte starred 3 repositories
</h4>
<CollapsibleTrigger asChild>
<Button variant="ghost" size="sm" className="w-9 p-0">
<ChevronsUpDown className="h-4 w-4" />
<span className="sr-only">Toggle</span>
</Button>
</CollapsibleTrigger>
</div>
<div className="rounded-md border border-slate-200 px-4 py-3 font-mono text-sm dark:border-slate-700">
@radix-ui/primitives
</div>
<CollapsibleContent className="space-y-2">
<div className="rounded-md border border-slate-200 px-4 py-3 font-mono text-sm dark:border-slate-700">
@radix-ui/colors
</div>
<div className="rounded-md border border-slate-200 px-4 py-3 font-mono text-sm dark:border-slate-700">
@stitches/react
</div>
</CollapsibleContent>
</Collapsible>
</Story>
Loading