Skip to content

Commit d63cea6

Browse files
refactor(perps): use MMDS HeaderStandard (#29703)
## **Description** This PR replaces the temporary `HeaderCompactStandard` component with `HeaderStandard` from `@metamask/design-system-react-native` across Perps surfaces. **Reason:** Standardize Perps headers on the MetaMask design system and reduce dependence on `component-library/components-temp` for common header patterns. **What changed:** `HeaderStandard` is now used for the Perps markets list, withdrawal flow, transaction detail screens (funding, order, position—including the “not found” states), and the default header inside `PerpsBottomSheetTooltip` when no custom header is supplied. Existing props such as `includesTopInset`, `onBack`, `onClose`, `title`, `backButtonProps`, and `testID` are preserved so behavior should match the previous implementation. **Tests:** `PerpsMarketListHeader.test.tsx` was updated to spread `jest.requireActual('@metamask/design-system-react-native')` into the design-system mock and to remove the dedicated `HeaderCompactStandard` mock, so tests exercise the real `HeaderStandard` behavior from the design system package. ## **Changelog** CHANGELOG entry: null ## **Related issues** Fixes: https://consensyssoftware.atlassian.net/browse/DSYS-700 ## **Manual testing steps** ```gherkin Feature: Perps headers use design system HeaderStandard Scenario: Markets list header Given the user opens Perps and navigates to the markets list When they view the header and use back or any trailing actions (e.g. watchlist) as before Then layout and navigation match prior behavior Scenario: Transaction detail screens Given the user opens a Perps funding, order, or position transaction from history When they view the header title and tap back Then they return to the previous screen and titles match expectations Scenario: Missing transaction Given a transaction id resolves to no data When the user lands on the not-found state Then a minimal header with back is shown and back navigates away Scenario: Withdraw screen Given the user opens Perps withdraw When they view the withdrawal title and use the back control Then behavior matches the previous screen Scenario: Bottom sheet tooltip Given a Perps tooltip bottom sheet that uses the default (non-custom) header When the user views the title and closes the sheet Then the sheet dismisses as before ``` ## **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 `HeaderStandard`; main risk is minor UI/layout or testID regressions across Perps screens. > > **Overview** > Standardizes Perps UI headers by replacing the temporary `HeaderCompactStandard` with MMDS `HeaderStandard` across the markets list, withdraw flow, transaction detail screens (including “not found” states), the default header in `PerpsBottomSheetTooltip`, and the shared `ListHeaderWithSearch`. > > Updates the `PerpsMarketListHeader` test setup to rely on the real design-system exports (spreading `jest.requireActual('@metamask/design-system-react-native')`) and removes the dedicated `HeaderCompactStandard` mock so tests exercise `HeaderStandard` behavior. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 5e55753. 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 3fe0354 commit d63cea6

8 files changed

Lines changed: 19 additions & 75 deletions

File tree

app/components/UI/Perps/Views/PerpsMarketListView/PerpsMarketListView.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ import React, {
55
useMemo,
66
useCallback,
77
} from 'react';
8+
import { HeaderStandard } from '@metamask/design-system-react-native';
89
import { View, Animated } from 'react-native';
910
import { useStyles } from '../../../../../component-library/hooks';
1011
import Icon, {
1112
IconName,
1213
IconSize,
1314
} from '../../../../../component-library/components/Icons/Icon';
14-
import HeaderCompactStandard from '../../../../../component-library/components-temp/HeaderCompactStandard';
1515
import TextFieldSearch from '../../../../../component-library/components/Form/TextFieldSearch/TextFieldSearch';
1616
import { strings } from '../../../../../../locales/i18n';
1717
import Text, {
@@ -317,7 +317,7 @@ const PerpsMarketListView = ({
317317

318318
return (
319319
<SafeAreaView style={styles.container}>
320-
<HeaderCompactStandard
320+
<HeaderStandard
321321
title={title || strings('perps.home.markets')}
322322
onBack={handleBackPressed}
323323
backButtonProps={{

app/components/UI/Perps/Views/PerpsTransactionsView/PerpsFundingTransactionView.tsx

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
Button,
1010
ButtonVariant,
1111
ButtonSize,
12+
HeaderStandard,
1213
} from '@metamask/design-system-react-native';
1314
import Text, {
1415
TextColor,
@@ -17,7 +18,6 @@ import Text, {
1718
import { useStyles } from '../../../../../component-library/hooks';
1819
import { selectSelectedInternalAccountByScope } from '../../../../../selectors/multichainAccounts/accounts';
1920
import ScreenView from '../../../../Base/ScreenView';
20-
import HeaderCompactStandard from '../../../../../component-library/components-temp/HeaderCompactStandard';
2121
import PerpsTransactionDetailAssetHero from '../../components/PerpsTransactionDetailAssetHero';
2222
import { usePerpsBlockExplorerUrl } from '../../hooks';
2323
import {
@@ -54,10 +54,7 @@ const PerpsFundingTransactionView: React.FC = () => {
5454
if (!transaction) {
5555
return (
5656
<ScreenView>
57-
<HeaderCompactStandard
58-
includesTopInset
59-
onBack={() => navigation.goBack()}
60-
/>
57+
<HeaderStandard includesTopInset onBack={() => navigation.goBack()} />
6158
<View style={styles.content}>
6259
<Text>{strings('perps.transactions.not_found')}</Text>
6360
</View>
@@ -109,7 +106,7 @@ const PerpsFundingTransactionView: React.FC = () => {
109106

110107
return (
111108
<ScreenView>
112-
<HeaderCompactStandard
109+
<HeaderStandard
113110
includesTopInset
114111
title={transaction.title}
115112
onBack={() => navigation.goBack()}

app/components/UI/Perps/Views/PerpsTransactionsView/PerpsOrderTransactionView.tsx

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ import {
1313
Button,
1414
ButtonVariant,
1515
ButtonSize,
16+
HeaderStandard,
1617
} from '@metamask/design-system-react-native';
1718
import { useStyles } from '../../../../../component-library/hooks';
1819
import { selectSelectedInternalAccountByScope } from '../../../../../selectors/multichainAccounts/accounts';
1920
import ScreenView from '../../../../Base/ScreenView';
20-
import HeaderCompactStandard from '../../../../../component-library/components-temp/HeaderCompactStandard';
2121
import PerpsTransactionDetailAssetHero from '../../components/PerpsTransactionDetailAssetHero';
2222
import { usePerpsBlockExplorerUrl, usePerpsOrderFees } from '../../hooks';
2323
import { PerpsOrderTransactionRouteProp } from '../../types/transactionHistory';
@@ -54,10 +54,7 @@ const PerpsOrderTransactionView: React.FC = () => {
5454
if (!transaction) {
5555
return (
5656
<ScreenView>
57-
<HeaderCompactStandard
58-
includesTopInset
59-
onBack={() => navigation.goBack()}
60-
/>
57+
<HeaderStandard includesTopInset onBack={() => navigation.goBack()} />
6158
<View style={styles.content}>
6259
<Text>{strings('perps.transactions.not_found')}</Text>
6360
</View>
@@ -127,7 +124,7 @@ const PerpsOrderTransactionView: React.FC = () => {
127124

128125
return (
129126
<ScreenView>
130-
<HeaderCompactStandard
127+
<HeaderStandard
131128
includesTopInset
132129
title={transaction.title}
133130
onBack={() => navigation.goBack()}

app/components/UI/Perps/Views/PerpsTransactionsView/PerpsPositionTransactionView.tsx

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ import {
1313
Button,
1414
ButtonVariant,
1515
ButtonSize,
16+
HeaderStandard,
1617
} from '@metamask/design-system-react-native';
1718
import { useStyles } from '../../../../../component-library/hooks';
1819
import { selectSelectedInternalAccountByScope } from '../../../../../selectors/multichainAccounts/accounts';
1920
import Routes from '../../../../../constants/navigation/Routes';
2021
import ScreenView from '../../../../Base/ScreenView';
21-
import HeaderCompactStandard from '../../../../../component-library/components-temp/HeaderCompactStandard';
2222
import PerpsTransactionDetailAssetHero from '../../components/PerpsTransactionDetailAssetHero';
2323
import { usePerpsBlockExplorerUrl } from '../../hooks';
2424
import {
@@ -69,10 +69,7 @@ const PerpsPositionTransactionView: React.FC = () => {
6969
// Handle missing transaction data
7070
return (
7171
<ScreenView>
72-
<HeaderCompactStandard
73-
includesTopInset
74-
onBack={() => navigation.goBack()}
75-
/>
72+
<HeaderStandard includesTopInset onBack={() => navigation.goBack()} />
7673
<View style={styles.content}>
7774
<Text>{strings('perps.transactions.not_found')}</Text>
7875
</View>
@@ -174,7 +171,7 @@ const PerpsPositionTransactionView: React.FC = () => {
174171

175172
return (
176173
<ScreenView>
177-
<HeaderCompactStandard
174+
<HeaderStandard
178175
title={transaction?.fill?.shortTitle || ''}
179176
onBack={() => navigation.goBack()}
180177
includesTopInset

app/components/UI/Perps/Views/PerpsWithdrawView/PerpsWithdrawView.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ import {
1717
Button,
1818
ButtonVariant,
1919
ButtonSize,
20+
HeaderStandard,
2021
} from '@metamask/design-system-react-native';
21-
import HeaderCompactStandard from '../../../../../component-library/components-temp/HeaderCompactStandard';
2222
import { useTailwind } from '@metamask/design-system-twrnc-preset';
2323
import { PerpsWithdrawViewSelectorsIDs } from '../../Perps.testIds';
2424
import { strings } from '../../../../../../locales/i18n';
@@ -371,7 +371,7 @@ const PerpsWithdrawView: React.FC = () => {
371371
<SafeAreaView style={tw.style('flex-1 bg-default')}>
372372
<Box twClassName="flex-1 bg-default">
373373
{/* Header */}
374-
<HeaderCompactStandard
374+
<HeaderStandard
375375
title={strings('perps.withdrawal.title')}
376376
onBack={handleBack}
377377
backButtonProps={{

app/components/UI/Perps/components/PerpsBottomSheetTooltip/PerpsBottomSheetTooltip.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
/* eslint-disable jsdoc/check-indentation */
22
import React, { useRef, useCallback, useMemo } from 'react';
3+
import { HeaderStandard } from '@metamask/design-system-react-native';
34
import { View } from 'react-native';
45
import BottomSheet, {
56
BottomSheetRef,
67
} from '../../../../../component-library/components/BottomSheets/BottomSheet';
7-
import HeaderCompactStandard from '../../../../../component-library/components-temp/HeaderCompactStandard';
88
import BottomSheetFooter, {
99
ButtonsAlignment,
1010
} from '../../../../../component-library/components/BottomSheets/BottomSheetFooter';
@@ -147,7 +147,7 @@ const PerpsBottomSheetTooltip = React.memo<PerpsBottomSheetTooltipProps>(
147147
testID={testID}
148148
>
149149
{!hasCustomHeader && (
150-
<HeaderCompactStandard
150+
<HeaderStandard
151151
title={title}
152152
testID={PerpsBottomSheetTooltipSelectorsIDs.TITLE}
153153
onClose={handleClose}

app/components/UI/Perps/components/PerpsMarketListHeader/PerpsMarketListHeader.test.tsx

Lines changed: 2 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,10 @@ jest.mock('../../../../../../locales/i18n', () => ({
2020
}));
2121

2222
jest.mock('@metamask/design-system-react-native', () => {
23+
const actual = jest.requireActual('@metamask/design-system-react-native');
2324
const { View, Text: RNText } = jest.requireActual('react-native');
2425
return {
26+
...actual,
2527
Box: View,
2628
Text: RNText,
2729
BoxFlexDirection: { Row: 'row' },
@@ -89,55 +91,6 @@ jest.mock('../../../../../component-library/hooks', () => ({
8991
}),
9092
}));
9193

92-
jest.mock(
93-
'../../../../../component-library/components-temp/HeaderCompactStandard',
94-
() => {
95-
const { View, Text, TouchableOpacity } = jest.requireActual('react-native');
96-
return {
97-
__esModule: true,
98-
default: ({
99-
title,
100-
onBack,
101-
endButtonIconProps,
102-
testID,
103-
}: {
104-
title: string;
105-
onBack: () => void;
106-
endButtonIconProps?: {
107-
iconName: string;
108-
onPress: () => void;
109-
testID?: string;
110-
}[];
111-
testID?: string;
112-
}) => (
113-
<View testID={testID}>
114-
<TouchableOpacity
115-
testID={testID ? `${testID}-back-button` : undefined}
116-
onPress={onBack}
117-
>
118-
<Text>Back</Text>
119-
</TouchableOpacity>
120-
<Text>{title}</Text>
121-
{endButtonIconProps?.map(
122-
(
123-
props: { iconName: string; onPress: () => void; testID?: string },
124-
index: number,
125-
) => (
126-
<TouchableOpacity
127-
key={index}
128-
testID={props.testID}
129-
onPress={props.onPress}
130-
>
131-
<Text>{props.iconName}</Text>
132-
</TouchableOpacity>
133-
),
134-
)}
135-
</View>
136-
),
137-
};
138-
},
139-
);
140-
14194
describe('PerpsMarketListHeader', () => {
14295
const mockGoBack = jest.fn();
14396
const mockCanGoBack = jest.fn();

app/components/UI/shared/ListHeaderWithSearch/ListHeaderWithSearch.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import {
1414
BoxFlexDirection,
1515
BoxAlignItems,
1616
IconName as DSIconName,
17+
HeaderStandard,
1718
} from '@metamask/design-system-react-native';
1819
import { useTailwind } from '@metamask/design-system-twrnc-preset';
1920
import Icon, {
@@ -25,7 +26,6 @@ import Text, {
2526
TextVariant,
2627
TextColor,
2728
} from '../../../../component-library/components/Texts/Text';
28-
import HeaderCompactStandard from '../../../../component-library/components-temp/HeaderCompactStandard';
2929
import { useTheme } from '../../../../util/theme';
3030
import type { ListHeaderWithSearchProps } from './ListHeaderWithSearch.types';
3131
import styleSheet from './ListHeaderWithSearch.styles';
@@ -140,7 +140,7 @@ const ListHeaderWithSearch: React.FC<ListHeaderWithSearchProps> = ({
140140
}
141141

142142
return (
143-
<HeaderCompactStandard
143+
<HeaderStandard
144144
title={title || defaultTitle}
145145
onBack={handleBack}
146146
backButtonProps={{

0 commit comments

Comments
 (0)