Skip to content

Commit

Permalink
refactor: re-configure storybook hosting for web (#537)
Browse files Browse the repository at this point in the history
## Description

<img width="600" alt="screen"
src="https://github.com/dooboolab-community/dooboo-ui/assets/27461460/3d5ec738-4bf8-4d95-b7cd-7773e703d189">

Delete the separately documented Storybook from the past, and change the
structure to manage it together with the existing root project.


## Checklist

Before you create this PR confirms that it meets all requirements listed
below by checking the relevant checkboxes (`[x]`). This will ensure a
smooth and quick review process.

- [x] I read the [Contributor
Guide](https://github.com/dooboolab-community/dooboo-ui/blob/main/CONTRIBUTING.md)
and followed the process outlined there for submitting PRs.
- [x] Run `yarn test:all` and make sure nothing fails.
- [x] I am willing to follow-up on review comments in a timely manner.
  • Loading branch information
hyochan committed Feb 7, 2024
1 parent c8e69bd commit 061c0b1
Show file tree
Hide file tree
Showing 97 changed files with 1,027 additions and 16,253 deletions.
File renamed without changes.
18 changes: 7 additions & 11 deletions .github/workflows/deploy-docs-staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,9 @@ on:
pull_request:
branches:
- main
paths:
- 'docs/**'

jobs:
build_and_preview:
if: ${{ github.event.label.name == 'preview' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
Expand All @@ -17,25 +14,24 @@ jobs:
node-version: 20.x
check-latest: false

- name: Install Expo CLI
run: yarn global add expo-cli
- name: Setup expo cli
uses: expo/expo-github-action@v8
with:
expo-version: 4.x

- name: Install packages and build storybook
run: |
pushd ./docs
yarn preinstall
yarn install --network-concurrency 1
yarn build
popd
yarn pre
yarn storybook:build
- name: Deploy to firebase
uses: FirebaseExtended/action-hosting-deploy@v0
with:
entryPoint: './docs'
repoToken: '${{ secrets.GITHUB_TOKEN }}'
firebaseServiceAccount: '${{ secrets.FIREBASE_SERVICE_ACCOUNT_DOOBOOLAB_2F044 }}'
projectId: dooboolab-2f044
target: dooboo-ui
expires: 14d
expires: 7d
env:
FIREBASE_CLI_PREVIEWS: hostingchannels
16 changes: 7 additions & 9 deletions .github/workflows/deploy-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ on:
push:
branches:
- main
paths:
- 'docs/**'

jobs:
build_and_deploy:
Expand All @@ -16,20 +14,20 @@ jobs:
with:
node-version: 20.x

- name: Install Expo CLI
run: yarn global add expo-cli

- name: Setup expo cli
uses: expo/expo-github-action@v8
with:
expo-version: 4.x

- name: Install packages and build storybook
run: |
pushd ./docs
yarn install --network-concurrency 1
yarn build
popd
yarn pre
yarn storybook:build
- name: Deploy to firebase
uses: FirebaseExtended/action-hosting-deploy@v0
with:
entryPoint: './docs'
repoToken: '${{ secrets.GITHUB_TOKEN }}'
firebaseServiceAccount: '${{ secrets.FIREBASE_SERVICE_ACCOUNT_DOOBOOLAB_2F044 }}'
channelId: live
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/gh-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:

- name: Install packages and build storybook
run: |
yarn build:storybook
yarn export
- name: Deploy
uses: peaceiris/actions-gh-pages@v3
Expand Down
14 changes: 8 additions & 6 deletions .storybook/main.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
/** @type{import("@storybook/react-webpack5").StorybookConfig} */
module.exports = {
stories: [
"../stories/**/*.stories.mdx",
"../stories/**/*.stories.@(js|jsx|ts|tsx)",
'../stories/**/*.stories.mdx',
'../stories/**/*.stories.@(js|jsx|ts|tsx)',
],
addons: [
"@storybook/addon-links",
"@storybook/addon-essentials",
"@storybook/addon-react-native-web",
'@storybook/addon-links',
'@storybook/addon-essentials',
'@storybook/addon-docs',
'@storybook/addon-react-native-web',
'storybook-dark-mode',
],
framework: {
name: "@storybook/react-webpack5",
name: '@storybook/react-webpack5',
options: {},
},
docs: {
Expand Down
8 changes: 8 additions & 0 deletions .storybook/manager-head.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<link rel="shortcut icon" href="/static/icon.ico" />
<link rel="icon" type="image/png" href="/static/icon.png" sizes="192x192" />
<style>
html {
font-size: 16px;
}
</style>
<title>dooboo-ui</title>
13 changes: 0 additions & 13 deletions .storybook/preview.ts

This file was deleted.

83 changes: 83 additions & 0 deletions .storybook/preview.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
import React from 'react';
import type {Preview} from '@storybook/react';
import {darkTheme, lightTheme} from './theme';
import {DocsContainer} from '@storybook/addon-docs';

import {useDarkMode} from 'storybook-dark-mode';

export const preview: Preview = {
parameters: {
actions: {argTypesRegex: '^on[A-Z].*'},
controls: {
matchers: {
color: /(background|color)$/i,
date: /Date$/,
},
},
darkMode: {
dark: darkTheme,
light: lightTheme,
},
docs: {
container: ({children, context}) => (
<DocsContainer
context={{
...context,
storyById: (id) => {
const storyContext = context.storyById(id);
return {
...storyContext,
parameters: {
...storyContext?.parameters,
docs: {
...storyContext?.parameters?.docs,
theme: useDarkMode() ? darkTheme : lightTheme,
},
},
};
},
}}
>
{children}
</DocsContainer>
),
},
options: {
storySort: (a, b) => {
const sectionA = a.id.split('-')[0];
const sectionB = b.id.split('-')[0];
if (sectionA === sectionB) {
return a.name.localeCompare(b.name);
}
const sectionMap = {
overview: 1,
components: 2,
modals: 3,
packages: 4,
};
return (sectionMap[sectionA] || 0) - (sectionMap[sectionB] || 0);
},
/**
* regex for finding the hierarchy separator
* @example:
* null - turn off hierarchy
* /\// - split by `/`
* /\./ - split by `.`
* /\/|\./ - split by `/` or `.`
* @type {Regex}
*/
hierarchySeparator: /\/|\./,
/**
* regex for finding the hierarchy root separator
* @example:
* null - turn off multiple hierarchy roots
* /\|/ - split by `|`
* @type {Regex}
*/
hierarchyRootSeparator: /\|/,
isToolshown: true,
showPanel: true,
panelPosition: 'bottom',
},
},
};
75 changes: 75 additions & 0 deletions .storybook/theme.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
import {create} from '@storybook/theming';

const commonTheme = {
brandTitle: 'dooboo-ui',
brandUrl: 'https://dooboo-ui.dooboolab.com',
brandImage: '/static/icon.png',
brandTarget: '_self',
stylePreview: true,
};

export const lightTheme = create({
...commonTheme,
base: 'light',
colorPrimary: 'black',
colorSecondary: '#00D9D5',

// UI
appBg: 'white',
appContentBg: 'white',
appBorderColor: '#F6F9FC',
appBorderRadius: 1,

// Typography
fontBase: '"Source Sans Pro", sans-serif',
fontCode: 'monospace',

// Text colors
textColor: 'black',
textInverseColor: 'white',

// Toolbar default and active colors
barTextColor: '#F6F9FC',
barSelectedColor: 'black',
barBg: '#00D9D5',

// Form colors
inputBg: 'white',
inputBorder: '#414141',
inputTextColor: 'black',
inputBorderRadius: 1,
});

export const darkTheme = create({
...commonTheme,
base: 'dark',
colorPrimary: 'white',
colorSecondary: '#1E1D1D',

// UI
appBg: '#1D1E1E',
appContentBg: '#1D1E1E',
appBorderColor: '#1D1E1E',
appBorderRadius: 1,

// Typography
fontBase: '"Source Sans Pro", sans-serif',
fontCode: 'monospace',

// Text colors
textColor: 'white',
textInverseColor: 'black',

// Toolbar default and active colors
barTextColor: '#EDEDED',
barSelectedColor: '#585DFA',
barBg: '#1D1E1E',

// Form colors
inputBg: 'black',
inputBorder: '#414141',
inputTextColor: 'white',
inputBorderRadius: 1,

appPreviewBg: '#1D1E1E',
});
3 changes: 1 addition & 2 deletions babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@ module.exports = (api) => {
],
plugins: [
'@emotion',
'@babel/plugin-syntax-dynamic-import',
'@babel/plugin-transform-modules-commonjs',
'react-native-reanimated/plugin',
['babel-plugin-react-docgen-typescript', {exclude: 'node_modules'}],
],
};
};
66 changes: 0 additions & 66 deletions docs/.gitignore

This file was deleted.

Loading

0 comments on commit 061c0b1

Please sign in to comment.