diff --git a/.changeset/unlucky-cats-fold.md b/.changeset/unlucky-cats-fold.md new file mode 100644 index 0000000000..d59d8aaa31 --- /dev/null +++ b/.changeset/unlucky-cats-fold.md @@ -0,0 +1,5 @@ +--- +'@talend/scripts-config-storybook-lib': minor +--- + +feat: use icons from talend/icons and not from unpkg diff --git a/packages/icons/.storybook/main.js b/packages/icons/.storybook/main.js index 6f7275f8e7..3f833890fd 100644 --- a/packages/icons/.storybook/main.js +++ b/packages/icons/.storybook/main.js @@ -1,35 +1,5 @@ -const fs = require('fs/promises'); -const path = require('path'); - module.exports = { webpackFinal: async config => { - const spriteAll = await fs.readFile(path.resolve(__dirname, '../dist/svg-bundle/all.svg'), { - encoding: 'utf8', - }); - const spriteXS = await fs.readFile(path.resolve(__dirname, '../dist/svg-bundle/XS.svg'), { - encoding: 'utf8', - }); - const spriteS = await fs.readFile(path.resolve(__dirname, '../dist/svg-bundle/S.svg'), { - encoding: 'utf8', - }); - const spriteM = await fs.readFile(path.resolve(__dirname, '../dist/svg-bundle/M.svg'), { - encoding: 'utf8', - }); - const spriteL = await fs.readFile(path.resolve(__dirname, '../dist/svg-bundle/L.svg'), { - encoding: 'utf8', - }); - config.plugins.forEach(plugin => { - if (plugin.constructor.name.includes('HtmlWebpackPlugin')) { - const htmlPlugin = plugin; - htmlPlugin.userOptions.templateParameters.bodyHtmlSnippet += spriteAll; - htmlPlugin.userOptions.templateParameters.bodyHtmlSnippet += spriteXS; - htmlPlugin.userOptions.templateParameters.bodyHtmlSnippet += spriteS; - htmlPlugin.userOptions.templateParameters.bodyHtmlSnippet += spriteM; - htmlPlugin.userOptions.templateParameters.bodyHtmlSnippet += spriteL; - return htmlPlugin; - } - return plugin; - }); return config; }, }; diff --git a/tools/scripts-config-storybook-lib/.storybook-templates/main.js b/tools/scripts-config-storybook-lib/.storybook-templates/main.js index 185f19cb1d..d7f914cd8d 100644 --- a/tools/scripts-config-storybook-lib/.storybook-templates/main.js +++ b/tools/scripts-config-storybook-lib/.storybook-templates/main.js @@ -43,7 +43,7 @@ const defaultMain = { buildStoriesJson: true, }, stories: getStoriesFolders(), - staticDirs: [path.join(__dirname, 'msw')], + staticDirs: [path.join(__dirname, 'msw'), require.resolve('@talend/icons').replace('/dist/TalendIcons.js', '/dist/svg-bundle')], addons: [ '@storybook/addon-essentials', '@storybook/addon-a11y', diff --git a/tools/scripts-config-storybook-lib/.storybook-templates/preview.js b/tools/scripts-config-storybook-lib/.storybook-templates/preview.js index 5bbd44ff39..cd38523dae 100644 --- a/tools/scripts-config-storybook-lib/.storybook-templates/preview.js +++ b/tools/scripts-config-storybook-lib/.storybook-templates/preview.js @@ -94,7 +94,14 @@ const defaultPreview = { const storyElement = React.createElement(Story, {...context, key: 'story'}); return [ React.createElement(IconsProvider, { - key: 'icons-provider-decorator' + key: 'icons-provider-decorator', + bundles: [ + '/all.svg', + '/XS.svg', + '/S.svg', + '/M.svg', + '/L.svg', + ] }), React.createElement(ToggleBootstrap, { disabled: context.globals.bootstrapTheme === 'false',