Skip to content

Commit b5e58e4

Browse files
authored
Release/storybook (#1871)
* chore: move docs to temp folder * chore: upgrade storybook * chore: migrate docs to new storybook version * chore: fix audit issues * chore: resolve doc issue
1 parent 844615a commit b5e58e4

835 files changed

Lines changed: 62719 additions & 37455 deletions

File tree

Some content is hidden

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

.gitignore

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,8 @@ resources/data/commands.json
8888
resources/data/contributors.json
8989
resources/data/selectors.json
9090

91-
docs/stories/contributing/contributors.md
92-
docs/stories/development/00-guides/theming/theming.md
91+
docs/src/contributing/contributors.md
92+
docs/src/development/00-guides/theming/theming.md
9393
docs/public/assets/fonts/
9494
docs/public/assets/data/
9595
docs/public/assets/download/
@@ -100,9 +100,12 @@ docs/public/build/
100100
docs/public/assets/images/map-markers
101101
docs/public/assets/images/brand-icons
102102
docs/public/assets/images/icons
103-
docs/stories/assets/data
104-
docs/stories/components/**/api.md
103+
docs/src/assets/data
104+
docs/src/components/**/api.md
105+
docs/src/components/**/theming.md
106+
docs/src/components/**/testing.md
105107
docs/dist
108+
docs.old/
106109

107110
test/angular/*
108111
!test/angular/base

.prettierignore

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,18 @@ CHANGELOG_v12.md
2525
generated
2626

2727
docs/public
28-
docs/stories/assets
29-
docs/stories/components/**/api.md
30-
docs/stories/components/**/testing.md
31-
docs/stories/components/**/theming.md
28+
docs/src/assets
29+
docs/src/components/**/api.md
30+
docs/src/components/**/testing.md
31+
docs/src/components/**/theming.md
3232

3333
e2e/cypress/snapshots
3434
e2e/cypress/videos
3535
e2e/cypress/downloads
3636

3737
package-lock.json
3838
*.svg
39+
*.mdx
3940
resources/data/components.json
4041

4142
/.nx/workspace-data

cspell.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,11 @@
44
"language": "en",
55
"dictionaries": ["en_us", "softwareTerms", "lorem-ipsum", "typescript", "css", "html"],
66
"useGitignore": true,
7-
"files": ["docs/stories/**/*.{md,mdx}", "packages/core/src/**/*.{tsx,ts}"],
7+
"files": ["docs/src/**/*.{md,mdx}", "packages/core/src/**/*.{tsx,ts}"],
88
"ignorePaths": [
99
"packages/core/src/**/*.i18n.ts",
1010
"packages/core/src/**/*.data.ts",
1111
"packages/core/src/**/*.spec.ts",
12-
"docs/stories/components/bal-select/code-sandbox/*",
1312
"docs/public/*",
1413
"docs/assets/*"
1514
],
@@ -43,7 +42,6 @@
4342
"Chainable",
4443
"Chiudere",
4544
"clastzoo",
46-
"codesandbox",
4745
"colorify",
4846
"Combi",
4947
"commitlint",

docs/.eslintignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
node_modules
22
dist
33
public
4-
stories/assets
4+
src/assets

docs/.eslintrc.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
"@baloise/ds-brand-icons",
2424
"@baloise/ds-icons",
2525
"@baloise/ds-tokens",
26+
"react",
2627
"react-dom",
2728
"js-beautify",
2829
"storybook",
@@ -34,8 +35,7 @@
3435
"@storybook/components",
3536
"@storybook/theming",
3637
"@storybook/addon-docs",
37-
"@storybook/global",
38-
"codesandbox"
38+
"@storybook/global"
3939
]
4040
}
4141
]

docs/.gitignore

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
yarn-debug.log*
6+
yarn-error.log*
7+
pnpm-debug.log*
8+
lerna-debug.log*
9+
10+
node_modules
11+
dist
12+
dist-ssr
13+
*.local
14+
15+
# Editor directories and files
16+
.vscode/*
17+
!.vscode/extensions.json
18+
.idea
19+
.DS_Store
20+
*.suo
21+
*.ntvs*
22+
*.njsproj
23+
*.sln
24+
*.sw?
25+
26+
*storybook.log
27+
storybook-static
Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
import { addons } from '@storybook/addons'
2-
31
const LOCAL_KEY = 'BaloiseDesignSystemCookieAccepted'
42

5-
const rIC = callback => {
3+
const rIC = (callback: () => void) => {
64
if ('requestIdleCallback' in window) {
75
window.requestIdleCallback(callback)
86
} else {
@@ -36,12 +34,13 @@ const showCookieAlert = () => {
3634
document.body.appendChild(cookie)
3735
}
3836

39-
addons.register('my/cookie', api => {
37+
// addons.register('my/cookie', api => {
38+
export const registerCookie = () => {
4039
rIC(() => {
41-
const hasAccepted = JSON.parse(localStorage.getItem(LOCAL_KEY))
40+
const hasAccepted = JSON.parse(localStorage.getItem(LOCAL_KEY) || 'false')
4241

4342
if (!hasAccepted) {
4443
showCookieAlert()
4544
}
4645
})
47-
})
46+
}

docs/.storybook/addons/cookie/index.js

Lines changed: 0 additions & 5 deletions
This file was deleted.
Lines changed: 158 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,158 @@
1+
import React, { useState } from 'react'
2+
import { WithTooltip } from 'storybook/internal/components'
3+
import { FORCE_RE_RENDER } from 'storybook/internal/core-events'
4+
import { addons, useGlobals } from 'storybook/manager-api'
5+
6+
const AngularSVG = `<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
7+
viewBox="0 0 250 250" style="enable-background:new 0 0 250 250;" xml:space="preserve">
8+
<style type="text/css">
9+
.st0{fill:#DD0031;}
10+
.st1{fill:#C3002F;}
11+
.st2{fill:#FFFFFF;}
12+
</style>
13+
<g>
14+
<polygon class="st0" points="125,30 125,30 125,30 31.9,63.2 46.1,186.3 125,230 125,230 125,230 203.9,186.3 218.1,63.2 "/>
15+
<polygon class="st1" points="125,30 125,52.2 125,52.1 125,153.4 125,153.4 125,230 125,230 203.9,186.3 218.1,63.2 125,30 "/>
16+
<path class="st2" d="M125,52.1L66.8,182.6h0h21.7h0l11.7-29.2h49.4l11.7,29.2h0h21.7h0L125,52.1L125,52.1L125,52.1L125,52.1
17+
L125,52.1z M142,135.4H108l17-40.9L142,135.4z"/>
18+
</g>
19+
</svg>
20+
`
21+
const ReactSVG = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="-11.5 -10.23174 23 20.46348">
22+
<title>React Logo</title>
23+
<circle cx="0" cy="0" r="2.05" fill="#61dafb"/>
24+
<g stroke="#61dafb" stroke-width="1" fill="none">
25+
<ellipse rx="11" ry="4.2"/>
26+
<ellipse rx="11" ry="4.2" transform="rotate(60)"/>
27+
<ellipse rx="11" ry="4.2" transform="rotate(120)"/>
28+
</g>
29+
</svg>`
30+
31+
const JavaScriptSVG = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 630 630">
32+
<rect width="630" height="630" fill="#f7df1e"/>
33+
<path d="m423.2 492.19c12.69 20.72 29.2 35.95 58.4 35.95 24.53 0 40.2-12.26 40.2-29.2 0-20.3-16.1-27.49-43.1-39.3l-14.8-6.35c-42.72-18.2-71.1-41-71.1-89.2 0-44.4 33.83-78.2 86.7-78.2 37.64 0 64.7 13.1 84.2 47.4l-46.1 29.6c-10.15-18.2-21.1-25.37-38.1-25.37-17.34 0-28.33 11-28.33 25.37 0 17.76 11 24.95 36.4 35.95l14.8 6.34c50.3 21.57 78.7 43.56 78.7 93 0 53.3-41.87 82.5-98.1 82.5-54.98 0-90.5-26.2-107.88-60.54zm-209.13 5.13c9.3 16.5 17.76 30.45 38.1 30.45 19.45 0 31.72-7.61 31.72-37.2v-201.3h59.2v202.1c0 61.3-35.94 89.2-88.4 89.2-47.4 0-74.85-24.53-88.81-54.075z"/>
34+
</svg>`
35+
36+
const SvgIcons = {
37+
angular: AngularSVG,
38+
react: ReactSVG,
39+
html: JavaScriptSVG,
40+
} as any
41+
42+
const labels = {
43+
angular: 'Angular',
44+
html: 'HTML & JS',
45+
react: 'React',
46+
} as any
47+
48+
const frameworks = ['angular', 'html', 'react']
49+
50+
const LOCAL_STORE_ID = 'bal-docs-framework'
51+
52+
const usePersisted = (initialValue: string) => {
53+
const [storedValue, setStoredValue] = useState(() => {
54+
try {
55+
const item = window.localStorage.getItem(LOCAL_STORE_ID)
56+
const storedFramework = item ? JSON.parse(item) : initialValue
57+
return frameworks.includes(storedFramework) ? storedFramework : undefined
58+
} catch (error) {
59+
return initialValue
60+
}
61+
})
62+
63+
const setValue = (value: string) => {
64+
const newFramework = frameworks.includes(value) ? value : 'angular'
65+
setStoredValue(newFramework)
66+
window.localStorage.setItem(LOCAL_STORE_ID, JSON.stringify(newFramework))
67+
}
68+
69+
return [storedValue, setValue]
70+
}
71+
72+
export const registerFramework = (): React.FC => {
73+
const [persistedFramework, updatePersisted] = usePersisted('angular')
74+
const [globals, updateGlobals] = useGlobals()
75+
let { framework } = globals
76+
77+
const urlSearchParams = new URLSearchParams(window.location.search)
78+
const params = Object.fromEntries(urlSearchParams.entries())
79+
let paramFramework = params.globals?.replace('framework:', '')
80+
81+
paramFramework = frameworks.includes(paramFramework) ? paramFramework : ''
82+
83+
React.useEffect(() => {
84+
if (!paramFramework && framework !== persistedFramework) {
85+
updateGlobals({ ...globals, framework: persistedFramework })
86+
addons.getChannel().emit(FORCE_RE_RENDER)
87+
}
88+
}, [framework, persistedFramework])
89+
90+
const iframe = document.getElementById('storybook-preview-iframe') as HTMLIFrameElement
91+
if (iframe && framework) {
92+
const iframeDocument = iframe.contentDocument || iframe.contentWindow?.document
93+
if (iframeDocument) {
94+
const body = iframeDocument.querySelector('body')
95+
if (body) {
96+
body.classList.add(`my-framework-${framework}`)
97+
}
98+
}
99+
}
100+
101+
return (
102+
<div className="my-framework">
103+
<WithTooltip
104+
placement="top"
105+
trigger="click"
106+
closeOnOutsideClick
107+
tooltip={({ onHide }) => {
108+
const handleItemClick = value => {
109+
framework = value
110+
updatePersisted(framework)
111+
updateGlobals({ ...globals, framework })
112+
onHide()
113+
}
114+
115+
const isActive = f => (f === framework ? ` my-framework__tooltip__item--active` : '')
116+
117+
return (
118+
<div className="my-framework__tooltip">
119+
<a
120+
id="angular"
121+
className={`my-framework__tooltip__item${isActive('angular')}`}
122+
onClick={() => handleItemClick('angular')}
123+
>
124+
<div className="my-framework__button__icon" dangerouslySetInnerHTML={{ __html: AngularSVG }}></div>
125+
Angular
126+
</a>
127+
<a
128+
id="html"
129+
className={`my-framework__tooltip__item${isActive('html')}`}
130+
onClick={() => handleItemClick('html')}
131+
>
132+
<div className="my-framework__button__icon" dangerouslySetInnerHTML={{ __html: JavaScriptSVG }}></div>
133+
HTML &amp; JS
134+
</a>
135+
<a
136+
id="react"
137+
className={`my-framework__tooltip__item${isActive('react')}`}
138+
onClick={() => handleItemClick('react')}
139+
>
140+
<div className="my-framework__button__icon" dangerouslySetInnerHTML={{ __html: ReactSVG }}></div>
141+
React
142+
</a>
143+
</div>
144+
)
145+
}}
146+
>
147+
<button className="my-framework__button" title="Integration technology">
148+
<span className="my-framework__button__label">Framework:</span>
149+
<div
150+
className="my-framework__button__icon"
151+
dangerouslySetInnerHTML={{ __html: SvgIcons[globals.framework] }}
152+
></div>
153+
{labels[globals.framework]}
154+
</button>
155+
</WithTooltip>
156+
</div>
157+
)
158+
}

docs/.storybook/addons/framework/index.js

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

0 commit comments

Comments
 (0)