Skip to content

Commit 5cce34f

Browse files
authored
docs: migrate to storybook version 8.x (#181)
1 parent 2b5e5a6 commit 5cce34f

File tree

82 files changed

+12530
-15537
lines changed

Some content is hidden

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

82 files changed

+12530
-15537
lines changed

apps/documentation/.storybook/main.ts

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,21 @@
1-
import {StorybookConfig} from '@storybook/angular';
1+
import { StorybookConfig } from '@storybook/angular';
2+
23
const config: StorybookConfig = {
3-
staticDirs: [{
4-
from: '../src/assets',
5-
to: 'assets'
6-
}],
7-
stories: ['../src/app/**/*.stories.mdx', '../src/app/**/*.stories.@(js|jsx|ts|tsx)'],
8-
addons: ['@storybook/addon-essentials', '@storybook/addon-mdx-gfm'],
9-
framework: '@storybook/angular',
4+
staticDirs: [
5+
{
6+
from: '../src/assets',
7+
to: 'assets',
8+
},
9+
],
10+
stories: ['../src/app/**/*.mdx', '../src/app/**/*.stories.@(js|jsx|ts|tsx)'],
11+
addons: ['@storybook/addon-essentials', '@storybook/addon-docs'],
12+
framework: {
13+
name: '@storybook/angular',
14+
options: {},
15+
},
1016
docs: {
11-
autodocs: true,
12-
defaultName: 'Docs'
13-
}
17+
defaultName: 'Docs',
18+
},
1419
};
15-
module.exports = config;
20+
21+
export default config;
Lines changed: 36 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
import '@ui5/webcomponents-icons/dist/AllIcons';
22
import '@ui5/webcomponents-fiori/dist/illustrations/AllIllustrations.js';
3-
import applyDirection from "@ui5/webcomponents-base/dist/locale/applyDirection.js";
4-
import {getTheme, setTheme} from '@ui5/webcomponents-base/dist/config/Theme';
3+
import applyDirection from '@ui5/webcomponents-base/dist/locale/applyDirection.js';
4+
import { getTheme, setTheme } from '@ui5/webcomponents-base/dist/config/Theme';
55

66
type Themes = {
77
[name: string]: string;
88
};
99

1010
const themes: Themes = {
11-
"Morning Horizon": "sap_horizon",
12-
"Evening Horizon": "sap_horizon_dark",
13-
"Horizon High Contrast Black": "sap_horizon_hcb",
14-
"Horizon High Contrast White": "sap_horizon_hcw",
15-
"Quartz Light": "sap_fiori_3",
16-
"Quartz Dark": "sap_fiori_3_dark",
17-
"Quartz High Contrast Black": "sap_fiori_3_hcb",
18-
"Quartz High Contrast White": "sap_fiori_3_hcw",
11+
'Morning Horizon': 'sap_horizon',
12+
'Evening Horizon': 'sap_horizon_dark',
13+
'Horizon High Contrast Black': 'sap_horizon_hcb',
14+
'Horizon High Contrast White': 'sap_horizon_hcw',
15+
'Quartz Light': 'sap_fiori_3',
16+
'Quartz Dark': 'sap_fiori_3_dark',
17+
'Quartz High Contrast Black': 'sap_fiori_3_hcb',
18+
'Quartz High Contrast White': 'sap_fiori_3_hcw',
1919
};
2020

2121
export const parameters = {
@@ -24,69 +24,66 @@ export const parameters = {
2424
},
2525
options: {
2626
storySort: {
27-
order: [
28-
"Introduction",
29-
"Maintainers",
30-
"*"
31-
],
27+
order: ['Introduction', 'Maintainers', '*'],
3228
},
3329
},
3430
};
3531

3632
const setDirection = (direction) => {
37-
document.body.setAttribute("dir", direction);
33+
document.body.setAttribute('dir', direction);
3834
applyDirection();
39-
}
40-
35+
};
4136

4237
const withThemeProvider = (Story, storyContext) => {
43-
const {theme, rtl, density} = storyContext.globals;
38+
const { theme, rtl, density } = storyContext.globals;
4439
setTheme(themes[theme]);
4540

46-
setDirection(rtl === "RTL" ? "rtl" : "ltr");
41+
setDirection(rtl === 'RTL' ? 'rtl' : 'ltr');
4742

48-
document.body.classList.remove("sapUiSizeCozy");
49-
document.body.classList.remove("sapUiSizeCompact");
50-
document.body.classList.add("sapUiSize" + density);
43+
document.body.classList.remove('sapUiSizeCozy');
44+
document.body.classList.remove('sapUiSizeCompact');
45+
document.body.classList.add('sapUiSize' + density);
5146
return Story();
52-
}
47+
};
5348

5449
export const decorators = [withThemeProvider];
5550

56-
const GLOBAL_CONTENT_DENSITY_CSS_VAR = "--_ui5_content_density";
51+
const GLOBAL_CONTENT_DENSITY_CSS_VAR = '--_ui5_content_density';
5752

58-
const getEffectiveContentDensity = (el: HTMLElement) => getComputedStyle(el).getPropertyValue(GLOBAL_CONTENT_DENSITY_CSS_VAR);
53+
const getEffectiveContentDensity = (el: HTMLElement) =>
54+
getComputedStyle(el).getPropertyValue(GLOBAL_CONTENT_DENSITY_CSS_VAR);
5955

6056
export const globalTypes = {
6157
theme: {
62-
description: "Global theme for components",
58+
description: 'Global theme for components',
6359
defaultValue: Object.keys(themes).find((key) => themes[key] === getTheme()),
6460
toolbar: {
65-
title: "Toggle theme",
66-
icon: "",
61+
title: 'Toggle theme',
62+
icon: '',
6763
items: Object.keys(themes),
6864
dynamicTitle: true,
6965
},
7066
},
7167
rtl: {
72-
description: "Global rtl mode for components",
73-
defaultValue: "LTR",
68+
description: 'Global rtl mode for components',
69+
defaultValue: 'LTR',
7470
toolbar: {
75-
title: "Direction",
76-
icon: "",
77-
items: ["LTR", "RTL"],
71+
title: 'Direction',
72+
icon: '',
73+
items: ['LTR', 'RTL'],
7874
dynamicTitle: true,
7975
},
8076
},
8177
density: {
82-
description: "Global content density mode for components",
78+
description: 'Global content density mode for components',
8379
defaultValue:
84-
getEffectiveContentDensity(document.body) === "cozy" ? "Cozy" : "Compact",
80+
getEffectiveContentDensity(document.body) === 'cozy' ? 'Cozy' : 'Compact',
8581
toolbar: {
86-
title: "Content Density",
87-
icon: "",
88-
items: ["Cozy", "Compact"],
82+
title: 'Content Density',
83+
icon: '',
84+
items: ['Cozy', 'Compact'],
8985
dynamicTitle: true,
9086
},
9187
},
9288
};
89+
export const tags = ['autodocs', 'autodocs', 'autodocs'];

apps/documentation/src/app/stories/docs/differences.stories.mdx renamed to apps/documentation/src/app/stories/docs/differences.mdx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {Meta} from "@storybook/addon-docs";
1+
import { Meta } from '@storybook/addon-docs';
22

33
<Meta title="Difference from underlying library" />
44

@@ -19,7 +19,6 @@ Every event name will be transformed to the schema `ui5${pascalCase(originalEven
1919
the event name will be `ui5SelectedDatesChange`. In most cases, you will not have to think about it, since all the properties and outputs are typed for Angular users and your IDE will give you autocompletion
2020
for all of them.
2121

22-
2322
### Component imports
2423

2524
In `@ui5/webcomponents` in order to use the component, you should import it as needed, but in `@ui5/webcomponents-ngx` you can import components as a module, as well as standalone components.
@@ -28,11 +27,13 @@ The standalone components are exported from their respective directories, so you
2827
```typescript
2928
import { ButtonComponent } from '@ui5/webcomponents-ngx/main/button';
3029
```
30+
3131
These components can be used as standard standalone components, or if you want to import all the components that are in for example `main` package, you can do it like this:
3232

3333
```typescript
3434
import { Ui5MainModule } from '@ui5/webcomponents-ngx/main';
3535
```
36+
3637
And then you should use them in your `NgModule` just like any other Angular module.
3738

3839
Besides `Ui5MainModule`, there are also `Ui5FioriModule` and `Ui5WebcomponentsModule`, which contains all available components.
@@ -50,7 +51,9 @@ import { ButtonComponent } from '@ui5/webcomponents-ngx/main/button';
5051
selector: 'some-component',
5152
standalone: true,
5253
imports: [CompactDirective, ButtonComponent],
53-
template: `<ui5-button (click)="compact = !compact" [ui5Compact]="compact">Toggle compact</ui5-button>`,
54+
template: `<ui5-button (click)="compact = !compact" [ui5Compact]="compact"
55+
>Toggle compact</ui5-button
56+
>`,
5457
})
5558
export class SomeComponent {
5659
compact = false;

0 commit comments

Comments
 (0)