Skip to content

Commit fffa823

Browse files
Merge pull request #37 from commitd/sh/upgrade
feat(docs): update to use newer committed/components
2 parents fe4765a + aff1e07 commit fffa823

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+5176
-2586
lines changed

.github/workflows/build.yml

Lines changed: 0 additions & 45 deletions
This file was deleted.

.github/workflows/ci.yaml

Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
name: ci
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- beta
8+
pull_request:
9+
types: [opened, synchronize, reopened]
10+
11+
concurrency:
12+
group: ${{ github.ref }}-${{ github.head_ref }}
13+
cancel-in-progress: true
14+
15+
env:
16+
NODE_VERSION: 16
17+
18+
jobs:
19+
build:
20+
runs-on: ubuntu-18.04
21+
steps:
22+
- name: Checkout Commit
23+
uses: actions/checkout@v3
24+
- name: Use Node.js
25+
uses: actions/setup-node@v3
26+
with:
27+
cache: 'yarn'
28+
node-version: ${{ env.NODE_VERSION }}
29+
- name: Install Dependencies
30+
run: |
31+
yarn install
32+
- name: Run build
33+
run: |
34+
yarn run build
35+
- name: Upload build artifacts
36+
uses: actions/upload-artifact@v3
37+
with:
38+
name: build-output
39+
path: dist
40+
retention-days: 1
41+
static-analysis:
42+
runs-on: ubuntu-18.04
43+
needs: build
44+
steps:
45+
- name: Checkout Commit
46+
uses: actions/checkout@v3
47+
- name: Use Node.js
48+
uses: actions/setup-node@v3
49+
with:
50+
cache: 'yarn'
51+
node-version: ${{ env.NODE_VERSION }}
52+
- name: Install Dependencies
53+
run: |
54+
yarn install
55+
- name: Run prettier
56+
run: |
57+
yarn run format:check
58+
- name: Run lint
59+
run: |
60+
yarn run lint
61+
unit-test-scan:
62+
runs-on: ubuntu-18.04
63+
needs: build
64+
steps:
65+
- name: Checkout Commit
66+
uses: actions/checkout@v3
67+
with:
68+
fetch-depth: 0
69+
- name: Use Node.js
70+
uses: actions/setup-node@v3
71+
with:
72+
cache: 'yarn'
73+
node-version: ${{ env.NODE_VERSION }}
74+
- name: Install Dependencies
75+
run: |
76+
yarn install
77+
- name: Run tests
78+
run: |
79+
yarn run test
80+
- name: SonarCloud Scan
81+
uses: sonarsource/sonarcloud-github-action@master
82+
env:
83+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
84+
SONAR_TOKEN: ${{ secrets.SONAR_CLOUD_TOKEN }}
85+
build-storybook:
86+
if: github.event_name == 'pull_request'
87+
runs-on: ubuntu-18.04
88+
needs: build
89+
steps:
90+
- name: Checkout Commit
91+
uses: actions/checkout@v3
92+
- name: Use Node.js
93+
uses: actions/setup-node@v3
94+
with:
95+
cache: 'yarn'
96+
node-version: ${{ env.NODE_VERSION }}
97+
- name: Install Dependencies
98+
run: |
99+
yarn install
100+
- name: Build Storybook
101+
run: yarn run build-storybook --quiet
102+
release:
103+
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/beta'
104+
runs-on: ubuntu-18.04
105+
needs: [static-analysis, unit-test-scan]
106+
steps:
107+
- name: Checkout Commit
108+
uses: actions/checkout@v3
109+
with:
110+
token: ${{ secrets.SEMANTIC_RELEASE_GITHUB_TOKEN }}
111+
- name: Use Node.js
112+
uses: actions/setup-node@v3
113+
with:
114+
cache: 'yarn'
115+
node-version: ${{ env.NODE_VERSION }}
116+
- name: Install Dependencies
117+
run: |
118+
yarn install
119+
- name: Download build artifacts
120+
uses: actions/download-artifact@v3
121+
with:
122+
name: build-output
123+
path: dist
124+
- name: Release
125+
env:
126+
GH_TOKEN: ${{ secrets.SEMANTIC_RELEASE_GITHUB_TOKEN }}
127+
GIT_AUTHOR_NAME: commitd-bot
128+
GIT_AUTHOR_EMAIL: [email protected]
129+
GIT_COMMITTER_NAME: commitd-bot
130+
GIT_COMMITTER_EMAIL: [email protected]
131+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
132+
run: npx semantic-release
133+
publish-storybook:
134+
runs-on: ubuntu-18.04
135+
needs: release
136+
steps:
137+
- name: Checkout Commit
138+
uses: actions/checkout@v3
139+
- name: Use Node.js
140+
uses: actions/setup-node@v3
141+
with:
142+
cache: 'yarn'
143+
node-version: ${{ env.NODE_VERSION }}
144+
- name: Install Dependencies
145+
run: |
146+
yarn install
147+
- name: Publish Storybook
148+
if: github.ref == 'refs/heads/main'
149+
run: yarn run deploy-storybook -- --ci
150+
env:
151+
GH_TOKEN: commitd-bot:${{ secrets.SEMANTIC_RELEASE_GITHUB_TOKEN }}

.github/workflows/release.yml

Lines changed: 0 additions & 33 deletions
This file was deleted.

.github/workflows/size.yml

Lines changed: 0 additions & 12 deletions
This file was deleted.

.husky/commit-msg

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/sh
2+
. "$(dirname "$0")/_/husky.sh"
3+
4+
npx --no-install commitlint --edit ""
5+
npx --no-install commitlint --edit ""

.husky/pre-push

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/sh
2+
. "$(dirname "$0")/_/husky.sh"
3+
4+
yarn test
5+
yarn lint
6+
yarn build
7+
yarn size

.storybook/committed/withTheme.tsx

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,31 @@
11
import React from 'react'
2-
import { ThemeProvider } from '@committed/components'
2+
import { useDarkMode } from 'storybook-dark-mode'
3+
import {
4+
ComponentsProvider,
5+
darkTheme,
6+
lightTheme,
7+
} from '@committed/components'
8+
import '@fontsource/inter/300.css'
9+
import '@fontsource/inter/400.css'
10+
import '@fontsource/inter/700.css'
11+
import '@fontsource/dosis/700.css'
12+
import '@fontsource/dosis/400.css'
13+
import '@fontsource/dosis/300.css'
314

415
/**
516
* Wrap a component with the default ThemeProvider
617
*
718
* @param {*} Story storybook component to wrap
819
*/
920
export const withTheme = (Story) => {
21+
// Clean the theme first
22+
document.body.classList.remove(darkTheme)
23+
document.body.classList.remove(lightTheme)
24+
25+
const choice = useDarkMode() ? 'dark' : 'light'
1026
return (
11-
<ThemeProvider choice="light">
27+
<ComponentsProvider theme={{ choice }}>
1228
<Story />
13-
</ThemeProvider>
29+
</ComponentsProvider>
1430
)
1531
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import React from 'react'
2+
import { DocsContainer as BaseContainer } from '@storybook/addon-docs/blocks'
3+
import { useDarkMode } from 'storybook-dark-mode'
4+
import { themes } from '@storybook/theming'
5+
6+
export const DocsContainer = ({ context, ...props }) => {
7+
const dark = useDarkMode()
8+
9+
return (
10+
<BaseContainer
11+
context={{
12+
...context,
13+
storyById: (id) => {
14+
const storyContext = context.storyById(id)
15+
return {
16+
...storyContext,
17+
parameters: {
18+
...storyContext?.parameters,
19+
docs: {
20+
...storyContext?.parameters?.docs,
21+
theme: dark ? themes.dark : themes.light,
22+
},
23+
},
24+
}
25+
},
26+
}}
27+
{...props}
28+
/>
29+
)
30+
}

.storybook/main.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
module.exports = {
22
stories: [
33
'../stories/**/*.stories.mdx',
4-
'../src/**/*.stories.@(js|jsx|ts|tsx|mdx)',
4+
'../src/**/*.stories.@(js|jsx|ts|tsx)',
55
],
66
addons: [
77
{
@@ -10,6 +10,7 @@ module.exports = {
1010
backgrounds: false,
1111
},
1212
},
13+
'storybook-dark-mode',
1314
],
1415
// https://storybook.js.org/docs/react/configure/typescript#mainjs-configuration
1516
typescript: {

.storybook/manager.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
import { addons } from '@storybook/addons'
2-
import { committedLight } from './committed/theme'
2+
import { committedDark, committedLight } from './committed/theme.js'
33

44
addons.setConfig({
5+
darkMode: {
6+
dark: committedDark,
7+
light: committedLight,
8+
},
59
theme: committedLight,
10+
showPanel: false,
611
})

0 commit comments

Comments
 (0)