Skip to content

Commit 8327006

Browse files
gavinbarronmusale
andauthored
chore: upgrade to storybook v7 (#2733)
* chore: upgrade to storybook v7 update dependencies automigration via npx storybook@latest upgrade fixed imports fixed parameter config updated stories to use .stories.js as standard extension fixed static dir path for dev loop using autodocs on tagged stories removed old jsll code fixed styling for editor added css hacks to remove padding inside story on docs page migtated doc page config to new format updated default docs story component adjusting css selectors for new storybook version * Remove unused selectors from the storybook Signed-off-by: Musale Martin <[email protected]> --------- Signed-off-by: Musale Martin <[email protected]> Co-authored-by: Musale Martin <[email protected]>
1 parent dc1e602 commit 8327006

File tree

555 files changed

+3563
-3071
lines changed

Some content is hidden

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

555 files changed

+3563
-3071
lines changed

.babelrc.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"sourceType": "unambiguous",
3+
"presets": [
4+
[
5+
"@babel/preset-env",
6+
{
7+
"targets": {
8+
"chrome": 100,
9+
"safari": 15,
10+
"firefox": 91
11+
}
12+
}
13+
],
14+
"@babel/preset-typescript"
15+
],
16+
"plugins": []
17+
}

.eslintrc.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ module.exports = {
44
es6: true,
55
node: true
66
},
7-
extends: ['@microsoft/eslint-config-msgraph'],
7+
extends: ['@microsoft/eslint-config-msgraph', 'plugin:storybook/recommended'],
88
parser: '@typescript-eslint/parser',
99
parserOptions: {
1010
project: [

.storybook/addons/codeEditorAddon/codeAddon.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import addons, { makeDecorator } from '@storybook/addons';
1+
import { addons, makeDecorator } from '@storybook/preview-api';
22

33
import { ProviderState } from '../../../packages/mgt-element/dist/es6/providers/IProvider';
44
import { EditorElement } from './editor';

.storybook/main.js

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { dirname, join } from 'path';
12
/**
23
* -------------------------------------------------------------------------------------------
34
* Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License.
@@ -8,26 +9,16 @@
89
const MonacoWebpackPlugin = require('monaco-editor-webpack-plugin');
910

1011
module.exports = {
11-
core: {
12-
builder: 'webpack5',
13-
},
14-
presets: [
15-
// {
16-
// name: '@storybook/addon-docs/preset',
17-
// options: {
18-
// sourceLoaderOptions: null
19-
// }
20-
// }
21-
],
22-
stories: ['../stories/overview.stories.mdx', '../stories/**/*.@(js|mdx)'],
12+
presets: [],
13+
14+
stories: ['../stories/overview.stories.mdx', '../stories/**/*.stories.@(js|mdx)'],
15+
2316
addons: [
24-
'storybook-version',
25-
'@storybook/addon-docs'
26-
// '@storybook/addon-a11y/register',
27-
// '@storybook/addon-actions/register',
28-
// '@storybook/addon-knobs/register',
29-
// '@storybook/addon-links/register'
17+
getAbsolutePath('storybook-version'),
18+
getAbsolutePath('@storybook/addon-docs'),
19+
getAbsolutePath('@storybook/addon-mdx-gfm')
3020
],
21+
3122
webpackFinal: async (config, { configType }) => {
3223
// `configType` has a value of 'DEVELOPMENT' or 'PRODUCTION'
3324
// You can change the configuration based on that.
@@ -42,5 +33,18 @@ module.exports = {
4233

4334
// Return the altered config
4435
return config;
36+
},
37+
38+
framework: {
39+
name: getAbsolutePath('@storybook/web-components-webpack5'),
40+
options: {}
41+
},
42+
43+
docs: {
44+
autodocs: 'tag'
4545
}
4646
};
47+
48+
function getAbsolutePath(value) {
49+
return dirname(require.resolve(join(value, 'package.json')));
50+
}

.storybook/manager-head.html

Lines changed: 10 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,10 @@
1313
</footer>
1414

1515
<script src="https://consentdeliveryfd.azurefd.net/mscc/lib/v2/wcp-consent.js"></script>
16-
<script src="https://az725175.vo.msecnd.net/scripts/jsll-4.js" type="text/javascript"></script>
1716
<script type="module" src="https://unpkg.com/@fluentui/web-components@2"></script>
1817
<script type="text/javascript">
1918
const xmlns = "http://www.w3.org/2000/svg";
2019

21-
var config = {
22-
autoCapture: {
23-
lineage: true,
24-
},
25-
coreData: {
26-
appId: "JS:GraphToolkit",
27-
},
28-
};
29-
awa.init(config);
30-
3120
window.onload = () => {
3221
addUsefulLinks();
3322
}
@@ -159,14 +148,7 @@
159148
</script>
160149

161150
<style>
162-
.css-bt79wf>svg>path,
163-
.css-1j9r8vi>svg>path {
164-
color: rgba(153, 153, 153, 0.6) !important;
165-
fill: rgba(153, 153, 153, 0.6) !important;
166-
}
167-
168151
@media (forced-colors: active) and (prefers-color-scheme: dark) {
169-
170152
#root,
171153
svg,
172154
svg>path,
@@ -175,33 +157,13 @@
175157
color: rgb(255, 255, 255) !important;
176158
}
177159

178-
.css-bt79wf>svg>path,
179-
.css-1j9r8vi>svg>path {
180-
color: rgba(255, 255, 255) !important;
181-
fill: rgba(255, 255, 255) !important;
182-
}
183-
184-
.css-cwrfva:hover,
185-
.css-cwrfva:focus-visible {
186-
border: 1px solid rgba(255, 255, 255) !important;
187-
}
188-
189-
.css-128qwy8:hover {
190-
/* background-image: radial-gradient(at center center,rgba(0,0,0,0.2) 0%,transparent 70%,transparent 100%); */
191-
background-image: radial-gradient(at center center, rgba(255, 255, 255) 100%, transparent 100%, transparent 100%);
192-
background-size: 50px 100%;
193-
background-position: 0 50%;
194-
background-repeat: no-repeat;
195-
}
196-
197160
.os-scrollbar>.os-scrollbar-track>.os-scrollbar-handle,
198161
.os-scrollbar>.os-scrollbar-track {
199162
border: 1px solid transparent;
200163
}
201164
}
202165

203166
@media (forced-colors: active) and (prefers-color-scheme: light) {
204-
205167
#root,
206168
svg,
207169
svg>path,
@@ -210,33 +172,12 @@
210172
color: rgb(0, 0, 0) !important;
211173
}
212174

213-
.css-bt79wf>svg>path,
214-
.css-1j9r8vi>svg>path {
215-
color: rgba(0, 0, 0) !important;
216-
fill: rgba(0, 0, 0) !important;
217-
}
218-
219-
.css-cwrfva:hover,
220-
.css-cwrfva:focus-visible {
221-
border: 1px solid rgba(0, 0, 0) !important;
222-
}
223-
224-
.css-128qwy8:hover {
225-
/* background-image: radial-gradient(at center center,rgba(0,0,0,0.2) 0%,transparent 70%,transparent 100%); */
226-
background-image: radial-gradient(at center center, rgba(0, 0, 0, 0.2) 100%, transparent 100%, transparent 100%);
227-
background-size: 50px 100%;
228-
background-position: 0 50%;
229-
background-repeat: no-repeat;
230-
}
231-
232175
.os-scrollbar>.os-scrollbar-track>.os-scrollbar-handle,
233176
.os-scrollbar>.os-scrollbar-track {
234177
border: 1px solid transparent;
235178
}
236179
}
237-
</style>
238180

239-
<style>
240181
.sidebar-header button {
241182
display: none !important;
242183
}
@@ -260,10 +201,6 @@
260201
color: #323232;
261202
}
262203

263-
.sidebar-subheading.css-ulso1l {
264-
color: #717171 !important;
265-
}
266-
267204
.sidebar-header h1 {
268205
font-size: 14px;
269206
font-weight: 700;
@@ -282,45 +219,29 @@
282219
color: inherit;
283220
}
284221

285-
.css-ulso1l,
286-
.css-gb1sl5 {
287-
color: #717171 !important;
288-
}
289-
290-
.sto-ulso1l,
291-
.css-1en6m26 {
222+
/* Sets the color of the sidebar section headings */
223+
.sidebar-subheading.css-ppqi8s {
292224
color: #616159 !important;
293225
}
294226

295227
/* Fix color contrast of left expanded/collapsed chevrons */
296-
297-
.sto-bt79wf,
298-
.sto-1j9r8vi {
228+
.css-ct44ui,
229+
.css-1necw0m {
299230
color: unset;
300231
}
301232

302233
/* Removes Find component feature */
303-
.css-8ktt77 {
304-
display: none;
305-
}
306-
307-
.css-14o7vtb {
308-
border: 2px solid transparent;
309-
}
310-
311-
.css-14o7vtb:focus-visible {
312-
outline: auto;
313-
}
314234
.search-field {
315235
display: none !important;
316236
}
317237

238+
/* fix high contrast mode colors on sidebar links */
318239
@media (forced-colors: active){
319-
a[class*="sto-"][data-selected="true"],
320-
a[class*="sto-"][data-selected="true"]:focus,
321-
a[class*="sto-"][data-selected="false"]:focus,
322-
a[class*="sto-"][data-selected="true"]:hover,
323-
a[class*="sto-"][data-selected="false"]:hover{
240+
a[class*="css-"][data-selected="true"],
241+
a[class*="css-"][data-selected="true"]:focus,
242+
a[class*="css-"][data-selected="false"]:focus,
243+
a[class*="css-"][data-selected="true"]:hover,
244+
a[class*="css-"][data-selected="false"]:hover {
324245
background: Highlight;
325246
color: LinkText;
326247
}

.storybook/preview-body.html

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
<style>
22
html,
33
body,
4-
#root {
4+
#root,
5+
#storybook-root {
56
height: 100%;
67
width: 100%;
78
font-family: var(--default-font-family, 'Segoe UI', 'Segoe UI Web (West European)', 'Segoe UI', -apple-system, BlinkMacSystemFont, Roboto,
@@ -20,6 +21,7 @@
2021
margin: 0px;
2122
}
2223

24+
/* code editor add-on styling */
2325
.story-mgt-root {
2426
height: 100%;
2527
width: 100%;
@@ -77,12 +79,15 @@
7779
z-index: 10;
7880
}
7981

80-
.css-19nbuh3,
82+
/* End code editor add-on styling */
83+
84+
/* fixes link color and attribute value colors in storybook inline code blocks*/
85+
.sbdocs-a,
8186
.css-zj0253 * .token.attr-value {
8287
color: #0360B9 !important;
8388
}
8489

85-
/* fix attributes in html rendering */
90+
/* fix attribute names in html rendering */
8691
.mtk4, .css-zj0253 * .token.attr-name {
8792
color: #e50000 !important;
8893
}
@@ -96,7 +101,16 @@
96101
outline: auto;
97102
}
98103

104+
/* changes to eliminate padding/margins inside embedded stories in docs page*/
105+
.docs-story > div {
106+
padding: 0;
107+
margin: 0;
108+
}
109+
.css-1wjen9k .innerZoomElementWrapper > div {
110+
border: 0!important;
111+
}
99112

113+
/* responsive fixes for small screens */
100114
@media (max-width: 768px) {
101115
.story-mgt-root {
102116
flex-direction: column;

.storybook/preview.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77

88
/* global window */
99

10-
import { addParameters, setCustomElements } from '@storybook/web-components';
10+
import { setCustomElements } from '@storybook/web-components';
1111
import '../node_modules/@webcomponents/webcomponentsjs/webcomponents-bundle.js';
1212
import customElements from '../custom-elements.json';
1313
import { versionInfo } from './versionInfo';
14-
import { noArgsDocsPage } from './story-elements/noArgsDocsPage.js';
14+
import { defaultDocsPage } from './story-elements/defaultDocsPage';
1515

1616
const setCustomElementsManifestWithOptions = (customElements, options) => {
1717
let { privateFields = true } = options;
@@ -33,7 +33,7 @@ const setCustomElementsManifestWithOptions = (customElements, options) => {
3333

3434
setCustomElementsManifestWithOptions(customElements, { privateFields: false });
3535

36-
addParameters({
36+
export const parameters = {
3737
previewTabs: {
3838
'storybook/docs/panel': {
3939
hidden: true
@@ -43,17 +43,19 @@ addParameters({
4343
}
4444
},
4545
docs: {
46-
iframeHeight: '400px',
47-
inlineStories: false,
48-
page: noArgsDocsPage
46+
page: defaultDocsPage,
47+
story: {
48+
inline: false,
49+
height: '500px'
50+
}
4951
},
5052
version: versionInfo,
5153
options: {
5254
storySort: {
5355
order: ['stories']
5456
}
5557
}
56-
});
58+
};
5759

5860
const req = require.context('../stories', true, /\.(js|mdx)$/);
5961
// configure(req, module);
Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
import React from 'react';
22

3-
import { Title, Subtitle, Description, Primary, ArgsTable, Stories, PRIMARY_STORY } from '@storybook/addon-docs';
3+
import { Title, Subtitle, Description, Primary, PRIMARY_STORY, ArgTypes } from '@storybook/addon-docs';
44

55
export const defaultDocsPage = () => (
66
<>
77
<Title />
88
<Subtitle />
99
<Description />
1010
<Primary />
11-
<ArgsTable story={PRIMARY_STORY} />
12-
<Stories />
11+
<ArgTypes story={PRIMARY_STORY} />
1312
</>
1413
);

.storybook/story-elements/noArgsDocsPage.js

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

0 commit comments

Comments
 (0)