From f704a338d8edc0094d4fb9f9973919f50e53883f Mon Sep 17 00:00:00 2001 From: Saad <38024451+sdadn@users.noreply.github.com> Date: Mon, 6 May 2024 06:50:33 -0500 Subject: [PATCH] updated icon scripts --- .../scripts/src/generate-example/generateStaticIcons.js | 6 +++++- .../src/generate-example/generateThemeableIcons.js | 8 +++++++- packages/terra-icon/scripts/src/icon-utils/parseCsv.js | 2 +- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/packages/terra-icon/scripts/src/generate-example/generateStaticIcons.js b/packages/terra-icon/scripts/src/generate-example/generateStaticIcons.js index 673f14a4efe..6b05e5a9e26 100644 --- a/packages/terra-icon/scripts/src/generate-example/generateStaticIcons.js +++ b/packages/terra-icon/scripts/src/generate-example/generateStaticIcons.js @@ -13,14 +13,18 @@ const generateIconAll = (iconObjs) => !iconObj.themeable && !iconObj.deprecated && !iconObj.isOldLowlight ); + staticIcons.sort((a, b) => a.componentName.localeCompare(b.componentName)); + outputfile.write( "// This file is autogenerated from scripts/src/generate-example\n" ); outputfile.write("/* eslint-disable */\n"); outputfile.write("import React from 'react';\n"); + outputfile.write("import {\n"); staticIcons.forEach((iconObj) => { - outputfile.write(iconObj.syntaxImport); + outputfile.write(` ${iconObj.componentName},\n`); }); + outputfile.write("} from 'terra-icon';\n\n"); outputfile.write("const cellStyle = { padding: '0.5rem' };\n"); outputfile.write("const IconAll = () => (\n"); outputfile.write("
"); diff --git a/packages/terra-icon/scripts/src/generate-example/generateThemeableIcons.js b/packages/terra-icon/scripts/src/generate-example/generateThemeableIcons.js index 56a06193e7e..07c87143380 100644 --- a/packages/terra-icon/scripts/src/generate-example/generateThemeableIcons.js +++ b/packages/terra-icon/scripts/src/generate-example/generateThemeableIcons.js @@ -14,14 +14,20 @@ const generateIconAll = (iconObjs) => } }); + themeableIcons.sort((a, b) => a.componentName.localeCompare(b.componentName)); + outputfile.write( "// This file is autogenerated from scripts/src/generate-example\n" ); outputfile.write("/* eslint-disable */\n"); outputfile.write("import React from 'react';\n"); + + outputfile.write("import {\n"); themeableIcons.forEach((iconObj) => { - outputfile.write(iconObj.syntaxImport); + outputfile.write(` ${iconObj.componentName},\n`); }); + outputfile.write("} from 'terra-icon';\n\n"); + outputfile.write("const cellStyle = { padding: '0.5rem' };\n"); outputfile.write("const IconAll = () => (\n"); outputfile.write("
"); diff --git a/packages/terra-icon/scripts/src/icon-utils/parseCsv.js b/packages/terra-icon/scripts/src/icon-utils/parseCsv.js index a139d18f01e..b4333952691 100644 --- a/packages/terra-icon/scripts/src/icon-utils/parseCsv.js +++ b/packages/terra-icon/scripts/src/icon-utils/parseCsv.js @@ -20,7 +20,7 @@ const parseCsv = () => new Promise((resolve) => { jsonObj.bidi = (jsonObj.bidi === 'bi-directional'); jsonObj.spinner = (jsonObj.name === 'IconSpinner'); jsonObj.syntaxComponent = `<${jsonObj.componentName} height='2em' width='2em' />`; - jsonObj.syntaxImport = `import ${jsonObj.componentName} from 'terra-icon/lib/icon/${jsonObj.componentName}';\n`; + jsonObj.syntaxImport = `import \{ ${jsonObj.componentName} \} from 'terra-icon';\n`; /* eslint-enable no-param-reassign */ }).then(jsonObj => resolve(jsonObj)); });