Skip to content

Commit

Permalink
Merge pull request #262 from cofacts/storybook
Browse files Browse the repository at this point in the history
Setup Storybook for LIFF components
  • Loading branch information
MrOrz committed Jun 22, 2021
2 parents 2560574 + a241754 commit 1fe1a3e
Show file tree
Hide file tree
Showing 11 changed files with 34,539 additions and 25,552 deletions.
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@ build/*
coverage/*
src/__fixtures__/*
liff/*
storybook-static
!.storybook
31 changes: 31 additions & 0 deletions .github/workflows/storybook.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Build storybook and deploy to gh-pages

on:
push:
branches:
- master
workflow_dispatch:

jobs:
build-and-push:
runs-on: ubuntu-latest

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
- name: Checkout repo
uses: actions/checkout@v2

- run: 'npm i'

- name: Generate staging .env file
run: 'curl $ENV_URL -o .env'
env:
ENV_URL: ${{ secrets.STAGING_ENV_URL }}

- run: 'npm run build-storybook'

- name: Deploy
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./storybook-static
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,6 @@ client_secret.json
data/

# Tesseract OCR folder
tmp_image_process
tmp_image_process

storybook-static
46 changes: 46 additions & 0 deletions .storybook/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
const path = require('path');

module.exports = {
stories: [
'../src/**/*.stories.mdx',
'../src/**/*.stories.@(js|jsx|ts|tsx|svelte)',
],
addons: [
'@storybook/addon-links',
{
name: '@storybook/addon-essentials',
options: {
backgrounds: false,
toolbars: false,
},
},
'@storybook/addon-svelte-csf',
],
webpackFinal: async config => {
// Enable project root import paths like 'src/lib/sharedUtils'
// Ref: https://stackoverflow.com/a/65772747/1582110
config.resolve.modules.push(path.resolve(__dirname, '../'));

config.module.rules.push({
test: /\.scss$/,
use: [
'style-loader',
'css-loader',
{
loader: 'sass-loader',
options: {
sassOptions: {
// Process svelte-material-ui SCSS files in node_modules as well
includePaths: [
path.resolve(__dirname, '../node_modules'),
path.resolve(__dirname, '../src/liff'),
],
},
},
},
],
});

return config;
},
};
12 changes: 12 additions & 0 deletions .storybook/preview.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import 'normalize.css';
import '../src/liff/index.scss';

export const parameters = {
actions: { argTypesRegex: '^on[A-Z].*' },
controls: {
matchers: {
color: /(background|color)$/i,
date: /Date$/,
},
},
};
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,15 @@ The LINE bot server starts a GraphQL server that stiches Cofacts GraphQL API and

Whenever Cofacts API updates, use `npm run cofactsapi` to fetch the latest Cofacts API schema.

#### LIFF components storybook

During development, use the following command to start a storybook on your local machine:
```
npm run storybook # Then visit http://localhost:6006
```

You can also visit https://cofacts.github.io/rumors-line-bot for pre-built storybook on `master` branch.

#### How LIFF is deployed on production

On production, LIFF files are compiled to `/liff` directory and served as static files by the chatbot server.
Expand Down
Loading

0 comments on commit 1fe1a3e

Please sign in to comment.