Skip to content

Commit

Permalink
Merge pull request #240 from cofacts/feature/storybook
Browse files Browse the repository at this point in the history
Feature/storybook
  • Loading branch information
MrOrz authored Mar 30, 2020
2 parents 790d134 + 5c85c8b commit b19de12
Show file tree
Hide file tree
Showing 10 changed files with 10,080 additions and 2,040 deletions.
3 changes: 2 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@
!package-lock.json
!server.js
!next.config.js
!ecosystem.config.js
!ecosystem.config.js
!.storybook/*
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@ node_modules
*.log
coverage
.vscode
public/storybook
.env
.DS_Store
.DS_Store
4 changes: 4 additions & 0 deletions .storybook/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module.exports = {
stories: ['../components/*.stories.js'],
addons: ['@storybook/addon-actions', '@storybook/addon-links'],
};
4 changes: 4 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ COPY . .
ARG LOCALE=en_US
ARG APP_ID=DEV

# Generate storybook files
RUN npm run build-storybook -- -c .storybook/ -o public/storybook/

# Generate .next, which includes absolute path to package so it must be done
# within container.
#
Expand All @@ -33,4 +36,5 @@ CMD ["node_modules/.bin/pm2-runtime", "ecosystem.config.js"]

COPY package.json package-lock.json next.config.js ecosystem.config.js server.js ./
COPY --from=builder /srv/www/.next ./.next
COPY --from=builder /srv/www/public ./public
COPY --from=builder /srv/www/node_modules ./node_modules
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,19 @@ $ docker run --rm --env-file .env -p 3000:3000 rumors-site-test-tw

On [docker hub](https://hub.docker.com/r/cofacts/rumors-site), `hooks/build` is automatically executed on `dev` and `master` branch.

### Storybook
We use storybook to demonstrate components.
```bash
# run storybook localserver on port 6006
$ npm run storybook
```
we also use storyshot to do snapshot test with stories, make sure to run:
```
$ npm test -- -u
```
before pushing to update stories snapshots.
Storybook will be available under /storybook/index.html after build.

## Analytics

This project supports Google Tag Manager. You can prepare the following setup in `.env` file:
Expand Down
3 changes: 3 additions & 0 deletions Storyshots.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import initStoryshots from '@storybook/addon-storyshots';

initStoryshots();
7 changes: 7 additions & 0 deletions __snapshots__/Storyshots.test.js.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Storyshots Example story Hello World 1`] = `
<div>
Hello world!
</div>
`;
5 changes: 5 additions & 0 deletions components/Example.stories.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import React from 'react';

export default { title: 'Example story' };

export const HelloWorld = () => <div>Hello world!</div>;
Loading

0 comments on commit b19de12

Please sign in to comment.