Skip to content

feat(DSYS-489): Migrate Text to ADR-0003 and ADR-0004#1047

Draft
cursor[bot] wants to merge 13 commits intomainfrom
cursor/enum-shared-type-migration-1f3a
Draft

feat(DSYS-489): Migrate Text to ADR-0003 and ADR-0004#1047
cursor[bot] wants to merge 13 commits intomainfrom
cursor/enum-shared-type-migration-1f3a

Conversation

@cursor
Copy link
Copy Markdown
Contributor

@cursor cursor bot commented Apr 7, 2026

Description

This PR migrates the Text component to align with ADR-0003 (String Unions) and ADR-0004 (Centralized Types Architecture) as part of epic DSYS-468.

Changes

New shared types (@metamask/design-system-shared)

  • TextVariant — converted from duplicated enum TextVariant in both platform packages to a single const object with string union type (ADR-0003). Values are identical across React and React Native.
  • TextColor — new shared const object containing all common color values across both platforms (ADR-0003). React extends this with hover states (PrimaryDefaultHover, ErrorDefaultHover, SuccessDefaultHover, WarningDefaultHover) and Inherit. React Native extends with PrimaryAlternative.
  • TextPropsShared — new shared props type (ADR-0004) containing cross-platform Text props: variant, children, and color (typed as string to allow platform-specific extensions).

Updated platform packages (design-system-react and design-system-react-native)

  • Removed enum TextVariant from both src/types/index.ts — now re-exported from shared
  • Removed enum TextColor from both src/types/index.ts — replaced with platform-extended const objects
  • Removed enum FontWeight, enum FontFamily, enum FontStyle from both src/types/index.ts — converted to const objects (platform-specific values preserved)
  • Removed enum TextAlign, enum OverflowWrap, enum TextTransform from React src/types/index.ts — converted to const objects (React/Tailwind-specific)
  • Text.types.ts in both packages now extends TextPropsShared from shared
  • Text/index.ts in both packages exports TextVariant and TextPropsShared from shared

Platform differences preserved

  • FontWeight: React uses Tailwind classes (font-bold, font-medium, font-regular); RN uses numeric values (600, 500, 400)
  • FontFamily: React uses Tailwind classes (font-default, font-accent, font-hero); RN uses plain names (default, accent, hero)
  • FontStyle: React uses Tailwind values (italic, not-italic); RN uses CSS values (italic, normal)
  • TextAlign, OverflowWrap, TextTransform: React-only (Tailwind-specific)

Related issues

Fixes: DSYS-489

Manual testing steps

  1. Run yarn build — all packages build successfully
  2. Run yarn test — all tests pass with 100% coverage on changed components
  3. Verify TextVariant is importable from @metamask/design-system-shared
  4. Verify TextColor is importable from @metamask/design-system-shared
  5. Verify TextPropsShared is importable from @metamask/design-system-shared

Screenshots/Recordings

Before

TextVariant and TextColor were duplicated enums in both design-system-react and design-system-react-native src/types/index.ts. FontWeight, FontFamily, FontStyle etc. were also enums.

After

TextVariant and TextColor (common subset) are shared const objects in @metamask/design-system-shared. Platform packages extend TextColor with their platform-specific values. All other Text-related enums converted to const objects.

Text component in storybook works as expected and no visual regressions picked up in Chromatic run

text.migration.after.720.mov
Screenshot 2026-04-07 at 3 57 11 PM

Pre-merge author checklist

  • I've followed MetaMask Contributor Docs
  • I've completed the PR template to the best of my ability
  • I've included tests if applicable
  • I've documented my code using JSDoc format if applicable
  • I've applied the right labels on the PR (see labeling guidelines). Not required for external contributors.

Pre-merge reviewer checklist

  • I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed).
  • I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots.
Open in Web View Automation 

Note

Medium Risk
Medium risk because it changes exported Text* types (enums → const string-union objects) and updates many imports across React/React Native, which can cause downstream type/runtime mismatches if any consumers relied on old enum values or CSS class names.

Overview
Migrates Text typing to centralized shared types by introducing FontWeight, FontStyle, FontFamily, TextVariant, TextColor, and TextPropsShared in @metamask/design-system-shared, and updating both React and React Native components/tests/stories to import these directly.

On web, Text now maps shared semantic font props to platform-specific Tailwind classes via new MAP_FONT* helpers, and React src/types removes the old Text* enums (converting TextAlign/OverflowWrap/TextTransform to const+union types). Storybook Tailwind scanning is expanded to include design-system-shared, and internal docs add guidance to import shared types from the shared package to avoid circular deps.

Reviewed by Cursor Bugbot for commit 71b6ea1. Bugbot is set up for automated code reviews on this repo. Configure here.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 7, 2026

📖 Storybook Preview

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 7, 2026

📖 Storybook Preview

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 7, 2026

📖 Storybook Preview

@georgewrmarshall georgewrmarshall force-pushed the cursor/enum-shared-type-migration-1f3a branch from b23ac6d to 25b28ad Compare April 7, 2026 21:46
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 7, 2026

📖 Storybook Preview

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 7, 2026

📖 Storybook Preview

Copy link
Copy Markdown
Contributor Author

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

There are 2 total unresolved issues (including 1 from previous review).

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit ebc9dd5. Configure here.

cursoragent and others added 10 commits April 7, 2026 16:02
- Add TextVariant const object to shared (identical across React and RN)
- Add TextColor const object to shared (common colors across platforms)
- Add TextPropsShared to shared (variant, children, color)
- React: TextColor extends shared + adds hover states (PrimaryDefaultHover,
  ErrorDefaultHover, SuccessDefaultHover, WarningDefaultHover) and Inherit
- RN: TextColor extends shared + adds PrimaryAlternative
- FontWeight, FontFamily, FontStyle remain platform-specific (different values)
- TextAlign, OverflowWrap, TextTransform are React-only (Tailwind-specific)
- Platform enums converted to const objects in types/index.ts
- Text.types.ts in both packages now extends TextPropsShared
- Component index.ts exports TextVariant/TextPropsShared from shared

DSYS-489

Co-authored-by: George Marshall <georgewrmarshall@users.noreply.github.com>
…ypes

- Add FontWeight, FontFamily, FontStyle const objects and types to design-system-shared with semantic values
- Remove platform-specific FontWeight/FontFamily/FontStyle from both platform types/index.ts
- Add MAP_FONTWEIGHT_CLASS, MAP_FONTFAMILY_CLASS, MAP_FONTSTYLE_CLASS constants to React Web Text component
- Update React Web Text.tsx to use mapping constants for Tailwind class resolution
- Update React Native Text.constants.ts to use explicit FontWeight values instead of design token casts
- Export Font* types directly from shared in both platform Text/index.ts files
- Update React Web Text tests to assert mapped CSS classes
…types/index.ts

Move TextVariant, TextColor, FontWeight, FontStyle, FontFamily imports
from ../../types to @metamask/design-system-shared across all consumer
files in both React and React Native packages. Remove the re-export stubs
from both platform types/index.ts files.
TextColor const values (e.g. 'text-primary-default-hover') are now defined
in @metamask/design-system-shared rather than design-system-react/src/types.
Add the shared package to the Storybook Tailwind content paths so JIT
generates CSS for all color literal strings found in the shared source.
@georgewrmarshall georgewrmarshall self-assigned this Apr 7, 2026
@georgewrmarshall georgewrmarshall force-pushed the cursor/enum-shared-type-migration-1f3a branch from 116713a to dff9dce Compare April 7, 2026 23:03
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 7, 2026

📖 Storybook Preview

@georgewrmarshall
Copy link
Copy Markdown
Contributor

@metamaskbot publish-preview

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 7, 2026

Preview builds have been published. See these instructions for more information about preview builds.

Expand for full list of packages and versions.
{
  "@metamask-previews/design-system-react": "0.14.0-preview.dff9dce",
  "@metamask-previews/design-system-react-native": "0.14.0-preview.dff9dce",
  "@metamask-previews/design-system-shared": "0.7.0-preview.dff9dce",
  "@metamask-previews/design-system-tailwind-preset": "0.6.1-preview.dff9dce",
  "@metamask-previews/design-system-twrnc-preset": "0.4.1-preview.dff9dce",
  "@metamask-previews/design-tokens": "8.3.0-preview.dff9dce"
}

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 7, 2026

📖 Storybook Preview

Comment on lines +14 to +31
/**
* Optional prop to control the font weight of the text.
* Normal: 400
* Medium: 500
* Bold: 600
*/
fontWeight?: FontWeight;
/**
* Optional prop to adjust the font family.
* Default: Geist
* Accent: MM Sans
* Hero: MM Poly
*/
fontFamily?: FontFamily;
/**
* Optional prop to adjust the style of the font.
*/
fontStyle?: FontStyle;
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.

Should be able to move these into TextPropsShared

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants