Skip to content

chore(icons): add workflow icons generator - #6572

Closed
cdransf wants to merge 1 commit into
cdransf/2nd-gen-icon-repointfrom
cdransf/2nd-gen-icon-public-workflow
Closed

chore(icons): add workflow icons generator#6572
cdransf wants to merge 1 commit into
cdransf/2nd-gen-icon-repointfrom
cdransf/2nd-gen-icon-public-workflow

Conversation

@cdransf

@cdransf cdransf commented Aug 3, 2026

Copy link
Copy Markdown
Member

Description

Adds scripts/generate-workflow-icons.mjs: converts A4U workflow SVGs into a per-icon function (StarIcon(): string) and a per-icon element (<swc-icon-star> extending IconBase), reusing Phase 0's shared icon-source/utils/. Staged in swc/components/workflow-icons/ for now; packaging into @adobe/spectrum-wc-icons is Phase 4. Filename regex (S2_Icon_<Name>_20_N.svg) is derived from a public sibling repo's manifest, not a confirmed real A4U sample, flagged as such in the file header. Validated against synthetic fixtures only; no real icon art is included or committed.

Motivation and context

Implements Phase 3 of the icon RFC (SWC-2442): public workflow icons as a Lit-free function plus a custom element.

Related issue(s)

  • Jira: SWC-2442
  • Depends on SWC-2439 (Phase 2 gate) · feeds SWC-2441 (Phase 4 packaging)

Screenshots (if appropriate)

N/A — build script only, no UI.

Author's checklist

  • I have read the CONTRIBUTING and PULL_REQUESTS documents.
  • I have reviewed the Accessibility Practices for this feature.
  • I have added automated tests to cover my changes.
  • I have included a well-written changeset if my change needs to be published.
  • I have included updated documentation if my change required it.

Reviewer's checklist

  • Includes a Github Issue with appropriate flag or Jira ticket number without a link
  • Includes thoughtfully written changeset if changes suggested include patch, minor, or major features
  • Automated tests cover all use cases and follow best practices for writing
  • Validated on all supported browsers
  • All VRTs are approved before the author can update Golden Hash

Manual review test cases

  • Drop a fixture SVG (S2_Icon_Star_20_N.svg, --iconPrimary fill) into icon-source/workflow/, run yarn generate:workflow-icons, confirm both output files are generated, fill is rewritten to var(--swc-icon-color, currentColor), and lint/prettier pass. Delete the fixture and output after.
  • Confirm running with an empty icon-source/workflow/ throws instead of deleting anything.

Device review

  • Did it pass in Desktop?
  • Did it pass in (emulated) Mobile?
  • Did it pass in (emulated) iPad?

Accessibility testing checklist

  • Keyboard: N/A, no UI in this PR.
  • Screen reader: N/A, no UI in this PR. Generated elements extend IconBase (existing, already-tested a11y contract: decorative by default, role="img" + aria-label when accessible-label is set); no new behavior introduced.

@cdransf cdransf self-assigned this Aug 3, 2026
@cdransf cdransf added the Spectrum 2 Issues related to Spectrum 2 label Aug 3, 2026
@changeset-bot

changeset-bot Bot commented Aug 3, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: c350f1c

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@github-actions

github-actions Bot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

📚 Branch Preview Links

🔍 Gen1 Visual Regression Test Results

When a visual regression test fails (or has previously failed while working on this branch), its results can be found in the following URLs:

Deployed to Azure Blob Storage: pr-6572

If the changes are expected, update the current_golden_images_cache hash in the circleci config to accept the new images. Instructions are included in that file.
If the changes are unexpected, you can investigate the cause of the differences and update the code accordingly.

@cdransf
cdransf force-pushed the cdransf/2nd-gen-icon-public-workflow branch 2 times, most recently from 9f272c0 to 5f7a3ac Compare August 3, 2026 20:35
@cdransf
cdransf marked this pull request as ready for review August 3, 2026 20:50
@cdransf
cdransf requested a review from a team as a code owner August 3, 2026 20:50
@cdransf
cdransf requested a review from caseyisonit August 3, 2026 21:18
@cdransf
cdransf force-pushed the cdransf/2nd-gen-icon-public-workflow branch from d68ef6c to 5f7a3ac Compare August 4, 2026 17:38
@cdransf
cdransf force-pushed the cdransf/2nd-gen-icon-repoint branch from fcc0c51 to 64a3740 Compare August 4, 2026 17:40
@cdransf
cdransf force-pushed the cdransf/2nd-gen-icon-public-workflow branch from 5f7a3ac to 0ffc6bf Compare August 4, 2026 17:40
@cdransf
cdransf force-pushed the cdransf/2nd-gen-icon-repoint branch from 64a3740 to faf07d0 Compare August 5, 2026 19:01
@cdransf
cdransf force-pushed the cdransf/2nd-gen-icon-public-workflow branch from 0ffc6bf to 7ecaa90 Compare August 5, 2026 19:01
@cdransf
cdransf force-pushed the cdransf/2nd-gen-icon-repoint branch from faf07d0 to e21e74a Compare August 6, 2026 17:28
@cdransf
cdransf force-pushed the cdransf/2nd-gen-icon-public-workflow branch from 7ecaa90 to 1f31550 Compare August 6, 2026 17:28
@cdransf
cdransf force-pushed the cdransf/2nd-gen-icon-repoint branch from e21e74a to 8bf9cbe Compare August 10, 2026 15:13
@cdransf
cdransf force-pushed the cdransf/2nd-gen-icon-public-workflow branch from 1f31550 to a35a1a1 Compare August 10, 2026 15:13
@cdransf
cdransf force-pushed the cdransf/2nd-gen-icon-repoint branch from 8bf9cbe to 6085381 Compare August 10, 2026 22:45
@cdransf
cdransf force-pushed the cdransf/2nd-gen-icon-public-workflow branch from a35a1a1 to c350f1c Compare August 10, 2026 22:45
@cdransf cdransf added the Status:Ready for review PR ready for review or re-review. label Aug 10, 2026

@Rajdeepc Rajdeepc left a comment

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.

Considering the real workflow set of 1096 icons, this emits 2192 modules. vite.config.ts's components/*/swc-*.ts glob would turn 1096 of them into rollup entries against the current 51; cem.config.js globs components/**/*.ts and yarn analyze runs ahead of every storybook and storybook:build; dist/custom-elements.json is already 869K and is a published export; and the npm script prettiers all 2192 on each run.
None of these needs solving in this PR, but it is the main input to packaging decision, so it'd be good to have the numbers written down before that phase starts rather than during it.

I don't see an automated tests here and the input grammar is unverified and this script is checking out by design so this will not execute in CI.

I will hold off this merge on the comments here and also on #6567 which has an open thread on close-button cross art.

// Refuse to run without source SVGs. The source folder is git-ignored, so on a clean
// checkout this would otherwise delete the committed workflow icon art and write
// nothing, breaking every consumer.
if (files.length === 0) {

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.

This throws when no source files exist, but the wipe at line 104 keys off names, which is only populated after SOURCE_NAME matches. So if the real A4U filenames don't match the inferred grammar, the sequence is: guard passes (files exist) → every file hits the console.warn skip → names is empty → every .ts in components/workflow-icons/ is deleted → nothing is written → exit code 0.
Please put that after the parse loop and keeping the current check too. I'd also make any skip fatal rather than a warning


protected override render(): TemplateResult {
return html\`
<span class="swc-Icon">\${unsafeSVG(${functionName}())}</span>

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.

Blocking: This reintroduces unsafeSVG, which #6552 removed as one of its stated goals, across all 1096 public elements.
I understand why but if you want the public substrate a string the generator already holds the cleaned SVG at this point, so it can emit both forms:

  • StarIcon(): string — unchanged, the public Lit-free substrate
  • a Lit svg template — internal, used by the generated element


// A4U source filename: S2_Icon_<LogicalName>_20_N.svg (one fixed-size drawing per
// icon, no optical step).
const SOURCE_NAME = /^S2_Icon_(?<name>.+?)_20_N\.svg$/;

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.

Is this verified? _20_ hardcodes a single size. That matches the RFC's workflow sizing model (one drawing scaled to a token box), but if A4U ships 20 and 24, everything else is silently skipped.
Could we get one real sample filename into the PR before we merge. I dont have anything to validate this against.

}
}

export class ${elementClassName} extends IconBase {

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.

This is missing JSDoc. Also Class and registration in one module drifts from the repo convention

// deletions in source propagate.
mkdirSync(outDir, { recursive: true });
// workflow-icons/ holds only generated modules, so clearing them all is safe.
for (const stale of globSync('*.ts', { cwd: outDir })) {

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.

Two things here:
generate-ui-icons.mjs emits an index.ts with the UI_ICONS registry and the UiIconName type. This generator emits nothing enumerable, so there's no way to list the available icons programmatically, and no name union for consumers.

Also this deletes every .ts in the output directory. Either emit the index from the generator (matching the UI one), or scope the clear to the two generated filename patterns.

@cdransf

cdransf commented Aug 11, 2026

Copy link
Copy Markdown
Member Author

Going to close this out in favor of the generator work in #6562.

@cdransf cdransf closed this Aug 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Spectrum 2 Issues related to Spectrum 2 Status:Ready for review PR ready for review or re-review.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants