Skip to content

Commit

Permalink
fix(icon-build-helpers): support glyph-only assets
Browse files Browse the repository at this point in the history
  • Loading branch information
emyarod committed May 20, 2021
1 parent 5e7720a commit 4d7f546
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
7 changes: 4 additions & 3 deletions packages/icon-build-helpers/src/builders/react/next.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 4d7f546

Please sign in to comment.