Skip to content

Commit 8ddd8c3

Browse files
committed
Merge remote-tracking branch 'origin/main' into fix/APP-4280
2 parents 72bc3d6 + a28f933 commit 8ddd8c3

136 files changed

Lines changed: 1818 additions & 2105 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.

.changeset/green-clubs-check.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@aragon/gov-ui-kit': minor
3+
---
4+
5+
Update Storybook to v9

.changeset/slimy-taxis-press.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@aragon/gov-ui-kit': minor
3+
---
4+
5+
Update minor and patch NPM dependencies

.storybook/components/docsPage/docsPage.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Controls, Description, Primary, Stories, Subtitle, Title } from '@storybook/blocks';
1+
import { Controls, Description, Primary, Stories, Subtitle, Title } from '@storybook/addon-docs/blocks';
22
import { StyleBlock } from '../styleBlock';
33

44
export const DocsPage: React.FC = () => {

.storybook/components/styleBlock/styleBlock.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Subheading, useOf } from '@storybook/blocks';
1+
import { Subheading, useOf } from '@storybook/addon-docs/blocks';
22

33
export interface ICustomisationDoc {
44
/**

.storybook/main.ts

Lines changed: 31 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,15 @@
1-
import type { StorybookConfig } from '@storybook/react-webpack5';
2-
import type { RuleSetRule } from 'webpack';
1+
import type { StorybookConfig } from '@storybook/react-vite';
2+
import type { RollupOptions } from 'rollup';
3+
import { mergeConfig } from 'vite';
4+
import { nodePolyfills } from 'vite-plugin-node-polyfills';
5+
import { viteStaticCopy } from 'vite-plugin-static-copy';
6+
import svgr from 'vite-plugin-svgr';
37

48
const config: StorybookConfig = {
59
stories: ['../docs/**/*.@(md|mdx)', '../src/**/*.stories.@(js|jsx|ts|tsx)', '../src/**/*.@(md|mdx)'],
610

7-
addons: [
8-
'@storybook/addon-links',
9-
'@storybook/addon-essentials',
10-
{
11-
name: '@storybook/addon-styling-webpack',
12-
options: {
13-
rules: [
14-
// Replaces existing CSS rules to support PostCSS
15-
{
16-
test: /\.css$/,
17-
use: [
18-
'style-loader',
19-
{
20-
loader: 'css-loader',
21-
options: { importLoaders: 1 },
22-
},
23-
{
24-
// Gets options from `postcss.config.js`
25-
loader: 'postcss-loader',
26-
options: { implementation: require.resolve('postcss') },
27-
},
28-
],
29-
},
30-
],
31-
},
32-
},
33-
'@storybook/addon-webpack5-compiler-babel',
34-
],
35-
3611
framework: {
37-
name: '@storybook/react-webpack5',
12+
name: '@storybook/react-vite',
3813
options: {},
3914
},
4015

@@ -43,41 +18,32 @@ const config: StorybookConfig = {
4318
reactDocgen: 'react-docgen-typescript',
4419
},
4520

46-
webpackFinal: (webpackConfig) => {
47-
// Remove any svg loader already set and use @svgr/webpack to load svgs on Storybook
48-
const svgWebpackRule = webpackConfig.module?.rules?.find((rule) => {
49-
if (rule != null && typeof rule !== 'string' && (rule as RuleSetRule).test instanceof RegExp) {
50-
const testRegExp = (rule as RuleSetRule).test as RegExp;
51-
return testRegExp.test('.svg');
52-
}
53-
54-
return undefined;
55-
});
56-
57-
if (typeof svgWebpackRule !== 'string') {
58-
(svgWebpackRule as RuleSetRule).exclude = /\.svg$/;
59-
}
60-
61-
webpackConfig.module?.rules?.push({
62-
test: /\.svg$/,
63-
use: ['@svgr/webpack'],
64-
});
65-
66-
// Retrieve and update css rule to support raw imports of CSS files using "?raw"
67-
const cssRule = webpackConfig.module?.rules?.find((rule) => {
68-
if (rule != null && typeof rule !== 'string' && (rule as RuleSetRule).test instanceof RegExp) {
69-
const testRegExp = (rule as RuleSetRule).test as RegExp;
70-
return testRegExp.test('.css');
71-
}
72-
73-
return undefined;
74-
});
21+
addons: ['@storybook/addon-docs'],
22+
23+
viteFinal: (viteConfig) => {
24+
// Add polyfills for path, url and source-map-js node modules and plugin for importing svg files
25+
const plugins = [
26+
nodePolyfills({ include: ['path', 'url'] }),
27+
svgr({ include: '**/*.svg' }),
28+
viteStaticCopy({ targets: [{ src: './src/theme/fonts/*.ttf', dest: './fonts' }] }),
29+
];
30+
const resolve = { alias: { 'source-map-js': 'source-map' } };
31+
32+
const rollupOptions: RollupOptions = {
33+
// Externalize font assets (see https://github.com/storybookjs/storybook/pull/27110)
34+
external: [/.*\.ttf/],
35+
// Silence "use client" directive and "/* PURE */" comment warnings during Storybook build
36+
onwarn: (warning, warn) => {
37+
if (['MODULE_LEVEL_DIRECTIVE', 'INVALID_ANNOTATION'].includes(warning.code ?? '')) {
38+
return;
39+
}
40+
warn(warning);
41+
},
42+
};
7543

76-
if (cssRule) {
77-
(cssRule as RuleSetRule).resourceQuery = { not: [/raw/] };
78-
}
44+
const finalConfigs = mergeConfig(viteConfig, { plugins, resolve, build: { rollupOptions } });
7945

80-
return webpackConfig;
46+
return finalConfigs;
8147
},
8248
};
8349

.storybook/manager.ts

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

44
addons.setConfig({

.storybook/preview.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { Preview } from '@storybook/react';
1+
import type { Preview } from '@storybook/react-vite';
22
import '../index.css';
33
import { GukModulesProvider } from '../src/modules';
44
import { DocsPage } from './components';
@@ -52,6 +52,14 @@ const preview: Preview = {
5252
],
5353

5454
tags: ['autodocs'],
55+
56+
// Needed to fix warning on HMR reload (see https://github.com/storybookjs/storybook-addon-pseudo-states/issues/59)
57+
globalTypes: {
58+
measureEnabled: {},
59+
backgrounds: {},
60+
outline: {},
61+
viewport: {},
62+
},
5563
};
5664

5765
export default preview;

.storybook/theme.ts

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

33
export default create({
44
base: 'light',

docs/changelog.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import Changelog from '../CHANGELOG.md?raw';
2-
import { Meta, Markdown } from '@storybook/blocks';
2+
import { Meta, Markdown } from '@storybook/addon-docs/blocks';
33

44
<Meta title="Docs/Changelog" />
55

docs/codingGuidelines/libraryDependencies.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Meta } from '@storybook/blocks';
1+
import { Meta } from '@storybook/addon-docs/blocks';
22

33
<Meta title="Docs/Coding Guidelines/Library Dependencies" />
44

0 commit comments

Comments
 (0)