brackeys.community

Brackeys UI Components - Storybook

This project uses Storybook to document and showcase our React UI components. Storybook provides an isolated environment for developing components and a comprehensive documentation site.

🚀 Quick Start

Development

# Install dependencies
bun install

# Start Storybook development server
bun run storybook

Visit http://localhost:6006 to view Storybook locally.

Building

# Build static Storybook for production
bun run build-storybook

📚 What’s Included

Our Storybook includes comprehensive documentation and examples for:

🎨 Features

🚀 GitHub Pages Deployment

Automatic Deployment

Storybook is automatically deployed to GitHub Pages when code is pushed to the main branch via GitHub Actions.

Live Storybook: https://brackeyscommunity.github.io/brackeys.community/

Manual Deployment

You can also trigger deployment manually:

  1. Go to Actions tab in your GitHub repository
  2. Select “Deploy Storybook to GitHub Pages” workflow
  3. Click “Run workflow” button
  4. Select main branch and click “Run workflow”

Setup Requirements

1. GitHub Repository Settings

Navigate to your repository settings:

  1. Go to SettingsPages
  2. Under Source, select “GitHub Actions”
  3. Save the settings

2. Repository Permissions

The workflow requires these permissions (already configured):

To ensure only tested code gets deployed:

  1. Go to SettingsBranches
  2. Add rule for main branch
  3. Enable “Require status checks to pass before merging”
  4. Select the Storybook build check

🎨 Chromatic Visual Testing

What is Chromatic?

Chromatic is a visual testing tool that captures snapshots of your Storybook components and detects visual changes. It’s integrated with our CI/CD pipeline to automatically test UI changes on every push.

Live Chromatic Storybook: Check your build status at chromatic.com

Automatic Visual Testing

Chromatic runs automatically on every push to any branch via GitHub Actions. It:

  1. Builds Storybook
  2. Uploads to Chromatic cloud
  3. Captures snapshots of all components
  4. Compares against baseline snapshots
  5. Reports any visual changes

Setup Requirements

GitHub Secret Configuration

  1. Go to your GitHub repository → SettingsSecrets and variablesActions
  2. Click “New repository secret”
  3. Add the following secret:
    • Name: CHROMATIC_PROJECT_TOKEN
    • Value: Your Chromatic project token (found in Chromatic project settings)
  4. Click “Add secret”

Running Chromatic Locally

# Run Chromatic with pre-built Storybook
bun run chromatic

# Or build and run in one command
bunx chromatic --project-token=<your-token>

Workflow Configuration

The Chromatic workflow (.github/workflows/chromatic.yml) is configured to:

Troubleshooting Chromatic

Build fails with “JavaScript failed to load”:

“Context access might be invalid” error:

🛠️ Development Workflow

Adding New Components

  1. Create your component in src/components/ui/
  2. Create a corresponding story file in src/stories/
  3. Follow our story patterns:
    // Basic story structure
    export const Basic: Story = {
      render: () => {
        const [value, setValue] = useState('');
        return <YourComponent value={value} onChange={setValue} />;
      },
    };
    

Story Best Practices

Updating Themes

The Storybook theme is configured in:

📁 File Structure

.storybook/
├── main.ts          # Storybook configuration
├── preview.ts       # Global decorators and parameters
└── manager.ts       # Manager UI theme (if exists)

src/stories/
├── Overview.stories.tsx    # Design system overview
├── Button.stories.tsx      # Button component examples
├── Input.stories.tsx       # Input component examples
├── Loading.stories.tsx     # Loading component examples
├── Modal.stories.tsx       # Modal component examples
└── Toast.stories.tsx       # Toast component examples

.github/workflows/
└── deploy-storybook.yml    # GitHub Actions deployment

🔧 Configuration

Base URL Configuration

The base URL is automatically configured for GitHub Pages deployment:

Build Configuration

Storybook builds to storybook-static/ directory, which is deployed to GitHub Pages.

📝 Troubleshooting

Common Issues

Build Fails:

Deployment Fails:

Stories Not Interactive:

Getting Help

🎯 Next Steps

After deployment, consider:

  1. Custom Domain - Add a custom domain in GitHub Pages settings
  2. Performance Monitoring - Track Storybook load times
  3. Component Testing - Add interaction tests with Storybook Test addon
  4. Design Tokens - Document color palette and spacing system
  5. Component Guidelines - Add usage guidelines for each component

Happy Documenting! 🎉