2021-06-18 12:10:03 +00:00
---
stage: none
group: unassigned
2022-09-21 21:13:33 +00:00
info: To determine the technical writer assigned to the Stage/Group associated with this page, see https://about.gitlab.com/handbook/product/ux/technical-writing/#assignments
2021-06-18 12:10:03 +00:00
---
# Storybook
2022-07-21 21:10:17 +00:00
The Storybook for the `gitlab-org/gitlab` project is available on our [GitLab Pages site ](https://gitlab-org.gitlab.io/gitlab/storybook/ ).
2021-06-18 12:10:03 +00:00
## Storybook in local development
Storybook dependencies and configuration are located under the `storybook/` directory.
To build and launch Storybook locally, in the root directory of the `gitlab` project:
1. Install Storybook dependencies:
```shell
yarn storybook:install
```
1. Build the Storybook site:
```shell
yarn storybook:start
```
## Adding components to Storybook
Stories can be added for any Vue component in the `gitlab` repository.
To add a story:
1. Create a new `.stories.js` file in the same directory as the Vue component.
2021-09-28 12:11:10 +00:00
The filename should have the same prefix as the Vue component.
2021-06-18 12:10:03 +00:00
```txt
vue_shared/
├─ components/
2021-07-05 06:08:01 +00:00
│ ├─ sidebar
2021-10-01 12:13:32 +00:00
│ | ├─ todo_toggle
│ | | ├─ todo_button.vue
│ │ | ├─ todo_button.stories.js
2021-06-18 12:10:03 +00:00
```
2021-07-02 18:08:28 +00:00
1. Write the story as per the [official Storybook instructions ](https://storybook.js.org/docs/vue/writing-stories/introduction/ )
2021-07-01 18:07:29 +00:00
2022-08-24 12:12:07 +00:00
NOTE:
2022-08-31 12:13:01 +00:00
Specify the `title` field of the story as the component's file path from the `javascripts/` directory, without the `/components` part.
2022-08-24 12:12:07 +00:00
For example, if the component is located at `app/assets/javascripts/vue_shared/components/sidebar/todo_toggle/todo_button.vue` ,
2022-08-31 12:13:01 +00:00
specify the story `title` as `vue_shared/sidebar/todo_toggle/todo_button` .
2022-08-24 12:12:07 +00:00
If the component is located in the `ee/` directory, make sure to prefix the story's title with `ee/` as well.
This will ensure the Storybook navigation maps closely to our internal directory structure.
2021-09-30 18:11:31 +00:00
## Mock backend APIs
2022-05-20 18:07:48 +00:00
The GitLab Storybook uses [MirajeJS ](https://miragejs.com/ ) to mock REST and GraphQL APIs. Storybook shares the MirajeJS server
2021-09-30 18:11:31 +00:00
with the [frontend integration tests ](../testing_guide/testing_levels.md#frontend-integration-tests ). You can find the MirajeJS
configuration files in `spec/frontend_integration/mock_server` .