From 4d7f546bfa7d85768efc41441f34f430d84312cd Mon Sep 17 00:00:00 2001 From: emyarod Date: Thu, 20 May 2021 13:36:11 -0500 Subject: [PATCH] fix(icon-build-helpers): support glyph-only assets --- packages/icon-build-helpers/src/builders/react/next.js | 7 ++++--- .../src/metadata/extensions/output/index.js | 6 +++--- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/packages/icon-build-helpers/src/builders/react/next.js b/packages/icon-build-helpers/src/builders/react/next.js index 05f98174255a..5e9a5c7c454a 100644 --- a/packages/icon-build-helpers/src/builders/react/next.js +++ b/packages/icon-build-helpers/src/builders/react/next.js @@ -303,9 +303,10 @@ function createIconSource(moduleName, sizes, preamble = []) { }); // The "default" icon that will be rendered, based on the max size - const returnStatement = sizeVariants.find(({ size }) => { - return size === maxSize; - }); + const returnStatement = + sizeVariants.find(({ size }) => { + return size === maxSize; + }) ?? sizeVariants[0]; // We build up our component source by adding in any necessary deprecation // blocks along with conditionally rendering all asset sizes. We also use a diff --git a/packages/icon-build-helpers/src/metadata/extensions/output/index.js b/packages/icon-build-helpers/src/metadata/extensions/output/index.js index 45c1f695171d..a12c968a5ff5 100644 --- a/packages/icon-build-helpers/src/metadata/extensions/output/index.js +++ b/packages/icon-build-helpers/src/metadata/extensions/output/index.js @@ -61,9 +61,9 @@ const output = (options = defaultOptions) => { // If the target is not set to pictograms, then we're building up // metadata for icons - const defaultAsset = icon.assets.find( - (asset) => asset.size === defaultSize - ); + const defaultAsset = + icon.assets.find((asset) => asset.size === defaultSize) ?? + icon.assets[0]; icon.output = await Promise.all( sizes.map(async (size) => { const asset = icon.assets.find((asset) => asset.size === size);