Skip to content

fix(icons): generate static icons from resource SVGs (no font transforms)#8036

Open
ggdouglas wants to merge 8 commits intodevelopfrom
gd/icons-static-components-from-resources
Open

fix(icons): generate static icons from resource SVGs (no font transforms)#8036
ggdouglas wants to merge 8 commits intodevelopfrom
gd/icons-static-components-from-resources

Conversation

@ggdouglas
Copy link
Copy Markdown
Contributor

@ggdouglas ggdouglas commented Apr 8, 2026

Fixes #6329
Fixes #7558

Summary

  • Generate static @blueprintjs/icons components from the same optimized paths as generate-icon-paths.mjs / <Icon />, instead of font glyph d + scale/translate transforms.
  • Add extractPathsFromResourceSvg.mjs shared by path modules and icon component generation; fix path extraction to use d="..." capture (no stray quote in d).
  • Write path kit exports with JSON.stringify per path for safe escaping.

Fixes visual mismatch / clipping issues discussed in #7558 / #6329; aligns with resource cleanup in #7826.

Before

Left and bottom edges of static icons are clipped

before

After

Clipping is fixed

after

@changelog-app
Copy link
Copy Markdown

changelog-app bot commented Apr 8, 2026

Generate changelog in packages/icons/changelog/@unreleased

Type (Select exactly one)

  • Feature (Adding new functionality)
  • Improvement (Improving existing functionality)
  • Fix (Fixing an issue with existing functionality)
  • Break (Creating a new major version by breaking public APIs)
  • Deprecation (Removing functionality in a non-breaking way)
  • Migration (Automatically moving data/functionality to a new system)

Description

fix(icons): generate static icons from resource SVGs (no font transforms)

Check the box to generate changelog(s)

  • Generate changelog entry

@ggdouglas ggdouglas force-pushed the gd/icons-static-components-from-resources branch from b1601eb to e9443e7 Compare April 8, 2026 02:25
@blueprint-previews
Copy link
Copy Markdown

fix(icons): build static icon components from resource SVG paths

Build artifact links for this commit: documentation | landing | table | demo | storybook

This is an automated comment from the deploy-preview CircleCI job.

@ggdouglas ggdouglas force-pushed the gd/icons-static-components-from-resources branch from e9443e7 to 16affa0 Compare April 9, 2026 13:55
@ggdouglas ggdouglas marked this pull request as ready for review April 9, 2026 13:56
Copilot AI review requested due to automatic review settings April 9, 2026 13:56
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Generates static @blueprintjs/icons React components directly from optimized resource SVG path data (matching core <Icon />), removing reliance on icon font glyph transforms to fix clipping/visual mismatches.

Changes:

  • Switch icon component generation to use extracted <path d="..."> data from resources/icons/ for 16px/20px grids.
  • Add shared extractPathsFromResourceSvg.mjs and reuse it in both path-module and component generation.
  • Escape/serialize generated path exports more safely via JSON.stringify.

Reviewed changes

Copilot reviewed 5 out of 6 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
packages/icons/scripts/iconComponent.tsx.hbs Renders multiple <path> elements from precomputed path arrays instead of transformed font glyphs.
packages/icons/scripts/generate-icon-paths.mjs Reuses shared extraction helper and safely serializes exported path strings.
packages/icons/scripts/generate-icon-components.mjs Generates components from resource SVG paths (16/20) and removes SVG font parsing.
packages/icons/scripts/extractPathsFromResourceSvg.mjs New shared helper to optimize SVGs and extract d attributes from <path> elements.
packages/icons/package.json Removes svg-parser devDependency no longer needed.
Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@blueprint-previews
Copy link
Copy Markdown

Tighten regex to match only path elements specifically

Build artifact links for this commit: documentation | landing | table | demo | storybook

This is an automated comment from the deploy-preview CircleCI job.

@changelog-app
Copy link
Copy Markdown

changelog-app bot commented Apr 9, 2026

Successfully generated changelog entry!

Need to regenerate?

Simply interact with the changelog bot comment again to regenerate these entries.


📋Changelog Preview

🐛 Fixes

  • fix(icons): generate static icons from resource SVGs (no font transforms) (#8036)

@blueprint-previews
Copy link
Copy Markdown

Merge branch 'develop' into gd/icons-static-components-from-resources

Build artifact links for this commit: documentation | landing | table | demo | storybook

This is an automated comment from the deploy-preview CircleCI job.

Copy link
Copy Markdown
Contributor

@mm-wang mm-wang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small suggestions, main thing I would prefer is some level of parallelization of the icon paths extraction. Open to discussing the error failing.

* @param {string} iconName
* @returns {Promise<string[]>}
*/
export async function extractPathsFromResourceSvg(iconSize, iconName) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thought: TODO comment on moving to a different file structure here? Just don't want to forget what we're moving toward.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

moving to a different file structure

Not 100% sure what you mean. Are you referring to switching these to TypeScript? Or something else?

let paths16;
let paths20;
try {
paths16 = await extractPathsFromResourceSvg(16, iconName);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: Can we use a promise all for 16/20 to parallelize?

I'm also a bit unsure about throwing the errors at this point - it will break on the first icon being unable to extract, but won't necessarily catch all issues with the icons. Might be nice to gather them and note the errors later.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea! I’m going to keep this fail-fast for now; generation should halt on the first broken icon. f40b918

@ggdouglas ggdouglas requested a review from mm-wang April 10, 2026 13:48
@blueprint-previews
Copy link
Copy Markdown

Parallelize path extraction in generator

Build artifact links for this commit: documentation | landing | table | demo | storybook

This is an automated comment from the deploy-preview CircleCI job.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Icons: Static vs Dynamic Icons Render Differently Icon edges cut (by transforms?)

3 participants