Skip to content

Commit e89b851

Browse files
authored
refactor(identity): migrate deprecated component-library imports to @metamask/design-system-react (#41448)
## **Description** Migrates deprecated `Box`, `Text`, `Icon`, `IconName`, `Button`, `ButtonVariant`, and `ButtonSize` imports from the internal `ui/components/component-library` to `@metamask/design-system-react` in the accounts-team-owned identity components. **Why:** The component-library versions are all marked `@deprecated` and will be removed in a future release. This is PR 2 of a planned series to eliminate deprecated imports across all accounts-team-owned files. **Files changed (4):** - `ui/components/app/identity/backup-and-sync-toggle/backup-and-sync-toggle.tsx` - `ui/components/app/identity/backup-and-sync-features-toggles/backup-and-sync-features-toggles.tsx` - `ui/components/app/modals/identity/turn-on-backup-and-sync-modal/turn-on-backup-and-sync-modal.tsx` - `ui/components/app/modals/identity/confirm-turn-on-backup-and-sync-modal/confirm-turn-on-backup-and-sync-modal.tsx` **Key API migration notes:** - `Box`: `display={Display.Flex}` removed; `flexDirection={BoxFlexDirection.Row}` used instead (DSR Box auto-applies `display:flex` when `flexDirection` is set). `Box as="img"` converted to a plain `<img>` element (DSR Box does not support the `as` polymorphic prop). - `Text`: camelCase enum variants (`bodyMd`, `textAlternative`) updated to PascalCase (`BodyMd`, `TextAlternative`). `bodyMdMedium` replaced with `BodyMd` + `fontWeight={FontWeight.Medium}`. `as="a"` / `as="div"` usages replaced with the `asChild` pattern (Radix Slot). Spacing props on `Text` moved to a wrapping `Box`. - `Button`: import source updated; `width={BlockSize.Half}` replaced with `className="w-1/2"`. - `Modal*` components (`Modal`, `ModalOverlay`, `ModalContent`, `ModalHeader`, `ModalBody`, `ModalFooter`) remain imported from `component-library` — they are not yet available in `@metamask/design-system-react`. ## **Changelog** CHANGELOG entry: null ## **Related issues** Fixes: <!-- ## **Manual testing steps** 1. Go to this page... 2. 3. --> <!-- ## **Screenshots/Recordings** ### **Before** ### **After** --> ## **Pre-merge author checklist** - [ ] I've followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Extension Coding Standards](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/CODING_GUIDELINES.md). - [ ] 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](https://jsdoc.app/) format if applicable - [ ] I've applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/LABELING_GUIDELINES.md)). 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. Made with [Cursor](https://cursor.com) <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Low Risk** > Pure UI refactor swapping component imports and prop APIs; main risk is small visual/layout regressions (spacing, link rendering) rather than behavioral changes. > > **Overview** > Refactors the Backup & Sync settings UI and related modals to replace deprecated `component-library` `Box`/`Text`/`Icon`/`Button` usage with `@metamask/design-system-react` equivalents. > > This updates layout and typography props (e.g., `BoxFlexDirection`/`BoxJustifyContent`, `TextVariant`/`TextColor` casing, `FontWeight`), switches various `Text as=...` usages to the `asChild` pattern, and replaces a polymorphic `Box as="img"` with a plain `<img>` plus utility classes (e.g., `w-1/2`, `rounded-md`). > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 0b1ccbc. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY -->
1 parent 26e4171 commit e89b851

4 files changed

Lines changed: 154 additions & 147 deletions

File tree

ui/components/app/identity/backup-and-sync-features-toggles/backup-and-sync-features-toggles.tsx

Lines changed: 27 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,26 @@
11
import React, { useCallback, useContext, useEffect } from 'react';
22
import { useSelector } from 'react-redux';
33
import { BACKUPANDSYNC_FEATURES } from '@metamask/profile-sync-controller/user-storage';
4+
import {
5+
Box,
6+
BoxAlignItems,
7+
BoxFlexDirection,
8+
BoxJustifyContent,
9+
FontWeight,
10+
Icon,
11+
IconName,
12+
Text,
13+
TextColor,
14+
TextVariant,
15+
} from '@metamask/design-system-react';
416
import { useI18nContext } from '../../../../hooks/useI18nContext';
517
import {
618
selectIsAccountSyncingEnabled,
719
selectIsContactSyncingEnabled,
820
selectIsBackupAndSyncEnabled,
921
selectIsBackupAndSyncUpdateLoading,
1022
} from '../../../../selectors/identity/backup-and-sync';
11-
import { Box, Icon, IconName, Text } from '../../../component-library';
1223
import ToggleButton from '../../../ui/toggle-button';
13-
import {
14-
AlignItems,
15-
Display,
16-
JustifyContent,
17-
TextColor,
18-
TextVariant,
19-
} from '../../../../helpers/constants/design-system';
2024
import Preloader from '../../../ui/icon/preloader/preloader-icon.component';
2125
import { useBackupAndSync } from '../../../../hooks/identity/useBackupAndSync/useBackupAndSync';
2226
import { MetaMetricsContext } from '../../../../contexts/metametrics';
@@ -107,15 +111,15 @@ const FeatureToggle = ({
107111

108112
return (
109113
<Box
110-
display={Display.Flex}
111-
justifyContent={JustifyContent.spaceBetween}
112-
alignItems={AlignItems.flexStart}
114+
flexDirection={BoxFlexDirection.Row}
115+
justifyContent={BoxJustifyContent.Between}
116+
alignItems={BoxAlignItems.Start}
113117
marginBottom={4}
114118
id={`backup-and-sync-features-toggles-${section.id}`}
115119
>
116-
<Box display={Display.Flex} gap={4}>
120+
<Box flexDirection={BoxFlexDirection.Row} gap={4}>
117121
<Icon name={section.iconName} />
118-
<Text variant={TextVariant.bodyMdMedium}>
122+
<Text variant={TextVariant.BodyMd} fontWeight={FontWeight.Medium}>
119123
{t(section.titleI18NKey)}
120124
</Text>
121125
</Box>
@@ -191,17 +195,18 @@ export const BackupAndSyncFeaturesToggles = () => {
191195
className="privacy-settings__setting__wrapper"
192196
data-testid={backupAndSyncFeaturesTogglesTestIds.container}
193197
>
194-
<Text variant={TextVariant.bodyMdMedium}>
198+
<Text variant={TextVariant.BodyMd} fontWeight={FontWeight.Medium}>
195199
{t('backupAndSyncManageWhatYouSync')}
196200
</Text>
197-
<Text
198-
variant={TextVariant.bodyMd}
199-
color={TextColor.textAlternative}
200-
as="div"
201-
marginBottom={4}
202-
>
203-
{t('backupAndSyncManageWhatYouSyncDescription')}
204-
</Text>
201+
<Box marginBottom={4}>
202+
<Text
203+
variant={TextVariant.BodyMd}
204+
color={TextColor.TextAlternative}
205+
asChild
206+
>
207+
<div>{t('backupAndSyncManageWhatYouSyncDescription')}</div>
208+
</Text>
209+
</Box>
205210

206211
{backupAndSyncFeaturesTogglesSections.map((section) => (
207212
<FeatureToggle

ui/components/app/identity/backup-and-sync-toggle/backup-and-sync-toggle.tsx

Lines changed: 36 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
11
import React, { useCallback, useContext, useEffect } from 'react';
22
import { useDispatch, useSelector } from 'react-redux';
33
import { BACKUPANDSYNC_FEATURES } from '@metamask/profile-sync-controller/user-storage';
4+
import {
5+
Box,
6+
BoxAlignItems,
7+
BoxFlexDirection,
8+
BoxJustifyContent,
9+
FontWeight,
10+
Text,
11+
TextColor,
12+
TextVariant,
13+
} from '@metamask/design-system-react';
414
import { useI18nContext } from '../../../../hooks/useI18nContext';
515
import { MetaMetricsContext } from '../../../../contexts/metametrics';
616
import { useBackupAndSync } from '../../../../hooks/identity/useBackupAndSync';
@@ -15,15 +25,7 @@ import {
1525
} from '../../../../selectors/identity/backup-and-sync';
1626
import { selectIsMetamaskNotificationsEnabled } from '../../../../selectors/metamask-notifications/metamask-notifications';
1727
import { showModal } from '../../../../store/actions';
18-
import { Box, Text } from '../../../component-library';
1928
import ToggleButton from '../../../ui/toggle-button';
20-
import {
21-
AlignItems,
22-
Display,
23-
JustifyContent,
24-
TextColor,
25-
TextVariant,
26-
} from '../../../../helpers/constants/design-system';
2729
import Preloader from '../../../ui/icon/preloader/preloader-icon.component';
2830
import {
2931
getExternalServicesOnboardingToggleState,
@@ -199,12 +201,12 @@ export const BackupAndSyncToggle = () => {
199201
data-testid={backupAndSyncToggleTestIds.container}
200202
>
201203
<Box
202-
display={Display.Flex}
203-
justifyContent={JustifyContent.spaceBetween}
204-
alignItems={AlignItems.flexStart}
204+
flexDirection={BoxFlexDirection.Row}
205+
justifyContent={BoxJustifyContent.Between}
206+
alignItems={BoxAlignItems.Start}
205207
marginBottom={1}
206208
>
207-
<Text variant={TextVariant.bodyMdMedium}>
209+
<Text variant={TextVariant.BodyMd} fontWeight={FontWeight.Medium}>
208210
{t('backupAndSyncEnable')}
209211
</Text>
210212

@@ -227,32 +229,33 @@ export const BackupAndSyncToggle = () => {
227229
</Box>
228230
<div className="privacy-settings__setting__description">
229231
<Text
230-
variant={TextVariant.bodyMd}
231-
color={TextColor.textAlternative}
232-
as="div"
232+
variant={TextVariant.BodyMd}
233+
color={TextColor.TextAlternative}
234+
asChild
233235
>
234-
{t('backupAndSyncEnableDescription', [
235-
<Text
236-
as="a"
237-
variant={TextVariant.bodyMd}
238-
href={ZENDESK_URLS.PROFILE_PRIVACY}
239-
target="_blank"
240-
rel="noopener noreferrer"
241-
key="privacy-link"
242-
color={TextColor.infoDefault}
243-
>
244-
{t('backupAndSyncPrivacyLink')}
245-
</Text>,
246-
])}
236+
<div>
237+
{t('backupAndSyncEnableDescription', [
238+
<Text
239+
asChild
240+
variant={TextVariant.BodyMd}
241+
key="privacy-link"
242+
color={TextColor.InfoDefault}
243+
>
244+
<a
245+
href={ZENDESK_URLS.PROFILE_PRIVACY}
246+
target="_blank"
247+
rel="noopener noreferrer"
248+
>
249+
{t('backupAndSyncPrivacyLink')}
250+
</a>
251+
</Text>,
252+
])}
253+
</div>
247254
</Text>
248255

249256
{error && (
250257
<Box marginTop={4} paddingBottom={4}>
251-
<Text
252-
as="p"
253-
color={TextColor.errorDefault}
254-
variant={TextVariant.bodySm}
255-
>
258+
<Text color={TextColor.ErrorDefault} variant={TextVariant.BodySm}>
256259
{t('notificationsSettingsBoxError')}
257260
</Text>
258261
</Box>

ui/components/app/modals/identity/confirm-turn-on-backup-and-sync-modal/confirm-turn-on-backup-and-sync-modal.tsx

Lines changed: 27 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,25 @@
11
import React from 'react';
22
import { useDispatch } from 'react-redux';
3-
import { useModalProps } from '../../../../../hooks/useModalProps';
43
import {
4+
Box,
5+
BoxAlignItems,
6+
BoxFlexDirection,
7+
BoxJustifyContent,
8+
Button,
59
ButtonSize,
10+
ButtonVariant,
11+
FontWeight,
12+
Text,
13+
TextVariant,
14+
} from '@metamask/design-system-react';
15+
import { useModalProps } from '../../../../../hooks/useModalProps';
16+
import {
617
Modal,
718
ModalOverlay,
819
ModalContent,
920
ModalHeader,
10-
Box,
11-
Text,
1221
ModalFooter,
13-
Button,
14-
ButtonVariant,
1522
} from '../../../../component-library';
16-
import {
17-
AlignItems,
18-
BlockSize,
19-
Display,
20-
FlexDirection,
21-
JustifyContent,
22-
TextVariant,
23-
} from '../../../../../helpers/constants/design-system';
2423
import { useI18nContext } from '../../../../../hooks/useI18nContext';
2524
import { toggleExternalServices } from '../../../../../store/actions';
2625
import { onboardingToggleBasicFunctionalityOn } from '../../../../../ducks/app/app';
@@ -65,26 +64,20 @@ export function ConfirmTurnOnBackupAndSyncModal() {
6564
data-testid={confirmTurnOnBackupAndSyncModalTestIds.modal}
6665
>
6766
<ModalOverlay />
68-
<ModalContent
69-
modalDialogProps={{
70-
display: Display.Flex,
71-
flexDirection: FlexDirection.Column,
72-
}}
73-
>
67+
<ModalContent>
7468
<ModalHeader
7569
paddingBottom={4}
7670
paddingRight={4}
7771
paddingLeft={4}
7872
onClose={handleHideModal}
7973
>
8074
<Box
81-
display={Display.Flex}
82-
flexDirection={FlexDirection.Column}
83-
alignItems={AlignItems.center}
84-
justifyContent={JustifyContent.center}
75+
flexDirection={BoxFlexDirection.Column}
76+
alignItems={BoxAlignItems.Center}
77+
justifyContent={BoxJustifyContent.Center}
8578
gap={4}
8679
>
87-
<Text variant={TextVariant.headingSm}>
80+
<Text variant={TextVariant.HeadingSm}>
8881
{t('backupAndSyncEnable')}
8982
</Text>
9083
</Box>
@@ -94,32 +87,27 @@ export function ConfirmTurnOnBackupAndSyncModal() {
9487
marginLeft={4}
9588
marginRight={4}
9689
marginBottom={4}
97-
display={Display.Flex}
90+
flexDirection={BoxFlexDirection.Column}
9891
gap={4}
99-
flexDirection={FlexDirection.Column}
10092
>
101-
<Text variant={TextVariant.bodySm}>
93+
<Text variant={TextVariant.BodySm}>
10294
{t('backupAndSyncEnableConfirmation', [
10395
<Text
96+
asChild
10497
key="basic-functionality"
105-
variant={TextVariant.bodySmBold}
106-
as="span"
98+
variant={TextVariant.BodySm}
99+
fontWeight={FontWeight.Bold}
107100
>
108-
{t('backupAndSyncBasicFunctionalityNameMention')}
101+
<span>{t('backupAndSyncBasicFunctionalityNameMention')}</span>
109102
</Text>,
110103
])}
111104
</Text>
112105
</Box>
113-
<ModalFooter
114-
containerProps={{
115-
flexDirection: FlexDirection.Row,
116-
alignItems: AlignItems.stretch,
117-
}}
118-
>
119-
<Box display={Display.Flex} gap={4}>
106+
<ModalFooter>
107+
<Box flexDirection={BoxFlexDirection.Row} gap={4}>
120108
<Button
121109
size={ButtonSize.Lg}
122-
width={BlockSize.Half}
110+
className="w-1/2"
123111
variant={ButtonVariant.Secondary}
124112
data-testid={confirmTurnOnBackupAndSyncModalTestIds.cancelButton}
125113
onClick={handleHideModal}
@@ -128,7 +116,7 @@ export function ConfirmTurnOnBackupAndSyncModal() {
128116
</Button>
129117
<Button
130118
size={ButtonSize.Lg}
131-
width={BlockSize.Half}
119+
className="w-1/2"
132120
variant={ButtonVariant.Primary}
133121
data-testid={confirmTurnOnBackupAndSyncModalTestIds.toggleButton}
134122
// TODO: Fix in https://github.com/MetaMask/metamask-extension/issues/31879

0 commit comments

Comments
 (0)