Skip to content

Commit 428bdda

Browse files
refactor(earn): use MMDS HeaderStandard (#29702)
## **Description** This change replaces the temporary `HeaderCompactStandard` component with `HeaderStandard` from `@metamask/design-system-react-native` on Earn-related surfaces. **Reason:** Align Earn UI with the MetaMask design system and reduce reliance on `component-library/components-temp` for standard headers. **What changed:** `HeaderStandard` is used for the Lending “How it works” bottom sheet, the Earn input screen header (back button and end actions), and the Earn token list bottom sheet. Behavior is intended to match the previous header (title, back/close, analytics-related tests unchanged aside from naming). Unit test comments and a `describe` block name were updated to reference `HeaderStandard`. ## **Changelog** CHANGELOG entry: null ## **Related issues** Fixes: https://consensyssoftware.atlassian.net/browse/DSYS-699 ## **Manual testing steps** ```gherkin Feature: Earn headers use design system HeaderStandard Scenario: Earn input screen header matches prior behavior Given the user is on the Earn flow and opens the amount/input screen (e.g. stake or supply) When the user views the screen header and uses the back control Then the header shows the expected title and navigation behaves as before Scenario: Lending “How it works” modal Given the user opens the Lending learn-more / “How it works” bottom sheet from Earn When the user views the header and taps close Then the sheet dismisses as before Scenario: Earn token selection bottom sheet Given the user opens the token list bottom sheet (e.g. select token to supply or withdraw) When the user views the header title and uses the close control Then the sheet closes as before and titles match the prior copy for the flow ``` ## **Screenshots/Recordings** ### **Before** ### **After** ## **Pre-merge author checklist** - [x] I've followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Mobile Coding Standards](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/CODING_GUIDELINES.md). - [x] I've completed the PR template to the best of my ability - [x] I've included tests if applicable - [x] I've documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [x] I've applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. #### Performance checks (if applicable) - [ ] I've tested on Android - Ideally on a mid-range device; emulator is acceptable - [ ] I've tested with a power user scenario - Use these [power-user SRPs](https://consensyssoftware.atlassian.net/wiki/spaces/TL1/pages/edit-v2/401401446401?draftShareId=9d77e1e1-4bdc-4be1-9ebb-ccd916988d93) to import wallets with many accounts and tokens - [ ] I've instrumented key operations with Sentry traces for production performance metrics - See [`trace()`](/app/util/trace.ts) for usage and [`addToken`](/app/components/Views/AddAsset/components/AddCustomToken/AddCustomToken.tsx#L274) for an example For performance guidelines and tooling, see the [Performance Guide](https://consensyssoftware.atlassian.net/wiki/spaces/TL1/pages/400085549067/Performance+Guide+for+Engineers). ## **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. <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Low Risk** > Low risk refactor that swaps a temporary header component for the design-system header on a few Earn screens; main regression risk is minor UI/interaction differences in back/close and end-icon rendering. > > **Overview** > Updates Earn surfaces to use the design-system `HeaderStandard` instead of the temporary `HeaderCompactStandard`, including the Lending “How it works” bottom sheet, the `EarnInputView` screen header (back + optional info icon), and the Earn token list bottom sheet (close button + title). > > Adjusts imports accordingly (including `IconName` usage from the design system) and updates unit test descriptions/comments to reference `HeaderStandard` while keeping behavioral assertions the same. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit c517a2e. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY --> Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 1de00bb commit 428bdda

5 files changed

Lines changed: 10 additions & 11 deletions

File tree

app/components/UI/Earn/LendingLearnMoreModal/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import React, { useEffect, useMemo, useRef, useState } from 'react';
2+
import { HeaderStandard } from '@metamask/design-system-react-native';
23
import styleSheet from './LendingLearnMoreModal.styles';
34
import { useStyles } from '../../../hooks/useStyles';
45
import BottomSheet, {
56
BottomSheetRef,
67
} from '../../../../component-library/components/BottomSheets/BottomSheet';
7-
import HeaderCompactStandard from '../../../../component-library/components-temp/HeaderCompactStandard';
88
import Text, {
99
TextColor,
1010
TextVariant,
@@ -288,7 +288,7 @@ export const LendingLearnMoreModal = () => {
288288

289289
return (
290290
<BottomSheet ref={sheetRef} isInteractable={false}>
291-
<HeaderCompactStandard
291+
<HeaderStandard
292292
title={strings('earn.how_it_works')}
293293
onClose={handleClose}
294294
/>

app/components/UI/Earn/Views/EarnInputView/EarnInputView.test.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -527,7 +527,7 @@ describe('EarnInputView', () => {
527527
name: 'params',
528528
});
529529

530-
// Verify the title is rendered in the HeaderCompactStandard component
530+
// Verify the title is rendered in the HeaderStandard component
531531
expect(getByText('Supply USDC')).toBeOnTheScreen();
532532

533533
// "0" in the input display and on the keypad
@@ -1202,7 +1202,7 @@ describe('EarnInputView', () => {
12021202
// Default mock returns ETH with POOLED_STAKING experience
12031203
const { getByText } = renderComponent();
12041204

1205-
// Verify the title is rendered in the HeaderCompactStandard component
1205+
// Verify the title is rendered in the HeaderStandard component
12061206
expect(getByText('Stake ETH')).toBeOnTheScreen();
12071207
});
12081208
});
@@ -1845,7 +1845,7 @@ describe('EarnInputView', () => {
18451845
});
18461846
});
18471847

1848-
describe('HeaderCompactStandard interactions', () => {
1848+
describe('HeaderStandard interactions', () => {
18491849
it('tracks STAKE_CANCEL_CLICKED event with token property when back button is pressed for staking', async () => {
18501850
selectStablecoinLendingEnabledFlagMock.mockReturnValue(false);
18511851

app/components/UI/Earn/Views/EarnInputView/EarnInputView.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,7 @@ import Keypad from '../../../../Base/Keypad';
4545
import { useAnalytics } from '../../../../hooks/useAnalytics/useAnalytics';
4646
import { MetaMetricsEvents } from '../../../../../core/Analytics';
4747
import { useStyles } from '../../../../hooks/useStyles';
48-
import HeaderCompactStandard from '../../../../../component-library/components-temp/HeaderCompactStandard';
49-
import { IconName } from '@metamask/design-system-react-native';
48+
import { HeaderStandard, IconName } from '@metamask/design-system-react-native';
5049
import ScreenLayout from '../../../Ramp/Aggregator/components/ScreenLayout';
5150
import QuickAmounts from '../../../Stake/components/QuickAmounts';
5251
import { EVENT_PROVIDERS } from '../../../Stake/constants/events';
@@ -1005,7 +1004,7 @@ const EarnInputView = () => {
10051004

10061005
return (
10071006
<ScreenLayout style={styles.container}>
1008-
<HeaderCompactStandard
1007+
<HeaderStandard
10091008
title={headerTitle}
10101009
onBack={handleBackPress}
10111010
endButtonIconProps={

app/components/UI/Earn/components/EarnTokenList/EarnTokenList.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -947,7 +947,7 @@ describe('EarnTokenList', () => {
947947
});
948948
});
949949

950-
describe('HeaderCompactStandard close button', () => {
950+
describe('HeaderStandard close button', () => {
951951
it('invokes handleClose when close button is pressed', async () => {
952952
const { getByTestId } = renderWithProvider(
953953
<SafeAreaProvider initialMetrics={initialMetrics}>

app/components/UI/Earn/components/EarnTokenList/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ import React, {
55
useReducer,
66
useMemo,
77
} from 'react';
8+
import { HeaderStandard } from '@metamask/design-system-react-native';
89
import BottomSheet, {
910
BottomSheetRef,
1011
} from '../../../../../component-library/components/BottomSheets/BottomSheet';
1112
import { TextColor } from '../../../../../component-library/components/Texts/Text';
12-
import HeaderCompactStandard from '../../../../../component-library/components-temp/HeaderCompactStandard';
1313
import { View } from 'react-native';
1414
import { useStyles } from '../../../../hooks/useStyles';
1515
import styleSheet from './EarnTokenList.styles';
@@ -380,7 +380,7 @@ const EarnTokenList = () => {
380380

381381
return (
382382
<BottomSheet ref={bottomSheetRef}>
383-
<HeaderCompactStandard
383+
<HeaderStandard
384384
title={
385385
params?.onItemPressScreen === EARN_INPUT_VIEW_ACTIONS.WITHDRAW
386386
? strings('stake.select_a_token_to_withdraw')

0 commit comments

Comments
 (0)