summaryrefslogtreecommitdiffstats
path: root/browser/components/storybook/README.md
blob: 0614abceed15491c85e07d783c6a496a608a187a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
= Storybook for Firefox

Storybook is a component library to document our design system, reusable
components and any specific components you might want to test with dummy data.

== Background

The storybook will list components that can be reused, and will help document
what common elements we have. It can also list implementation specific
components, but they should not be added to the "Design System" section.

Changes to files directly referenced from the storybook (so basically
non-chrome:// paths) should automatically reflect changes in the opened browser.
If you make a change to a chrome:// referenced file then you'll need to do a
hard refresh (Cmd+Shift+R/Ctrl+Shift+R) to notice the changes.

== Running Storybook

Installing the npm dependencies and running the `storybook` npm script should be
enough to get storybook running. This can be done with your personal npm/node
that happens to be compatible or using `./mach npm`.

=== Running with mach based npm

If you do this a lot, you might want to add an alias like this to your shell's
startup config:

```
alias npm-storybook="./mach npm --prefix=browser/components/storybook"
```

Then running `npm-storybook` from the repo's root directory will work with the
storybook directory.

To start storybook the first time (or if it's been a while since you last
installed):

```
# Install the package-lock.json exactly so lockfileVersion won't change.
# Using the `install` command may affect package-lock.json.
./mach npm --prefix=browser/components/storybook ci
# or
npm-storybook ci
```

Once you've got your dependencies installed you can start storybook. You should
run your local build to test in storybook since chrome:// URLs are currently
being pulled from the running browser, so any changes to common-shared.css for
example will come from your build.

```
# Start the Storybook server.
./mach npm --prefix=browser/components/storybook run start-storybook
# or
npm-storybook run start-storybook
# In another terminal:
./mach run http://localhost:5703/

# On MacOS/Linux, there's a command to start storybook and launch your browser.
./mach npm --prefix=browser/components/storybook run storybook
# or
npm-storybook run storybook
```

=== Personal npm

You can use your own `npm` to install and run storyboook. Compatibility is up
to you to sort out.

```
cd browser/components/storybook
npm ci # Install the package-lock.json exactly so lockfileVersion won't change
npm run storybook
```