feat(DSYS-489): Migrate Text to ADR-0003 and ADR-0004#1047
Draft
cursor[bot] wants to merge 13 commits intomainfrom
Draft
feat(DSYS-489): Migrate Text to ADR-0003 and ADR-0004#1047cursor[bot] wants to merge 13 commits intomainfrom
cursor[bot] wants to merge 13 commits intomainfrom
Conversation
Contributor
📖 Storybook Preview |
Contributor
📖 Storybook Preview |
Contributor
📖 Storybook Preview |
b23ac6d to
25b28ad
Compare
Contributor
📖 Storybook Preview |
Contributor
📖 Storybook Preview |
Contributor
Author
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
There are 2 total unresolved issues (including 1 from previous review).
❌ 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.
packages/design-system-react-native/src/components/HeaderRoot/HeaderRoot.stories.tsx
Outdated
Show resolved
Hide resolved
- 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.
116713a to
dff9dce
Compare
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. |
Contributor
📖 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; |
Contributor
There was a problem hiding this comment.
Should be able to move these into TextPropsShared
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
This PR migrates the
Textcomponent 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 duplicatedenum TextVariantin both platform packages to a singleconstobject with string union type (ADR-0003). Values are identical across React and React Native.TextColor— new sharedconstobject containing all common color values across both platforms (ADR-0003). React extends this with hover states (PrimaryDefaultHover,ErrorDefaultHover,SuccessDefaultHover,WarningDefaultHover) andInherit. React Native extends withPrimaryAlternative.TextPropsShared— new shared props type (ADR-0004) containing cross-platform Text props:variant,children, andcolor(typed asstringto allow platform-specific extensions).Updated platform packages (
design-system-reactanddesign-system-react-native)enum TextVariantfrom bothsrc/types/index.ts— now re-exported from sharedenum TextColorfrom bothsrc/types/index.ts— replaced with platform-extended const objectsenum FontWeight,enum FontFamily,enum FontStylefrom bothsrc/types/index.ts— converted to const objects (platform-specific values preserved)enum TextAlign,enum OverflowWrap,enum TextTransformfrom Reactsrc/types/index.ts— converted to const objects (React/Tailwind-specific)Text.types.tsin both packages now extendsTextPropsSharedfrom sharedText/index.tsin both packages exportsTextVariantandTextPropsSharedfrom sharedPlatform 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
yarn build— all packages build successfullyyarn test— all tests pass with 100% coverage on changed componentsTextVariantis importable from@metamask/design-system-sharedTextColoris importable from@metamask/design-system-sharedTextPropsSharedis importable from@metamask/design-system-sharedScreenshots/Recordings
Before
TextVariantandTextColorwere duplicatedenums in bothdesign-system-reactanddesign-system-react-nativesrc/types/index.ts.FontWeight,FontFamily,FontStyleetc. were also enums.After
TextVariantandTextColor(common subset) are sharedconstobjects in@metamask/design-system-shared. Platform packages extendTextColorwith their platform-specific values. All other Text-related enums converted toconstobjects.Text component in storybook works as expected and no visual regressions picked up in Chromatic run
text.migration.after.720.mov
Pre-merge author checklist
Pre-merge reviewer checklist
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
Texttyping to centralized shared types by introducingFontWeight,FontStyle,FontFamily,TextVariant,TextColor, andTextPropsSharedin@metamask/design-system-shared, and updating both React and React Native components/tests/stories to import these directly.On web,
Textnow maps shared semantic font props to platform-specific Tailwind classes via newMAP_FONT*helpers, and Reactsrc/typesremoves the oldText*enums (convertingTextAlign/OverflowWrap/TextTransformto const+union types). Storybook Tailwind scanning is expanded to includedesign-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.