Skip to content

Commit c146202

Browse files
committed
Update dependencies and enhance Storybook configuration
- Added .angular/cache to .gitignore to prevent caching issues. - Upgraded Storybook and related addons to version 10.2.10 for improved functionality. - Updated @chromatic-com/storybook to version 5.0.1 and chromatic to version 13.3.4. - Modified Storybook preview configuration to streamline background options and set initial global values. - Introduced middleware for CORS handling in Angular Storybook setup. - Added auto-generated theme files for spacing, sizing, shape, and state tokens to support design consistency.
1 parent f428c4f commit c146202

File tree

9 files changed

+16585
-1074
lines changed

9 files changed

+16585
-1074
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@ build-storybook.log
1010

1111
.DS_Store
1212

13+
angular/.angular/cache/*

.storybook/preview.tsx

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,12 @@ const preview: Preview = {
8080
},
8181

8282
backgrounds: {
83-
disable: true,
84-
default: 'light',
85-
values: [
86-
{ name: 'light', value: '#ffffff' },
87-
{ name: 'dark', value: '#000000' },
88-
],
83+
options: {
84+
light: { name: 'light', value: '#ffffff' },
85+
dark: { name: 'dark', value: '#000000' }
86+
},
87+
88+
disabled: true
8989
},
9090

9191
controls: {
@@ -104,6 +104,12 @@ const preview: Preview = {
104104
},
105105

106106
tags: ['autodocs'],
107+
108+
initialGlobals: {
109+
backgrounds: {
110+
value: 'light'
111+
}
112+
}
107113
}
108114

109115
export default preview

angular/.storybook/middleware.mjs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
const ALLOWED_ORIGINS = [
2+
'http://localhost:6006',
3+
'http://127.0.0.1:6006',
4+
];
5+
6+
/**
7+
* Overrides the default Access-Control-Allow-Origin: * header set by Storybook's
8+
* built-in CORS middleware. Wildcard origins are rejected by browsers when the
9+
* request uses credentials: "include" (which Storybook's ref loader does).
10+
*/
11+
export default function expressMiddleware(app) {
12+
app.use((req, res, next) => {
13+
const origin = req.headers.origin;
14+
15+
if (origin && ALLOWED_ORIGINS.includes(origin)) {
16+
res.setHeader('Access-Control-Allow-Origin', origin);
17+
res.setHeader('Access-Control-Allow-Credentials', 'true');
18+
}
19+
20+
next();
21+
});
22+
};

0 commit comments

Comments
 (0)