feat(shared): migrate Box to ADR-0003 and ADR-0004 shared types (DSYS-482)#1026
Draft
cursor[bot] wants to merge 1 commit intomainfrom
Draft
feat(shared): migrate Box to ADR-0003 and ADR-0004 shared types (DSYS-482)#1026cursor[bot] wants to merge 1 commit intomainfrom
cursor[bot] wants to merge 1 commit intomainfrom
Conversation
…-482)
- Create packages/design-system-shared/src/types/Box/Box.types.ts with:
- BoxFlexDirection, BoxFlexWrap, BoxAlignItems, BoxJustifyContent,
BoxBackgroundColor, BoxBorderColor converted from enums to const objects (ADR-0003)
- BoxSpacing, BoxBorderWidth type aliases (unchanged primitive types)
- BoxPropsShared new shared props type with platform-independent properties (ADR-0004)
- Export Box types from @metamask/design-system-shared index
- Update React package Box.types.ts to extend BoxPropsShared from shared
- Update React package Box/index.ts to export const objects from shared
- Update React Native package Box.types.ts to extend BoxPropsShared from shared
- Update React Native package Box/index.ts to export const objects from shared
- Remove old Box enums from both platform type indices
- Update all files importing Box types to import from @metamask/design-system-shared
Co-authored-by: George Marshall <georgewrmarshall@users.noreply.github.com>
Contributor
📖 Storybook Preview |
Contributor
|
@metamaskbot publish-preview |
Contributor
|
Preview builds have been published. See these instructions for more information about preview builds. Expand for full list of packages and versions. |
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 the
Boxcomponent to follow ADR-0003 (String Unions) and ADR-0004 (Centralized Types Architecture) as part of the DSYS-468 epic.What changed:
packages/design-system-shared/src/types/Box/Box.types.tswith:BoxFlexDirection,BoxFlexWrap,BoxAlignItems,BoxJustifyContent,BoxBackgroundColor,BoxBorderColorconverted from enums to const objects (ADR-0003)BoxSpacing,BoxBorderWidthtype aliases (unchanged — already primitive literal types)BoxPropsSharednew shared props type with all platform-independent properties (ADR-0004)@metamask/design-system-sharedindexBox.types.tsto extendBoxPropsSharedfrom sharedBox/index.tsto export const objects from shared (single source of truth)Box.types.tsto extendBoxPropsSharedfrom sharedBox/index.tsto export const objects from sharedsrc/types/index.tsfiles../../typesto import from@metamask/design-system-shared(BannerBase, BannerAlert, BoxHorizontal, BoxVertical, and various story files)All enum values are identical across React and React Native (both use Tailwind class strings), so all enums qualify for ADR-0003 migration.
Related issues
Fixes: DSYS-482
Manual testing steps
yarn buildfrom repo root — should succeedyarn testfrom repo root — all Box tests should pass with 100% coverageyarn lintfrom repo root — no new lint errorsScreenshots/Recordings
Before
BoxFlexDirection,BoxFlexWrap,BoxAlignItems,BoxJustifyContent,BoxBackgroundColor,BoxBorderColorwere enums duplicated in bothdesign-system-react/src/types/index.tsanddesign-system-react-native/src/types/index.tswith no shared source.After
All Box enums are now const objects in
@metamask/design-system-shared, with a singleBoxPropsSharedtype containing all platform-independent props. Both React and React Native packages extendBoxPropsSharedand add their platform-specific props (className/asChildfor React,twClassNamefor React Native).Pre-merge author checklist
Pre-merge reviewer checklist