Update storybook to support stories for individual components (#3010)

This PR updates the `storybook` with support for adding stories for
individual components.

### Motivation

Right now we just have one story in the storybook that renders an entire
`WorkspaceElement`.

While iterating on the various UI components, it will be helpful to be
able to create stories of those components just by themselves.

This is especially true for components that have a number of different
states, as we can render the components in all of the various states in
a single layout.

### Explanation

We achieve this by adding a simple CLI to the storybook.

The `storybook` binary now accepts an optional `[STORY]` parameter that
can be used to indicate which story should be loaded. If this parameter
is not provided, it will load the workspace story as it currently does.

Passing a story name will load the corresponding story, if it exists.

For example:

```
cargo run -- elements/avatar
```

<img width="723" alt="Screenshot 2023-09-21 at 10 29 52 PM"
src="https://github.com/zed-industries/zed/assets/1486634/5df489ed-8607-4024-9c19-c5f4541f97c9">

```
cargo run -- components/facepile
```

<img width="785" alt="Screenshot 2023-09-21 at 10 30 07 PM"
src="https://github.com/zed-industries/zed/assets/1486634/e04a4577-7403-405d-b23c-e765b7a06229">



Release Notes:

- N/A
This commit is contained in:
Marshall Bowers 2023-09-21 22:41:53 -04:00 committed by GitHub
parent 4628639ac6
commit 66358f2900
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 180 additions and 19 deletions

View file

@ -9,8 +9,9 @@ name = "storybook"
path = "src/storybook.rs"
[dependencies]
gpui2 = { path = "../gpui2" }
anyhow.workspace = true
clap = { version = "3.1", features = ["derive"] }
gpui2 = { path = "../gpui2" }
log.workspace = true
rust-embed.workspace = true
serde.workspace = true