Skip to content

Commit

Permalink
feat: use local icons
Browse files Browse the repository at this point in the history
  • Loading branch information
jmfrancois committed Oct 18, 2023
1 parent 2c0bd32 commit 8fff161
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 32 deletions.
5 changes: 5 additions & 0 deletions .changeset/unlucky-cats-fold.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@talend/scripts-config-storybook-lib': minor
---

feat: use icons from talend/icons and not from unpkg
30 changes: 0 additions & 30 deletions packages/icons/.storybook/main.js
Original file line number Diff line number Diff line change
@@ -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;
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down

0 comments on commit 8fff161

Please sign in to comment.