chore: migrate IconSize to shared union type (ADR-0003 + ADR-0004)#1048
Draft
georgewrmarshall wants to merge 1 commit intomainfrom
Draft
chore: migrate IconSize to shared union type (ADR-0003 + ADR-0004)#1048georgewrmarshall wants to merge 1 commit intomainfrom
georgewrmarshall wants to merge 1 commit intomainfrom
Conversation
Contributor
📖 Storybook Preview |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Migrates
IconSizefrom platform-specific definitions to a shared const object in@metamask/design-system-shared, following ADR-0003 (string unions) and ADR-0004 (centralized types).Why:
IconSizedefinitions — React used semantic tokens ('xs'/'sm'/'md'/'lg'/'xl'), while React Native used pixel strings ('12'/'16'/'20'/'24'/'32'). This PR unifies them using the semantic token approach.What changed:
IconSizeconst object (semantic tokensxs/sm/md/lg/xl) to@metamask/design-system-sharedsize?: stringto sharedIconPropsSharedtypeIconSizedefinitions from bothsrc/types/index.tsfilesIcon/index.tsfiles now exportIconSizedirectly from@metamask/design-system-sharedIcon.tsxto use aTWCLASSMAP_ICON_SIZE_DIMENSIONclass map (same pattern as React) instead of arbitraryw-[${size}px]template interpolationIcon.constants.tsin RN package (mirrors existing React pattern)BannerAlertin both platforms to importIconSizefrom'../Icon'instead of'../../types'AvatarIcon.test.tsxsize assertions to use the class mapRelated issues
Fixes:
Manual testing steps
yarn build— should complete without TypeScript errorsyarn test— all 499 React + 811 RN tests should passyarn lint— should pass cleanScreenshots/Recordings
Before
After
Pre-merge author checklist
Pre-merge reviewer checklist
Note
Medium Risk
Medium risk because it changes exported icon sizing/types across both React and React Native and updates how RN icons compute width/height, which could cause subtle styling or downstream type breakages.
Overview
Unifies
IconSizeacross React and React Native by moving it to@metamask/design-system-sharedas a string-union style token (xs/sm/md/lg/xl), removing the platform-specificIconSizedefinitions from both packages’typesexports.Refactors icon sizing to use a shared class map: RN
Iconnow derives dimensions from a newTWCLASSMAP_ICON_SIZE_DIMENSION(mirroring React) instead of interpolating pixel-based tailwind classes, and related consumers/tests (AvatarIcon,BannerAlert, stories/tests) are updated to importIconSizefrom../Iconand assert against the new mapping.Adds shared icon types in
design-system-shared(IconColor,IconName,IconSize,IconPropsShared) and updates platformIconPropsto extendIconPropsShared.Reviewed by Cursor Bugbot for commit 68ba9dc. Bugbot is set up for automated code reviews on this repo. Configure here.