Skip to content

refactor(renderer): model chevron icon choice as a direction - #3527

Merged
setchy merged 1 commit into
mainfrom
refactor/chevron-direction
Oct 25, 2026
Merged

setchy merged 1 commit into
mainfrom
refactor/chevron-direction

Conversation

@setchy

@setchy setchy commented Oct 25, 2026

Copy link
Copy Markdown
Member

Summary

Chevron.icon was typed as FC<OcticonProps> with a TODO to restrict which icons are allowed. That restriction cannot be expressed at the field level: every @primer/octicons-react component shares the same structural Icon type, so a union of the three chevron components collapses back to Icon.

This replaces the icon component with a closed ChevronDirection ('down' | 'left' | 'right') and resolves the icon through one exhaustive registry.

  • Chevron now carries direction + label; getChevronDetails returns data instead of a component.
  • getChevronIcon in utils/ui/icons.ts owns a private Record<ChevronDirection, Icon>; adding a direction fails compilation until the map is updated.
  • AccountHeader and RepositoryHeader resolve the icon at the call site.
  • display.test.ts asserts directions; icons.test.ts asserts the direction-to-icon mapping.
  • Rendered icons, accessible labels, and snapshots are unchanged.

No behavior change; not a breaking change. OpenSpec change: refactor-chevron-direction (pure refactor, skip_specs).

Test plan

  • pnpm check
  • pnpm test — 204 files, 1,974 tests passed
  • pnpm test:visual — 11 files, 158 screenshot tests passed (Linux Playwright container)

Replace the un-narrowable FC<OcticonProps> chevron icon field with a closed direction union and resolve icons through one exhaustive registry.
@setchy
setchy requested a review from afonsojramos as a code owner October 25, 2026 20:51
@github-actions github-actions Bot added the refactor Refactoring of existing feature label Oct 25, 2026
@setchy
setchy merged commit 215bb5c into main Oct 25, 2026
14 checks passed
@setchy
setchy deleted the refactor/chevron-direction branch October 25, 2026 20:53
@github-actions github-actions Bot added this to the Release 7.11.0 milestone Oct 25, 2026
@sonarqubecloud

Copy link
Copy Markdown

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

Labels

refactor Refactoring of existing feature

Development

Successfully merging this pull request may close these issues.

1 participant