Working with Storybook

Working with Storybook

I’m a HUGE fan of Storybook. It’s a great way to:

  • Build components in isolation

  • Create living documentation of your code

Up and Running with Storybook

Within your Redwood project, using Storybook is as simple as running a single command:

yarn rw storybook

The first time you run this command, it will take a little longer since Redwood still needs to download Storybook’s dependencies.

Once you’re up and running, you should be able to open Storybook within the browser on port 7910

A Storybook File

Every time you generate a component, cell, layout, or page within Redwood, it will generate (1) a component file, (2) a Storybook file, and (3) a test file.

A Storybook file, is named COMPONENT.stories.tsx (or .jsx if you’re not using TypeScript).

Here’s what the boiler plate code looks like for a component called RsvpStatus

// Pass props to your component by passing an `args` object to your story
//
// ```tsx
// export const Primary: Story = {
//  args: {
//    propName: propValue
//  }
// }
// ```
//
// See <https://storybook.js.org/docs/react/writing-stories/args>.

import type { Meta, StoryObj } from '@storybook/react'

import RsvpStatus from './RsvpStatus'

const meta: Meta<typeof RsvpStatus> = {
  component: RsvpStatus,
}

export default meta

type Story = StoryObj<typeof RsvpStatus>

export const Primary: Story = {}

You can pass in props by adding an args object. For example:

export const Primary: Story = {
  args: {
    count: 0,
    status: 'success',
    heading: 'Attending',
  },
}

You can also create additional “stories” — which are just variations of your component — by exporting out additional constants:

export const Disabled: Story = {
  args: {
    count: 0,
    disabled: true,
    status: 'success',
    heading: 'Attending',
  },
}

export const withClearFilter: Story = {
  args: {
    clearFilter: {
      isShowing: true,
      handleClick: () => {},
    },
    count: 0,
    status: 'success',
    heading: 'Attending',
  },
}

I have a video on YouTube, dedicated to working with Storybook and Redwood.

Advent of JavaScript 2023

Buy nowLearn more

👋 Welcome!

  • START HERE!26

Challenge #1 - Setting up the Database

  • Challenge #12
  • Project Files
  • Solution #1

Challenge #2 - Set up an Authentication System

  • Challenge #2
  • Project Files
  • Solution #2

Challenge #3 - Styling the Login Pages

  • Challenge #3
  • Project Files
  • Solution #42

Challenge #4 - Creating a Group / Event Form

  • Challenge #4
  • Project Files
  • Solution #4

Challenge #5 - Invite Page

  • Challenge #5
  • Project Files2
  • Solution #5

Challenge #6 - Edit the Event

  • Challenge #6
  • Project Files
  • Solution #6

Challenge #7: Send an Email Invite to a Friend

  • Challenge #7
  • Project Files1

Challenge #8 - RSVP Page

  • Challenge #8
  • Project Files

Challenge #9 - View the Wish List

  • Challenge #9
  • Project Files

Challenge #10 - Create Wish List

  • Challenge #10
  • Project Files

Challenge #11 - Update the Wish List

  • Challenge #11
  • Project Files

Challenge #12 - Dashboard Page

  • Challenge #12
  • Project Files

Challenge #13 - Match Names Together

  • Project Files
  • Challenge #13

Challenge #14 - Automatically Trigger Matching

  • Challenge #14
  • Project Files

Challenge #15 - Thank You Page

  • Challenge #151
  • Project Files

Challenge #16 - Create your wishlist

  • Challenge #16
  • Project Files

Challenge #17 - Archive of Previous Events

  • Challenge #17
  • Project Files

Challenge #18 - Role Based Access

  • Challenge #18
  • Project Files

Challenge #19 - Seed the Database

  • Challenge #19
  • Project Files

Challenge #20 - Custom Upload Field

  • Challenge #20
  • Project Files

Challenge #21 - Delete an Invite

  • Challenge #21
  • Project Files

Challenge #22 - Send Event Reminders

  • Challenge #22
  • Project Files

Challenge #23 - Outstanding Pieces

  • Challenge #23
  • Project Files

Challenge #24 - Deploying

  • Challenge #24
  • Project Files2

Appendix

  • Getting Help and Support
  • Working with RedwoodJS
  • Working with Storybook
  • Working with Gitpod
  • Working with Github
  • Want more? Where to go from here?