Repository navigation
feat: add a HeroAmountInput component for large amount inputs - #47564
Conversation
Builds ready [12dab28]
⚡ Performance Benchmarks (Total: 🟢 10 pass · 🟡 0 warn · 🔴 3 fail)
Bundle Size Diffs
|
Builds ready [3650c83]
⚡ Performance Benchmarks (Total: 🟢 7 pass · 🟡 4 warn · 🔴 2 fail)
Bundle Size Diffs [🚨 Warning! Bundle size has increased!]
|
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
Bugbot Autofix prepared a fix for the issue found in the latest run.
- ✅ Fixed: First paint uses fallback font size
- Moved measurement into useLayoutEffect so the container width is read before paint, avoiding a flash of the popup fallback font size.
Or push these changes by commenting:
@cursor push 87db80b92b
Preview (87db80b92b)
diff --git a/ui/hooks/useAmountInputFontSize.test.tsx b/ui/hooks/useAmountInputFontSize.test.tsx
--- a/ui/hooks/useAmountInputFontSize.test.tsx
+++ b/ui/hooks/useAmountInputFontSize.test.tsx
@@ -54,6 +54,36 @@
expect(getFontSize()).toBe(40);
});
+ it('uses the laid-out width before the first resize notification', () => {
+ const clientWidthDescriptor = Object.getOwnPropertyDescriptor(
+ HTMLElement.prototype,
+ 'clientWidth',
+ );
+ Object.defineProperty(HTMLElement.prototype, 'clientWidth', {
+ configurable: true,
+ get() {
+ return 626;
+ },
+ });
+
+ try {
+ render(<Harness text={LONG_AMOUNT} fallbackWidth={219} />);
+
+ expect(getFontSize()).toBe(40);
+ expect(resizeObserver.constructorSpy).toHaveBeenCalledTimes(1);
+ } finally {
+ if (clientWidthDescriptor) {
+ Object.defineProperty(
+ HTMLElement.prototype,
+ 'clientWidth',
+ clientWidthDescriptor,
+ );
+ } else {
+ delete (HTMLElement.prototype as { clientWidth?: number }).clientWidth;
+ }
+ }
+ });
+
it('keeps the start size when the measured container is wide', () => {
render(<Harness text={LONG_AMOUNT} fallbackWidth={219} />);
diff --git a/ui/hooks/useAmountInputFontSize.ts b/ui/hooks/useAmountInputFontSize.ts
--- a/ui/hooks/useAmountInputFontSize.ts
+++ b/ui/hooks/useAmountInputFontSize.ts
@@ -1,4 +1,4 @@
-import { useCallback, useEffect, useMemo, useState } from 'react';
+import { useCallback, useLayoutEffect, useMemo, useState } from 'react';
import {
AMOUNT_INPUT_MAX_FONT_SIZE,
AMOUNT_INPUT_POPUP_WIDTH,
@@ -27,10 +27,11 @@
* wide layouts such as the expanded view keep larger sizes while the popup
* and side panel still step down.
*
- * One ResizeObserver per container supplies the width; nothing reads layout
- * while typing. The width is stored rounded to a whole px and only when it
- * changes, so resize notifications that do not move it cause no re-render.
- * The font size itself is derived during render.
+ * The width is read once before paint when the container mounts and then only
+ * when a ResizeObserver reports a change, so typing never triggers a layout
+ * read. The width is stored rounded to a whole px and only when it changes,
+ * so resize notifications that do not move it cause no re-render. The font
+ * size itself is derived during render.
*
* @param text - The amount as rendered, including any currency symbol.
* @param options - Layout constraints of the input.
@@ -54,24 +55,35 @@
setContainer(element);
}, []);
- useEffect(() => {
- if (!container || typeof ResizeObserver === 'undefined') {
+ useLayoutEffect(() => {
+ if (!container) {
return undefined;
}
// React 18 can still run the component once for an update that bails
// out, so repeats of the last reported width skip setState entirely.
let lastReportedWidth: number | undefined;
- // The first notification arrives after layout and before paint.
+ const reportWidth = (width: number) => {
+ const rounded = Math.round(width);
+ if (rounded === lastReportedWidth) {
+ return;
+ }
+ lastReportedWidth = rounded;
+ setMeasuredWidth((previous) =>
+ previous === rounded ? previous : rounded,
+ );
+ };
+ // Measure before paint so the first frame uses the real width. A
+ // ResizeObserver created in useEffect would only fire after paint.
+ reportWidth(container.clientWidth);
+
+ if (typeof ResizeObserver === 'undefined') {
+ return undefined;
+ }
const observer = new ResizeObserver(([entry]) => {
if (!entry) {
return;
}
- const width = Math.round(entry.contentRect.width);
- if (width === lastReportedWidth) {
- return;
- }
- lastReportedWidth = width;
- setMeasuredWidth((previous) => (previous === width ? previous : width));
+ reportWidth(entry.contentRect.width);
});
observer.observe(container);
return () => observer.disconnect();You can send follow-ups to the cloud agent here.
Reviewed by Cursor Bugbot for commit d9f2104. Configure here.
Builds ready [d9f2104]
⚡ Performance Benchmarks (Total: 🟢 6 pass · 🟡 3 warn · 🔴 4 fail)
Bundle Size Diffs [🚨 Warning! Bundle size has increased!]
|
|
CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes. |
| </> | ||
| ) : null} | ||
| {/* | ||
| * An <input> does not size to its value, so a hidden copy of the amount |
There was a problem hiding this comment.
field-sizing: content would replace the hidden copy, but Firefox only shipped it in 152 and our strict_min_version is 128. The copy uses the same variant and inline size as the input, so the wrapper is exactly as wide as the typed amount and the $ sits right beside it in every browser. Once the Firefox minimum reaches 152 this can become a single <input>.
| * | ||
| * @returns Spies and a `resize` helper. Call `restore` after each test. | ||
| */ | ||
| export function mockResizeObserver(): ResizeObserverMock { |
There was a problem hiding this comment.
jsdom has no ResizeObserver and every element measures 0px, so this mock lets tests report a width for a specific observed element through resize(width, target). Consumer tests use it to check the step at a given row width, and to assert that typing creates no new observers, without mocking HeroAmountInput itself.
There was a problem hiding this comment.
Font sizing, letter spacing, decimals and variants lgtm.
Strongly suggest implementing the per glyph motion as per this comment.
amandaye0h
left a comment
There was a problem hiding this comment.
Approving - hopefully we get the animations in for the following release
| value, | ||
| onChange, | ||
| maxDecimals, | ||
| autoFocus = false, |
There was a problem hiding this comment.
booleans default to false, so we can drop these
| textColor = TextColor.TextMuted; | ||
| } | ||
|
|
||
| const { className: prefixClassName, ...restPrefixProps } = prefixProps ?? {}; |
There was a problem hiding this comment.
if this grows, maybe need start considering CVA
…3.57.0 (#47560) <!-- CURSOR_AGENT_PR_BODY_BEGIN --> Stacked on #47564 (shared font-size helper) — merge that first. ## **Description** This is the @MetaMask/perps slice of the Grotzec large number amount inputs. It was split from the UAT build in #47557, which has the full plan, the input inventory and the risks. - Ticket: [TMCU-1744](https://consensyssoftware.atlassian.net/browse/TMCU-1744) - Epic: [TMCU-1741 [Extension] Update large number amount inputs with Grotzec](https://consensyssoftware.atlassian.net/browse/TMCU-1741) **Depends on #47564** (the shared amount scale and `useAmountInputFontSize` hook). This PR is stacked on #47564's branch (`cursor/grotzec-amount-input-scale-f3b4`) and does not carry its own copy of the helper, so its diff shows only this slice. Merge #47564 first, then retarget this PR to `main`. **What is the reason for the change?** The Perps withdraw amount was Inter at weight 500 and 64/40/30/20px. Perps balances and prices moved to Grotzec in #47465. This input is the twin of the MM Pay `CustomAmount`, which Mobile moves to Grotzec at 88px in [#38135](MetaMask/metamask-mobile#38135). **What is the improvement?** - **MMDS `Input`.** The `<input>` is now the MMDS `Input` (`textVariant={AmountDisplayLg}`, `font-hero`). The hidden-text measuring pattern stays. The symbol and measuring element are MMDS `Text` (`AmountDisplayLg` + `FontFamily.Hero`), so all three share the same family, weight and size. The explicit `fontWeight: 500` is dropped, as on Mobile. - **Sizing: shared scale.** The withdraw amount uses the scale in #47564 (`ui/helpers/utils/amount-input-font-size.ts`), the same one used by Swap/Bridge, Ramps Buy and the MM Pay amount. It has steps of 88, 72, 60, 48, 40, 32, 24 and 20px, takes the largest step at which `$` and the amount fit the input's measured width (`useAmountInputFontSize`, one `ResizeObserver` per input; 328px is only the fallback before the first measurement), and sets line height equal to font size. In the expanded view long amounts stay large instead of shrinking early. At the 328px popup width, `$25` is 88px, `$1234567.89` is 72px and `$123456789012.34` is 48px. - **Mobile reference.** The 88px start, 88px row, 88px `rounded-lg` skeleton and 20px floor match Mobile #38135. Mobile's MM Pay drops straight from 88px to 40px; Extension steps down gradually so mid-length amounts stay larger. - **Twin stays in sync.** The local length-based `getFontSize` is removed. Its twin, the confirmations `CustomAmount`, moves to the same scale in #47565, so the two can no longer drift. **Risks** - The weight changes from 500 Inter to the Bold Grotzec cut. Perps is USD only, and Grotzec has `$`, so there is no glyph fallback. ## **Changelog** CHANGELOG entry: Updated the Perps withdraw amount input to the Grotzec typeface ## **Related issues** Fixes: [TMCU-1744](https://consensyssoftware.atlassian.net/browse/TMCU-1744) Epic: [TMCU-1741](https://consensyssoftware.atlassian.net/browse/TMCU-1741) Depends on: #47564 Related: #47565 (MM Pay custom amount twin) Split from: #47557 ## **Manual testing steps** 1. Load this branch in the extension, open Perps and choose Withdraw. 2. Confirm the loading skeleton is 88px tall with rounded corners. 3. Enter `25` and confirm it renders in Grotzec at 88px. 4. Type `123456789012.34` one key at a time and confirm the amount steps down 88 → 72 → 60 → 48px and stays centred. 5. Enter more than the available balance and confirm the amount turns red. 6. Repeat in the expanded view, where long amounts stay larger instead of shrinking early, and in the side panel, where they step down smoothly as the width narrows. ## **Screenshots/Recordings** ### Before / After by code owner Before is `main` @adeaf9ad59 and After is the UAT head (#47557) @28a7077e43, both recorded with the same typing script (type 5, then 500000000000000000, then clear). #### Perps withdraw | Before | After | | --- | --- | | <img width="360" src="https://github.com/user-attachments/assets/bde0cc8d-a0a6-493e-81cd-6754ac6a0a82" alt="Perps withdraw before, side panel"> | <img width="360" src="https://github.com/user-attachments/assets/87e17271-f2a9-4b2e-824f-92456a58a3eb" alt="Perps withdraw after, side panel"> | | <img width="360" src="https://github.com/user-attachments/assets/2c539038-48c1-4f5b-9ef4-85b21391df3b" alt="Perps withdraw before, expanded view"> | <img width="360" src="https://github.com/user-attachments/assets/cc7c54af-42e1-4bf9-bffc-92bd98312ead" alt="Perps withdraw after, expanded view"> | Full MP4s: [Side panel before](https://github.com/user-attachments/assets/49c2722c-88e1-41fb-8ff3-1fda48319b85) · [Side panel after](https://github.com/user-attachments/assets/573cd199-f321-4b96-aab8-790349a292a6) · [Expanded before](https://github.com/user-attachments/assets/0595640d-d948-4c3f-9ec8-fb505f8f01f7) · [Expanded after](https://github.com/user-attachments/assets/85f918b1-09ec-4359-927d-705da4ed3405) ## **Pre-merge author checklist** - [x] 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). - [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 - [ ] 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. <!-- CURSOR_AGENT_PR_BODY_END --> <div><a href="https://cursor.com/agents/bc-b3180cce-a244-5330-95e3-35b5951ff3b4?cursor_ref=pr_footer&cursor_cta=open_in_web"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/open-in-web-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/open-in-web-light.png"><img alt="Open in Web" width="114" height="28" src="https://cursor.com/assets/images/open-in-web-dark.png"></picture></a> <a href="https://cursor.com/background-agent?bcId=bc-b3180cce-a244-5330-95e3-35b5951ff3b4&cursor_ref=pr_footer&cursor_cta=open_in_cursor"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/open-in-cursor-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/open-in-cursor-light.png"><img alt="Open in Cursor" width="131" height="28" src="https://cursor.com/assets/images/open-in-cursor-dark.png"></picture></a> </div> [TMCU-1744]: https://consensyssoftware.atlassian.net/browse/TMCU-1744?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ [TMCU-1744]: https://consensyssoftware.atlassian.net/browse/TMCU-1744?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Low Risk** > Scoped UI swap on the Perps withdraw amount field with no changes to withdrawal submission, balance guards, or backend calls. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 52d1e02. 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 Agent <cursoragent@cursor.com> Co-authored-by: George Marshall <georgewrmarshall@users.noreply.github.com>
…3.57.0 (#47560) <!-- CURSOR_AGENT_PR_BODY_BEGIN --> Stacked on #47564 (shared font-size helper) — merge that first. ## **Description** This is the @MetaMask/perps slice of the Grotzec large number amount inputs. It was split from the UAT build in #47557, which has the full plan, the input inventory and the risks. - Ticket: [TMCU-1744](https://consensyssoftware.atlassian.net/browse/TMCU-1744) - Epic: [TMCU-1741 [Extension] Update large number amount inputs with Grotzec](https://consensyssoftware.atlassian.net/browse/TMCU-1741) **Depends on #47564** (the shared amount scale and `useAmountInputFontSize` hook). This PR is stacked on #47564's branch (`cursor/grotzec-amount-input-scale-f3b4`) and does not carry its own copy of the helper, so its diff shows only this slice. Merge #47564 first, then retarget this PR to `main`. **What is the reason for the change?** The Perps withdraw amount was Inter at weight 500 and 64/40/30/20px. Perps balances and prices moved to Grotzec in #47465. This input is the twin of the MM Pay `CustomAmount`, which Mobile moves to Grotzec at 88px in [#38135](MetaMask/metamask-mobile#38135). **What is the improvement?** - **MMDS `Input`.** The `<input>` is now the MMDS `Input` (`textVariant={AmountDisplayLg}`, `font-hero`). The hidden-text measuring pattern stays. The symbol and measuring element are MMDS `Text` (`AmountDisplayLg` + `FontFamily.Hero`), so all three share the same family, weight and size. The explicit `fontWeight: 500` is dropped, as on Mobile. - **Sizing: shared scale.** The withdraw amount uses the scale in #47564 (`ui/helpers/utils/amount-input-font-size.ts`), the same one used by Swap/Bridge, Ramps Buy and the MM Pay amount. It has steps of 88, 72, 60, 48, 40, 32, 24 and 20px, takes the largest step at which `$` and the amount fit the input's measured width (`useAmountInputFontSize`, one `ResizeObserver` per input; 328px is only the fallback before the first measurement), and sets line height equal to font size. In the expanded view long amounts stay large instead of shrinking early. At the 328px popup width, `$25` is 88px, `$1234567.89` is 72px and `$123456789012.34` is 48px. - **Mobile reference.** The 88px start, 88px row, 88px `rounded-lg` skeleton and 20px floor match Mobile #38135. Mobile's MM Pay drops straight from 88px to 40px; Extension steps down gradually so mid-length amounts stay larger. - **Twin stays in sync.** The local length-based `getFontSize` is removed. Its twin, the confirmations `CustomAmount`, moves to the same scale in #47565, so the two can no longer drift. **Risks** - The weight changes from 500 Inter to the Bold Grotzec cut. Perps is USD only, and Grotzec has `$`, so there is no glyph fallback. ## **Changelog** CHANGELOG entry: Updated the Perps withdraw amount input to the Grotzec typeface ## **Related issues** Fixes: [TMCU-1744](https://consensyssoftware.atlassian.net/browse/TMCU-1744) Epic: [TMCU-1741](https://consensyssoftware.atlassian.net/browse/TMCU-1741) Depends on: #47564 Related: #47565 (MM Pay custom amount twin) Split from: #47557 ## **Manual testing steps** 1. Load this branch in the extension, open Perps and choose Withdraw. 2. Confirm the loading skeleton is 88px tall with rounded corners. 3. Enter `25` and confirm it renders in Grotzec at 88px. 4. Type `123456789012.34` one key at a time and confirm the amount steps down 88 → 72 → 60 → 48px and stays centred. 5. Enter more than the available balance and confirm the amount turns red. 6. Repeat in the expanded view, where long amounts stay larger instead of shrinking early, and in the side panel, where they step down smoothly as the width narrows. ## **Screenshots/Recordings** ### Before / After by code owner Before is `main` @adeaf9ad59 and After is the UAT head (#47557) @28a7077e43, both recorded with the same typing script (type 5, then 500000000000000000, then clear). #### Perps withdraw | Before | After | | --- | --- | | <img width="360" src="https://github.com/user-attachments/assets/bde0cc8d-a0a6-493e-81cd-6754ac6a0a82" alt="Perps withdraw before, side panel"> | <img width="360" src="https://github.com/user-attachments/assets/87e17271-f2a9-4b2e-824f-92456a58a3eb" alt="Perps withdraw after, side panel"> | | <img width="360" src="https://github.com/user-attachments/assets/2c539038-48c1-4f5b-9ef4-85b21391df3b" alt="Perps withdraw before, expanded view"> | <img width="360" src="https://github.com/user-attachments/assets/cc7c54af-42e1-4bf9-bffc-92bd98312ead" alt="Perps withdraw after, expanded view"> | Full MP4s: [Side panel before](https://github.com/user-attachments/assets/49c2722c-88e1-41fb-8ff3-1fda48319b85) · [Side panel after](https://github.com/user-attachments/assets/573cd199-f321-4b96-aab8-790349a292a6) · [Expanded before](https://github.com/user-attachments/assets/0595640d-d948-4c3f-9ec8-fb505f8f01f7) · [Expanded after](https://github.com/user-attachments/assets/85f918b1-09ec-4359-927d-705da4ed3405) ## **Pre-merge author checklist** - [x] 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). - [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 - [ ] 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. <!-- CURSOR_AGENT_PR_BODY_END --> <div><a href="https://cursor.com/agents/bc-b3180cce-a244-5330-95e3-35b5951ff3b4?cursor_ref=pr_footer&cursor_cta=open_in_web"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/open-in-web-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/open-in-web-light.png"><img alt="Open in Web" width="114" height="28" src="https://cursor.com/assets/images/open-in-web-dark.png"></picture></a> <a href="https://cursor.com/background-agent?bcId=bc-b3180cce-a244-5330-95e3-35b5951ff3b4&cursor_ref=pr_footer&cursor_cta=open_in_cursor"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/open-in-cursor-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/open-in-cursor-light.png"><img alt="Open in Cursor" width="131" height="28" src="https://cursor.com/assets/images/open-in-cursor-dark.png"></picture></a> </div> [TMCU-1744]: https://consensyssoftware.atlassian.net/browse/TMCU-1744?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ [TMCU-1744]: https://consensyssoftware.atlassian.net/browse/TMCU-1744?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Low Risk** > Scoped UI swap on the Perps withdraw amount field with no changes to withdrawal submission, balance guards, or backend calls. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 52d1e02. 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 Agent <cursoragent@cursor.com> Co-authored-by: George Marshall <georgewrmarshall@users.noreply.github.com>
…put in Grotzec Hero cp-13.57.0 (#47560) <!-- CURSOR_AGENT_PR_BODY_BEGIN --> Stacked on #47564 (shared font-size helper) — merge that first. ## **Description** This is the @MetaMask/perps slice of the Grotzec large number amount inputs. It was split from the UAT build in #47557, which has the full plan, the input inventory and the risks. - Ticket: [TMCU-1744](https://consensyssoftware.atlassian.net/browse/TMCU-1744) - Epic: [TMCU-1741 [Extension] Update large number amount inputs with Grotzec](https://consensyssoftware.atlassian.net/browse/TMCU-1741) **Depends on #47564** (the shared amount scale and `useAmountInputFontSize` hook). This PR is stacked on #47564's branch (`cursor/grotzec-amount-input-scale-f3b4`) and does not carry its own copy of the helper, so its diff shows only this slice. Merge #47564 first, then retarget this PR to `main`. **What is the reason for the change?** The Perps withdraw amount was Inter at weight 500 and 64/40/30/20px. Perps balances and prices moved to Grotzec in #47465. This input is the twin of the MM Pay `CustomAmount`, which Mobile moves to Grotzec at 88px in [#38135](MetaMask/metamask-mobile#38135). **What is the improvement?** - **MMDS `Input`.** The `<input>` is now the MMDS `Input` (`textVariant={AmountDisplayLg}`, `font-hero`). The hidden-text measuring pattern stays. The symbol and measuring element are MMDS `Text` (`AmountDisplayLg` + `FontFamily.Hero`), so all three share the same family, weight and size. The explicit `fontWeight: 500` is dropped, as on Mobile. - **Sizing: shared scale.** The withdraw amount uses the scale in #47564 (`ui/helpers/utils/amount-input-font-size.ts`), the same one used by Swap/Bridge, Ramps Buy and the MM Pay amount. It has steps of 88, 72, 60, 48, 40, 32, 24 and 20px, takes the largest step at which `$` and the amount fit the input's measured width (`useAmountInputFontSize`, one `ResizeObserver` per input; 328px is only the fallback before the first measurement), and sets line height equal to font size. In the expanded view long amounts stay large instead of shrinking early. At the 328px popup width, `$25` is 88px, `$1234567.89` is 72px and `$123456789012.34` is 48px. - **Mobile reference.** The 88px start, 88px row, 88px `rounded-lg` skeleton and 20px floor match Mobile #38135. Mobile's MM Pay drops straight from 88px to 40px; Extension steps down gradually so mid-length amounts stay larger. - **Twin stays in sync.** The local length-based `getFontSize` is removed. Its twin, the confirmations `CustomAmount`, moves to the same scale in #47565, so the two can no longer drift. **Risks** - The weight changes from 500 Inter to the Bold Grotzec cut. Perps is USD only, and Grotzec has `$`, so there is no glyph fallback. ## **Changelog** CHANGELOG entry: Updated the Perps withdraw amount input to the Grotzec typeface ## **Related issues** Fixes: [TMCU-1744](https://consensyssoftware.atlassian.net/browse/TMCU-1744) Epic: [TMCU-1741](https://consensyssoftware.atlassian.net/browse/TMCU-1741) Depends on: #47564 Related: #47565 (MM Pay custom amount twin) Split from: #47557 ## **Manual testing steps** 1. Load this branch in the extension, open Perps and choose Withdraw. 2. Confirm the loading skeleton is 88px tall with rounded corners. 3. Enter `25` and confirm it renders in Grotzec at 88px. 4. Type `123456789012.34` one key at a time and confirm the amount steps down 88 → 72 → 60 → 48px and stays centred. 5. Enter more than the available balance and confirm the amount turns red. 6. Repeat in the expanded view, where long amounts stay larger instead of shrinking early, and in the side panel, where they step down smoothly as the width narrows. ## **Screenshots/Recordings** ### Before / After by code owner Before is `main` @adeaf9ad59 and After is the UAT head (#47557) @28a7077e43, both recorded with the same typing script (type 5, then 500000000000000000, then clear). #### Perps withdraw | Before | After | | --- | --- | | <img width="360" src="https://github.com/user-attachments/assets/bde0cc8d-a0a6-493e-81cd-6754ac6a0a82" alt="Perps withdraw before, side panel"> | <img width="360" src="https://github.com/user-attachments/assets/87e17271-f2a9-4b2e-824f-92456a58a3eb" alt="Perps withdraw after, side panel"> | | <img width="360" src="https://github.com/user-attachments/assets/2c539038-48c1-4f5b-9ef4-85b21391df3b" alt="Perps withdraw before, expanded view"> | <img width="360" src="https://github.com/user-attachments/assets/cc7c54af-42e1-4bf9-bffc-92bd98312ead" alt="Perps withdraw after, expanded view"> | Full MP4s: [Side panel before](https://github.com/user-attachments/assets/49c2722c-88e1-41fb-8ff3-1fda48319b85) · [Side panel after](https://github.com/user-attachments/assets/573cd199-f321-4b96-aab8-790349a292a6) · [Expanded before](https://github.com/user-attachments/assets/0595640d-d948-4c3f-9ec8-fb505f8f01f7) · [Expanded after](https://github.com/user-attachments/assets/85f918b1-09ec-4359-927d-705da4ed3405) ## **Pre-merge author checklist** - [x] 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). - [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 - [ ] 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. <!-- CURSOR_AGENT_PR_BODY_END --> <div><a href="https://cursor.com/agents/bc-b3180cce-a244-5330-95e3-35b5951ff3b4?cursor_ref=pr_footer&cursor_cta=open_in_web"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/open-in-web-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/open-in-web-light.png"><img alt="Open in Web" width="114" height="28" src="https://cursor.com/assets/images/open-in-web-dark.png"></picture></a> <a href="https://cursor.com/background-agent?bcId=bc-b3180cce-a244-5330-95e3-35b5951ff3b4&cursor_ref=pr_footer&cursor_cta=open_in_cursor"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/open-in-cursor-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/open-in-cursor-light.png"><img alt="Open in Cursor" width="131" height="28" src="https://cursor.com/assets/images/open-in-cursor-dark.png"></picture></a> </div> [TMCU-1744]: https://consensyssoftware.atlassian.net/browse/TMCU-1744?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ [TMCU-1744]: https://consensyssoftware.atlassian.net/browse/TMCU-1744?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Low Risk** > Scoped UI swap on the Perps withdraw amount field with no changes to withdrawal submission, balance guards, or backend calls. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 52d1e02. 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 Agent <cursoragent@cursor.com> Co-authored-by: George Marshall <georgewrmarshall@users.noreply.github.com>
…zec Hero cp-13.57.0 (#47565) <!-- CURSOR_AGENT_PR_BODY_BEGIN --> Stacked on #47564 (shared font-size helper) — merge that first. ## **Description** This is the @MetaMask/confirmations slice of the Grotzec large number amount inputs. It was split from the UAT build in #47557. - Epic: [TMCU-1741 [Extension] Update large number amount inputs with Grotzec](https://consensyssoftware.atlassian.net/browse/TMCU-1741) - Ticket: a child ticket of [TMCU-1741](https://consensyssoftware.atlassian.net/browse/TMCU-1741) is still to be created for the MM Pay custom amount. **Depends on #47564** (the shared amount scale and `useAmountInputFontSize` hook). This PR is stacked on #47564's branch (`cursor/grotzec-amount-input-scale-f3b4`) and does not carry its own copy of the helper, so its diff shows only this slice. Merge #47564 first, then retarget this PR to `main`. **What is the reason for the change?** `CustomAmount` (`ui/pages/confirmations/components/transactions/custom-amount/custom-amount.tsx`) is the MM Pay hero amount. It is used by Perps deposit, the Perps withdraw confirmation, mUSD conversion and Money account deposit and withdraw. It was still Inter at weight 500, sized 64/40/30/20px with line heights 70/44/33/22px, using legacy component-library `Text` and a raw `<input>` sized in `ch`. Mobile moves the same component to Grotzec in [#38135](MetaMask/metamask-mobile#38135). **What is the improvement?** - **MMDS `Input`.** The `<input>` is now the MMDS `Input` (`textVariant={AmountDisplayLg}`, `font-hero`, `isStateStylesDisabled`). The symbol is MMDS `Text` `AmountDisplayLg` + `FontFamily.Hero`. - **Width.** The `ch` estimate is replaced with the hidden measuring `Text` that its Perps twin (`PerpsFiatHeroAmountInput`) uses. The measuring `Text` is set in the same font, so the input width is exact for Grotzec and for fallback symbols. - **Sizing.** Sizes come from the shared scale in #47564: 88, 72, 60, 48, 40, 32, 24, 20px, taking the largest step at which the symbol and amount fit the input's measured width (`useAmountInputFontSize`, one `ResizeObserver` per input; 328px is only the fallback before the first measurement). Line height equals font size. In the expanded view long amounts stay large instead of shrinking early. At the 328px popup width, `$25` is 88px, `$1234567.89` is 72px and a 20-digit amount is 32px. The row and the `rounded-lg` skeleton are both 88px, as in Mobile #38135. - **Unchanged.** Test IDs (`custom-amount-input`, `custom-amount-symbol`, `custom-amount-skeleton`), cents-only display, the 2-decimal input pattern, `autoFocus` and the alert and disabled colours are unchanged. The E2E page objects use the same test IDs. **Risks** - This changes the hero on five confirmation flows at once: Perps deposit, Perps withdraw, mUSD conversion, and Money deposit and withdraw. - Symbols Grotzec lacks (₹ ₩ ₿ …) render in the fallback family. The shared scale budgets for their extra width. - The weight changes from 500 Inter to the Bold Grotzec cut. ## **Changelog** CHANGELOG entry: Updated the MetaMask Pay amount input to the Grotzec typeface ## **Related issues** Epic: [TMCU-1741](https://consensyssoftware.atlassian.net/browse/TMCU-1741). A child ticket is still to be created. Depends on: #47564 Split from: #47557 ## **Manual testing steps** 1. Load this branch in the extension. 2. Start a Perps deposit. Confirm the amount is Grotzec at 88px for `25`. Then type `123456789012.34` one key at a time and confirm it steps down 88 → 72 → 60 → 48px and stays centred. 3. Click Max or a percentage and confirm the amount shows at most 2 decimals. 4. Enter more than the balance and confirm the amount turns red. 5. Repeat the short and long amount check in mUSD conversion and in Money account deposit and withdraw. 6. Repeat in the expanded view, where long amounts stay larger instead of shrinking early, and in the side panel, where they step down smoothly as the width narrows. ## **Screenshots/Recordings** ### Before / After by code owner Before is `main` @adeaf9ad59 and After is the UAT head (#47557) @28a7077e43, both recorded with the same typing script (type 5, then 500000000000000000, then clear). #### MM Pay custom amount | Before | After | | --- | --- | | <img width="360" src="https://github.com/user-attachments/assets/ce28237e-b7de-4816-9a62-4dfab0d2577d" alt="MM Pay custom amount before, side panel"> | <img width="360" src="https://github.com/user-attachments/assets/10617750-5f69-4a1a-8700-a1e1ebef52be" alt="MM Pay custom amount after, side panel"> | | <img width="360" src="https://github.com/user-attachments/assets/a30507a6-420a-4c2a-b240-0176ec1c8f3c" alt="MM Pay custom amount before, expanded view"> | <img width="360" src="https://github.com/user-attachments/assets/7d9fbaf6-c0d0-4590-bac4-4d724808e4da" alt="MM Pay custom amount after, expanded view"> | Full MP4s: [Side panel before](https://github.com/user-attachments/assets/940444b2-140e-47f1-ae07-ad0e2a79fb68) · [Side panel after](https://github.com/user-attachments/assets/b754992c-b785-4fe0-a25c-50da625a0453) · [Expanded before](https://github.com/user-attachments/assets/377356c2-15f9-4d26-9572-af2ee51624e0) · [Expanded after](https://github.com/user-attachments/assets/96562d58-8e05-4ebb-99bf-0285eaf55c1b) ## **Pre-merge author checklist** - [x] 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). - [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 - [ ] 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. <!-- CURSOR_AGENT_PR_BODY_END --> <div><a href="https://cursor.com/agents/bc-b3180cce-a244-5330-95e3-35b5951ff3b4?cursor_ref=pr_footer&cursor_cta=open_in_web"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/open-in-web-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/open-in-web-light.png"><img alt="Open in Web" width="114" height="28" src="https://cursor.com/assets/images/open-in-web-dark.png"></picture></a> <a href="https://cursor.com/background-agent?bcId=bc-b3180cce-a244-5330-95e3-35b5951ff3b4&cursor_ref=pr_footer&cursor_cta=open_in_cursor"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/open-in-cursor-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/open-in-cursor-light.png"><img alt="Open in Cursor" width="131" height="28" src="https://cursor.com/assets/images/open-in-cursor-dark.png"></picture></a> </div> [TMCU-1741]: https://consensyssoftware.atlassian.net/browse/TMCU-1741?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ [TMCU-1741]: https://consensyssoftware.atlassian.net/browse/TMCU-1741?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Medium Risk** > The same hero control drives several MM Pay confirmation flows; visual and sizing behavior change via the shared component, though fiat display rules and input constraints stay equivalent. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 30842bf. 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 Agent <cursoragent@cursor.com> Co-authored-by: George Marshall <georgewrmarshall@users.noreply.github.com>
…zec Hero cp-13.57.0 (#47565) <!-- CURSOR_AGENT_PR_BODY_BEGIN --> Stacked on #47564 (shared font-size helper) — merge that first. ## **Description** This is the @MetaMask/confirmations slice of the Grotzec large number amount inputs. It was split from the UAT build in #47557. - Epic: [TMCU-1741 [Extension] Update large number amount inputs with Grotzec](https://consensyssoftware.atlassian.net/browse/TMCU-1741) - Ticket: a child ticket of [TMCU-1741](https://consensyssoftware.atlassian.net/browse/TMCU-1741) is still to be created for the MM Pay custom amount. **Depends on #47564** (the shared amount scale and `useAmountInputFontSize` hook). This PR is stacked on #47564's branch (`cursor/grotzec-amount-input-scale-f3b4`) and does not carry its own copy of the helper, so its diff shows only this slice. Merge #47564 first, then retarget this PR to `main`. **What is the reason for the change?** `CustomAmount` (`ui/pages/confirmations/components/transactions/custom-amount/custom-amount.tsx`) is the MM Pay hero amount. It is used by Perps deposit, the Perps withdraw confirmation, mUSD conversion and Money account deposit and withdraw. It was still Inter at weight 500, sized 64/40/30/20px with line heights 70/44/33/22px, using legacy component-library `Text` and a raw `<input>` sized in `ch`. Mobile moves the same component to Grotzec in [#38135](MetaMask/metamask-mobile#38135). **What is the improvement?** - **MMDS `Input`.** The `<input>` is now the MMDS `Input` (`textVariant={AmountDisplayLg}`, `font-hero`, `isStateStylesDisabled`). The symbol is MMDS `Text` `AmountDisplayLg` + `FontFamily.Hero`. - **Width.** The `ch` estimate is replaced with the hidden measuring `Text` that its Perps twin (`PerpsFiatHeroAmountInput`) uses. The measuring `Text` is set in the same font, so the input width is exact for Grotzec and for fallback symbols. - **Sizing.** Sizes come from the shared scale in #47564: 88, 72, 60, 48, 40, 32, 24, 20px, taking the largest step at which the symbol and amount fit the input's measured width (`useAmountInputFontSize`, one `ResizeObserver` per input; 328px is only the fallback before the first measurement). Line height equals font size. In the expanded view long amounts stay large instead of shrinking early. At the 328px popup width, `$25` is 88px, `$1234567.89` is 72px and a 20-digit amount is 32px. The row and the `rounded-lg` skeleton are both 88px, as in Mobile #38135. - **Unchanged.** Test IDs (`custom-amount-input`, `custom-amount-symbol`, `custom-amount-skeleton`), cents-only display, the 2-decimal input pattern, `autoFocus` and the alert and disabled colours are unchanged. The E2E page objects use the same test IDs. **Risks** - This changes the hero on five confirmation flows at once: Perps deposit, Perps withdraw, mUSD conversion, and Money deposit and withdraw. - Symbols Grotzec lacks (₹ ₩ ₿ …) render in the fallback family. The shared scale budgets for their extra width. - The weight changes from 500 Inter to the Bold Grotzec cut. ## **Changelog** CHANGELOG entry: Updated the MetaMask Pay amount input to the Grotzec typeface ## **Related issues** Epic: [TMCU-1741](https://consensyssoftware.atlassian.net/browse/TMCU-1741). A child ticket is still to be created. Depends on: #47564 Split from: #47557 ## **Manual testing steps** 1. Load this branch in the extension. 2. Start a Perps deposit. Confirm the amount is Grotzec at 88px for `25`. Then type `123456789012.34` one key at a time and confirm it steps down 88 → 72 → 60 → 48px and stays centred. 3. Click Max or a percentage and confirm the amount shows at most 2 decimals. 4. Enter more than the balance and confirm the amount turns red. 5. Repeat the short and long amount check in mUSD conversion and in Money account deposit and withdraw. 6. Repeat in the expanded view, where long amounts stay larger instead of shrinking early, and in the side panel, where they step down smoothly as the width narrows. ## **Screenshots/Recordings** ### Before / After by code owner Before is `main` @adeaf9ad59 and After is the UAT head (#47557) @28a7077e43, both recorded with the same typing script (type 5, then 500000000000000000, then clear). #### MM Pay custom amount | Before | After | | --- | --- | | <img width="360" src="https://github.com/user-attachments/assets/ce28237e-b7de-4816-9a62-4dfab0d2577d" alt="MM Pay custom amount before, side panel"> | <img width="360" src="https://github.com/user-attachments/assets/10617750-5f69-4a1a-8700-a1e1ebef52be" alt="MM Pay custom amount after, side panel"> | | <img width="360" src="https://github.com/user-attachments/assets/a30507a6-420a-4c2a-b240-0176ec1c8f3c" alt="MM Pay custom amount before, expanded view"> | <img width="360" src="https://github.com/user-attachments/assets/7d9fbaf6-c0d0-4590-bac4-4d724808e4da" alt="MM Pay custom amount after, expanded view"> | Full MP4s: [Side panel before](https://github.com/user-attachments/assets/940444b2-140e-47f1-ae07-ad0e2a79fb68) · [Side panel after](https://github.com/user-attachments/assets/b754992c-b785-4fe0-a25c-50da625a0453) · [Expanded before](https://github.com/user-attachments/assets/377356c2-15f9-4d26-9572-af2ee51624e0) · [Expanded after](https://github.com/user-attachments/assets/96562d58-8e05-4ebb-99bf-0285eaf55c1b) ## **Pre-merge author checklist** - [x] 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). - [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 - [ ] 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. <!-- CURSOR_AGENT_PR_BODY_END --> <div><a href="https://cursor.com/agents/bc-b3180cce-a244-5330-95e3-35b5951ff3b4?cursor_ref=pr_footer&cursor_cta=open_in_web"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/open-in-web-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/open-in-web-light.png"><img alt="Open in Web" width="114" height="28" src="https://cursor.com/assets/images/open-in-web-dark.png"></picture></a> <a href="https://cursor.com/background-agent?bcId=bc-b3180cce-a244-5330-95e3-35b5951ff3b4&cursor_ref=pr_footer&cursor_cta=open_in_cursor"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/open-in-cursor-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/open-in-cursor-light.png"><img alt="Open in Cursor" width="131" height="28" src="https://cursor.com/assets/images/open-in-cursor-dark.png"></picture></a> </div> [TMCU-1741]: https://consensyssoftware.atlassian.net/browse/TMCU-1741?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ [TMCU-1741]: https://consensyssoftware.atlassian.net/browse/TMCU-1741?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Medium Risk** > The same hero control drives several MM Pay confirmation flows; visual and sizing behavior change via the shared component, though fiat display rules and input constraints stay equivalent. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 30842bf. 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 Agent <cursoragent@cursor.com> Co-authored-by: George Marshall <georgewrmarshall@users.noreply.github.com>
…tom amount input in Grotzec Hero cp-13.57.0 (#47565) <!-- CURSOR_AGENT_PR_BODY_BEGIN --> Stacked on #47564 (shared font-size helper) — merge that first. ## **Description** This is the @MetaMask/confirmations slice of the Grotzec large number amount inputs. It was split from the UAT build in #47557. - Epic: [TMCU-1741 [Extension] Update large number amount inputs with Grotzec](https://consensyssoftware.atlassian.net/browse/TMCU-1741) - Ticket: a child ticket of [TMCU-1741](https://consensyssoftware.atlassian.net/browse/TMCU-1741) is still to be created for the MM Pay custom amount. **Depends on #47564** (the shared amount scale and `useAmountInputFontSize` hook). This PR is stacked on #47564's branch (`cursor/grotzec-amount-input-scale-f3b4`) and does not carry its own copy of the helper, so its diff shows only this slice. Merge #47564 first, then retarget this PR to `main`. **What is the reason for the change?** `CustomAmount` (`ui/pages/confirmations/components/transactions/custom-amount/custom-amount.tsx`) is the MM Pay hero amount. It is used by Perps deposit, the Perps withdraw confirmation, mUSD conversion and Money account deposit and withdraw. It was still Inter at weight 500, sized 64/40/30/20px with line heights 70/44/33/22px, using legacy component-library `Text` and a raw `<input>` sized in `ch`. Mobile moves the same component to Grotzec in [#38135](MetaMask/metamask-mobile#38135). **What is the improvement?** - **MMDS `Input`.** The `<input>` is now the MMDS `Input` (`textVariant={AmountDisplayLg}`, `font-hero`, `isStateStylesDisabled`). The symbol is MMDS `Text` `AmountDisplayLg` + `FontFamily.Hero`. - **Width.** The `ch` estimate is replaced with the hidden measuring `Text` that its Perps twin (`PerpsFiatHeroAmountInput`) uses. The measuring `Text` is set in the same font, so the input width is exact for Grotzec and for fallback symbols. - **Sizing.** Sizes come from the shared scale in #47564: 88, 72, 60, 48, 40, 32, 24, 20px, taking the largest step at which the symbol and amount fit the input's measured width (`useAmountInputFontSize`, one `ResizeObserver` per input; 328px is only the fallback before the first measurement). Line height equals font size. In the expanded view long amounts stay large instead of shrinking early. At the 328px popup width, `$25` is 88px, `$1234567.89` is 72px and a 20-digit amount is 32px. The row and the `rounded-lg` skeleton are both 88px, as in Mobile #38135. - **Unchanged.** Test IDs (`custom-amount-input`, `custom-amount-symbol`, `custom-amount-skeleton`), cents-only display, the 2-decimal input pattern, `autoFocus` and the alert and disabled colours are unchanged. The E2E page objects use the same test IDs. **Risks** - This changes the hero on five confirmation flows at once: Perps deposit, Perps withdraw, mUSD conversion, and Money deposit and withdraw. - Symbols Grotzec lacks (₹ ₩ ₿ …) render in the fallback family. The shared scale budgets for their extra width. - The weight changes from 500 Inter to the Bold Grotzec cut. ## **Changelog** CHANGELOG entry: Updated the MetaMask Pay amount input to the Grotzec typeface ## **Related issues** Epic: [TMCU-1741](https://consensyssoftware.atlassian.net/browse/TMCU-1741). A child ticket is still to be created. Depends on: #47564 Split from: #47557 ## **Manual testing steps** 1. Load this branch in the extension. 2. Start a Perps deposit. Confirm the amount is Grotzec at 88px for `25`. Then type `123456789012.34` one key at a time and confirm it steps down 88 → 72 → 60 → 48px and stays centred. 3. Click Max or a percentage and confirm the amount shows at most 2 decimals. 4. Enter more than the balance and confirm the amount turns red. 5. Repeat the short and long amount check in mUSD conversion and in Money account deposit and withdraw. 6. Repeat in the expanded view, where long amounts stay larger instead of shrinking early, and in the side panel, where they step down smoothly as the width narrows. ## **Screenshots/Recordings** ### Before / After by code owner Before is `main` @adeaf9ad59 and After is the UAT head (#47557) @28a7077e43, both recorded with the same typing script (type 5, then 500000000000000000, then clear). #### MM Pay custom amount | Before | After | | --- | --- | | <img width="360" src="https://github.com/user-attachments/assets/ce28237e-b7de-4816-9a62-4dfab0d2577d" alt="MM Pay custom amount before, side panel"> | <img width="360" src="https://github.com/user-attachments/assets/10617750-5f69-4a1a-8700-a1e1ebef52be" alt="MM Pay custom amount after, side panel"> | | <img width="360" src="https://github.com/user-attachments/assets/a30507a6-420a-4c2a-b240-0176ec1c8f3c" alt="MM Pay custom amount before, expanded view"> | <img width="360" src="https://github.com/user-attachments/assets/7d9fbaf6-c0d0-4590-bac4-4d724808e4da" alt="MM Pay custom amount after, expanded view"> | Full MP4s: [Side panel before](https://github.com/user-attachments/assets/940444b2-140e-47f1-ae07-ad0e2a79fb68) · [Side panel after](https://github.com/user-attachments/assets/b754992c-b785-4fe0-a25c-50da625a0453) · [Expanded before](https://github.com/user-attachments/assets/377356c2-15f9-4d26-9572-af2ee51624e0) · [Expanded after](https://github.com/user-attachments/assets/96562d58-8e05-4ebb-99bf-0285eaf55c1b) ## **Pre-merge author checklist** - [x] 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). - [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 - [ ] 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. <!-- CURSOR_AGENT_PR_BODY_END --> <div><a href="https://cursor.com/agents/bc-b3180cce-a244-5330-95e3-35b5951ff3b4?cursor_ref=pr_footer&cursor_cta=open_in_web"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/open-in-web-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/open-in-web-light.png"><img alt="Open in Web" width="114" height="28" src="https://cursor.com/assets/images/open-in-web-dark.png"></picture></a> <a href="https://cursor.com/background-agent?bcId=bc-b3180cce-a244-5330-95e3-35b5951ff3b4&cursor_ref=pr_footer&cursor_cta=open_in_cursor"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/open-in-cursor-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/open-in-cursor-light.png"><img alt="Open in Cursor" width="131" height="28" src="https://cursor.com/assets/images/open-in-cursor-dark.png"></picture></a> </div> [TMCU-1741]: https://consensyssoftware.atlassian.net/browse/TMCU-1741?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ [TMCU-1741]: https://consensyssoftware.atlassian.net/browse/TMCU-1741?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Medium Risk** > The same hero control drives several MM Pay confirmation flows; visual and sizing behavior change via the shared component, though fiat display rules and input constraints stay equivalent. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 30842bf. 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 Agent <cursoragent@cursor.com> Co-authored-by: George Marshall <georgewrmarshall@users.noreply.github.com>
…taMask#47559) <!-- CURSOR_AGENT_PR_BODY_BEGIN --> Stacked on MetaMask#47564 (shared font-size helper) — merge that first. ## **Description** This is the @MetaMask/money-movement slice of the Grotzec large number amount inputs. It was split from the UAT build in MetaMask#47557, which has the full plan, the input inventory and the risks. - Ticket: [TMCU-1743](https://consensyssoftware.atlassian.net/browse/TMCU-1743) - Epic: [TMCU-1741 [Extension] Update large number amount inputs with Grotzec](https://consensyssoftware.atlassian.net/browse/TMCU-1741) **Depends on MetaMask#47564** (the shared amount scale and `useAmountInputFontSize` hook). This PR is stacked on MetaMask#47564's branch (`cursor/grotzec-amount-input-scale-f3b4`) and does not carry its own copy of the helper, so its diff shows only this slice. Merge MetaMask#47564 first, then retarget this PR to `main`. **What is the reason for the change?** The Buy amount was a fixed 56px Inter (`text-[56px] font-normal leading-none`) with no shrink by length. Mobile's Ramp quote screen ([MetaMask#38406](MetaMask/metamask-mobile#38406)) moves the same amount to Grotzec, starting at 88px. **What is the improvement?** - **MMDS `Input`.** The `<input>` is now the MMDS `Input` (`textVariant={AmountDisplayLg}`, `font-hero`). The hidden-text measuring pattern stays. The symbol and measuring element are MMDS `Text` (`AmountDisplayLg` + `FontFamily.Hero`), so all three share the same family, weight, tracking and size. - **Sizing: shared scale.** The Buy amount uses the scale in MetaMask#47564 (`ui/helpers/utils/amount-input-font-size.ts`), the same one used by Swap/Bridge, Perps withdraw and the MM Pay amount. It has steps of 88, 72, 60, 48, 40, 32, 24 and 20px, takes the largest step at which the symbol and amount fit the row's measured width (`useAmountInputFontSize`, one `ResizeObserver` per input; 328px is only the fallback before the first measurement), and sets line height equal to font size. At the 328px popup width, `$100` is 88px and `$1234567.89` is 72px. In the expanded view long amounts stay large instead of shrinking early. The 88px start matches Mobile MetaMask#38406. The fixed steps follow the gradual shape of Mobile's per-character curve, and the floor is MM Pay's 20px. - **KRW fix.** The scale estimates width per character from measured Grotzec widths, and counts fallback symbols such as ₩ (0.94em) at 1em. A 10-digit KRW amount (`₩1234567890`) now drops to 60px in the popup and fits the row. Before, the character count kept it at 64px and it spilled about 7px over. - **Stable layout.** The amount row is pinned at 88px, the largest step, so the payment pill doesn't move as the amount shrinks, as on Mobile. - **View model.** `amountTextClassName` (which carried the fixed `text-[56px]`) is replaced by `hasAmountError`. The view picks the size with `useAmountInputFontSize` on the amount row. **Risks** - Grotzec has `$` `€` `£` `¥` but no ₹ ₩ ₽ ₺ ₦ ₱ ₫ ฿ ₪. Those symbols fall back per character to `'Helvetica Neue', Helvetica, Arial`, as on Mobile. The measuring element uses the same stack, so the input width stays exact. - The weight changes from 400 Inter to the Bold Grotzec cut. - Snapshot updated: `ramps/build-quote/__snapshots__/build-quote.test.tsx.snap`. ## **Changelog** CHANGELOG entry: Updated the Buy amount input to the Grotzec typeface ## **Related issues** Fixes: [TMCU-1743](https://consensyssoftware.atlassian.net/browse/TMCU-1743) Epic: [TMCU-1741](https://consensyssoftware.atlassian.net/browse/TMCU-1741) Depends on: MetaMask#47564 Split from: MetaMask#47557 ## **Manual testing steps** 1. Load this branch in the extension and open Buy for any token. 2. Confirm `$100` renders in Grotzec at 88px. 3. Type `1234567.89` one key at a time and confirm the amount steps down to 72px without the payment pill moving. 4. Trigger a quote error and confirm the symbol and amount turn red. 5. Switch the region or currency to KRW and type `1234567890`. Confirm the amount fits the row at 60px. Check INR and EUR symbols too. 6. Repeat in the expanded view, where long amounts stay larger instead of shrinking early, and in the side panel, where they step down smoothly as the width narrows. ## **Screenshots/Recordings** ### Before / After by code owner Before is `main` @adeaf9ad59 and After is the UAT head (MetaMask#47557) @28a7077e43, both recorded with the same typing script (type 5, then 500000000000000000, then clear). #### Ramps Buy | Before | After | | --- | --- | | <img width="360" src="https://github.com/user-attachments/assets/d91dbfbb-2b31-4277-b39b-c877d1caf777" alt="Ramps Buy before, side panel"> | <img width="360" src="https://github.com/user-attachments/assets/c81cb5f7-21db-46b5-86b6-20c6702b2249" alt="Ramps Buy after, side panel"> | | <img width="360" src="https://github.com/user-attachments/assets/90eb701f-3d2b-4af5-8a9d-313a51ecd614" alt="Ramps Buy before, expanded view"> | <img width="360" src="https://github.com/user-attachments/assets/4c243f97-3db9-47ab-8583-88a2a27826de" alt="Ramps Buy after, expanded view"> | Full MP4s: [Side panel before](https://github.com/user-attachments/assets/f12c8d69-ebfb-4eaa-8bbd-5d86dd2caf85) · [Side panel after](https://github.com/user-attachments/assets/02ba6962-aec8-41d6-b473-9f61fa3b6409) · [Expanded before](https://github.com/user-attachments/assets/1a559b4d-706c-4dae-8865-37c49801ce4d) · [Expanded after](https://github.com/user-attachments/assets/d9c5cde4-4a96-4064-a188-821b49ac8c34) > **Note:** On main, the side panel field overflows at 18 digits and the page scrolls sideways (the Continue button slides off). ## **Pre-merge author checklist** - [x] 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). - [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 - [ ] 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. <!-- CURSOR_AGENT_PR_BODY_END --> <div><a href="https://cursor.com/agents/bc-b3180cce-a244-5330-95e3-35b5951ff3b4?cursor_ref=pr_footer&cursor_cta=open_in_web"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/open-in-web-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/open-in-web-light.png"><img alt="Open in Web" width="114" height="28" src="https://cursor.com/assets/images/open-in-web-dark.png"></picture></a> <a href="https://cursor.com/background-agent?bcId=bc-b3180cce-a244-5330-95e3-35b5951ff3b4&cursor_ref=pr_footer&cursor_cta=open_in_cursor"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/open-in-cursor-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/open-in-cursor-light.png"><img alt="Open in Cursor" width="131" height="28" src="https://cursor.com/assets/images/open-in-cursor-dark.png"></picture></a> </div> [TMCU-1743]: https://consensyssoftware.atlassian.net/browse/TMCU-1743?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ [TMCU-1743]: https://consensyssoftware.atlassian.net/browse/TMCU-1743?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Medium Risk** > Changes the primary Buy amount entry UI and moves decimal validation out of the amount hook into a shared component, which affects quote debouncing and error display on a money-movement path. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 5f625dd. 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 Agent <cursoragent@cursor.com> Co-authored-by: George Marshall <georgewrmarshall@users.noreply.github.com>
…Mask#47558) <!-- CURSOR_AGENT_PR_BODY_BEGIN --> Stacked on MetaMask#47564 (shared font-size helper) — merge that first. ## **Description** This is the @MetaMask/swaps-engineers slice of the Grotzec large number amount inputs. It was split from the UAT build in MetaMask#47557, which has the full plan, the input inventory and the risks. - Ticket: [TMCU-1742](https://consensyssoftware.atlassian.net/browse/TMCU-1742) - Epic: [TMCU-1741 [Extension] Update large number amount inputs with Grotzec](https://consensyssoftware.atlassian.net/browse/TMCU-1741) **Depends on MetaMask#47564** (the shared amount scale and `useAmountInputFontSize` hook). This PR is stacked on MetaMask#47564's branch (`cursor/grotzec-amount-input-scale-f3b4`) and does not carry its own copy of the helper, so its diff shows only this slice. Merge MetaMask#47564 first, then retarget this PR to `main`. **What is the reason for the change?** Read-only large amounts moved to `AmountDisplayLg` + Hero in MetaMask#47464–MetaMask#47468. The Swap/Bridge source and destination inputs were still Inter at weight 400. They also overflowed early: a 14-character value was cut off in the 219px popup field. **What is the improvement?** - **MMDS `Input`.** The legacy `TextField` is replaced with an MMDS `Box` row containing an MMDS `Text` prefix and an MMDS `Input` (`textVariant={AmountDisplayLg}`, `font-hero`). `data-testid`, `value`, `disabled`, `readOnly`, `autoFocus`, `autocomplete="off"`, the key filter, paste sanitising and click-to-focus are kept. The read-only destination field stays at 50% opacity until it has a value. - **Sizing: shared scale.** Every large amount input now uses the scale in MetaMask#47564 (`ui/helpers/utils/amount-input-font-size.ts`). It has steps of 88, 72, 60, 48, 40, 32, 24 and 20px, takes the largest step at which the text fits the field's measured width (`useAmountInputFontSize`, one `ResizeObserver` per field), and sets line height equal to font size. - **Bridge exception: starts at 48px.** Swap/Bridge is the one layout that starts lower: `maxFontSize: 48`. Its fallback width is 219px (`AMOUNT_FIELD_FALLBACK_WIDTH`, the popup field width), used only until the field has been measured. It has two stacked amount fields beside the asset pickers, so the 88px start would roughly double the height of each field. Bridge stays on the same steps (48, 40, 32, 24, 20px). 48px matches the Home and Money balance size. - **Widths.** The text estimate counts the fiat prefix and uses measured Grotzec glyph widths, and the budget is the field's measured width. In the 219px popup field, `1234567.123456` is 32px; 12 digits fit at 40px, 15 at 32px and 21 at 24px. In the wider expanded-view field, long amounts stay at 48px instead of shrinking early. Longer values scroll inside the field at 20px. - **Cleanup.** The `.mm-text-field` and `.defined` rules in `prepare/index.scss` only targeted the old markup, so they are removed along with the `defined` class toggle in `prepare-bridge-page.tsx`. **Risks** - Grotzec has no ₹ ₩ ₿ ₽ ₺ ₦ ₱ ₫ ฿ ₪, so a fiat prefix in those currencies falls back to `'Helvetica Neue', Helvetica, Arial`, as on Mobile. The shared scale budgets 1em for those glyphs. - The 48px start is an exception to the shared 88px start and needs design sign-off. Mobile's Bridge input is not on Grotzec yet. - Snapshots updated: `bridge/__snapshots__/index.test.tsx.snap`, `bridge/prepare/__snapshots__/prepare-bridge-page.test.tsx.snap`. ## **Changelog** CHANGELOG entry: Updated the Swap and Bridge amount inputs to the Grotzec typeface ## **Related issues** Fixes: [TMCU-1742](https://consensyssoftware.atlassian.net/browse/TMCU-1742) Epic: [TMCU-1741](https://consensyssoftware.atlassian.net/browse/TMCU-1741) Depends on: MetaMask#47564 Split from: MetaMask#47557 ## **Manual testing steps** 1. Load this branch in the extension and open Swap in the popup. 2. Enter `1`, then type `1234567.123456789` one key at a time. Confirm the amount is Grotzec and steps 48 → 40 → 32 → 24px in the popup without being cut off. 3. Type a letter and a second `.`; confirm both are rejected. Paste `1,234.5` and confirm it becomes `1234.5`. 4. Click beside the number in the source field and confirm the input is focused. 5. Toggle to fiat and confirm the currency prefix matches the amount size. 6. Before a quote arrives, confirm the destination shows a dimmed `0` and the loading skeleton; once a quote arrives, confirm it shows at full opacity. 7. Repeat in the expanded view, where the same value stays at 48px, and in the side panel, where it steps down smoothly as the field narrows. ## **Screenshots/Recordings** ### Before / After by code owner Before is `main` @adeaf9ad59 and After is the UAT head (MetaMask#47557) @28a7077e43, both recorded with the same typing script (type 5, then 500000000000000000, then clear). #### Swap/Bridge | Before | After | | --- | --- | | <img width="360" src="https://github.com/user-attachments/assets/aa53a2c2-2691-426c-90e8-1c497fbfb5b6" alt="Swap/Bridge before, side panel"> | <img width="360" src="https://github.com/user-attachments/assets/804e50aa-0be4-46a4-87a4-10c5d5988849" alt="Swap/Bridge after, side panel"> | | <img width="360" src="https://github.com/user-attachments/assets/37b2c2b5-9881-45e7-88f4-21772fe48dd3" alt="Swap/Bridge before, expanded view"> | <img width="360" src="https://github.com/user-attachments/assets/6b91925e-ee22-4900-b57d-e09239c032a2" alt="Swap/Bridge after, expanded view"> | Full MP4s: [Side panel before](https://github.com/user-attachments/assets/41cbd326-5a90-462e-8c53-6acfe6dd725f) · [Side panel after](https://github.com/user-attachments/assets/150496d1-0b7d-4595-addb-61542bff16a1) · [Expanded before](https://github.com/user-attachments/assets/031b69fc-e40c-4c9d-a287-ae3bc0fdeacd) · [Expanded after](https://github.com/user-attachments/assets/21f4812b-e75d-465d-a42b-ceccf4826f75) > **Note:** With the same mocks, main shows "This trade route isn't available right now" for the long amount; this is unrelated to the input. ## **Pre-merge author checklist** - [x] 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). - [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 - [ ] 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. <!-- CURSOR_AGENT_PR_BODY_END --> <div><a href="https://cursor.com/agents/bc-b3180cce-a244-5330-95e3-35b5951ff3b4?cursor_ref=pr_footer&cursor_cta=open_in_web"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/open-in-web-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/open-in-web-light.png"><img alt="Open in Web" width="114" height="28" src="https://cursor.com/assets/images/open-in-web-dark.png"></picture></a> <a href="https://cursor.com/background-agent?bcId=bc-b3180cce-a244-5330-95e3-35b5951ff3b4&cursor_ref=pr_footer&cursor_cta=open_in_cursor"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/open-in-cursor-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/open-in-cursor-light.png"><img alt="Open in Cursor" width="131" height="28" src="https://cursor.com/assets/images/open-in-cursor-dark.png"></picture></a> </div> [TMCU-1742]: https://consensyssoftware.atlassian.net/browse/TMCU-1742?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ [TMCU-1742]: https://consensyssoftware.atlassian.net/browse/TMCU-1742?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Medium Risk** > Changes core swap/bridge amount entry UX and validation paths (input component, dynamic font sizing, destination placeholder styling) on a high-traffic flow; depends on stacked MetaMask#47564 behavior. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit dd25b98. 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 Agent <cursoragent@cursor.com> Co-authored-by: George Marshall <georgewrmarshall@users.noreply.github.com>
MetaMask#47560) <!-- CURSOR_AGENT_PR_BODY_BEGIN --> Stacked on MetaMask#47564 (shared font-size helper) — merge that first. ## **Description** This is the @MetaMask/perps slice of the Grotzec large number amount inputs. It was split from the UAT build in MetaMask#47557, which has the full plan, the input inventory and the risks. - Ticket: [TMCU-1744](https://consensyssoftware.atlassian.net/browse/TMCU-1744) - Epic: [TMCU-1741 [Extension] Update large number amount inputs with Grotzec](https://consensyssoftware.atlassian.net/browse/TMCU-1741) **Depends on MetaMask#47564** (the shared amount scale and `useAmountInputFontSize` hook). This PR is stacked on MetaMask#47564's branch (`cursor/grotzec-amount-input-scale-f3b4`) and does not carry its own copy of the helper, so its diff shows only this slice. Merge MetaMask#47564 first, then retarget this PR to `main`. **What is the reason for the change?** The Perps withdraw amount was Inter at weight 500 and 64/40/30/20px. Perps balances and prices moved to Grotzec in MetaMask#47465. This input is the twin of the MM Pay `CustomAmount`, which Mobile moves to Grotzec at 88px in [MetaMask#38135](MetaMask/metamask-mobile#38135). **What is the improvement?** - **MMDS `Input`.** The `<input>` is now the MMDS `Input` (`textVariant={AmountDisplayLg}`, `font-hero`). The hidden-text measuring pattern stays. The symbol and measuring element are MMDS `Text` (`AmountDisplayLg` + `FontFamily.Hero`), so all three share the same family, weight and size. The explicit `fontWeight: 500` is dropped, as on Mobile. - **Sizing: shared scale.** The withdraw amount uses the scale in MetaMask#47564 (`ui/helpers/utils/amount-input-font-size.ts`), the same one used by Swap/Bridge, Ramps Buy and the MM Pay amount. It has steps of 88, 72, 60, 48, 40, 32, 24 and 20px, takes the largest step at which `$` and the amount fit the input's measured width (`useAmountInputFontSize`, one `ResizeObserver` per input; 328px is only the fallback before the first measurement), and sets line height equal to font size. In the expanded view long amounts stay large instead of shrinking early. At the 328px popup width, `$25` is 88px, `$1234567.89` is 72px and `$123456789012.34` is 48px. - **Mobile reference.** The 88px start, 88px row, 88px `rounded-lg` skeleton and 20px floor match Mobile MetaMask#38135. Mobile's MM Pay drops straight from 88px to 40px; Extension steps down gradually so mid-length amounts stay larger. - **Twin stays in sync.** The local length-based `getFontSize` is removed. Its twin, the confirmations `CustomAmount`, moves to the same scale in MetaMask#47565, so the two can no longer drift. **Risks** - The weight changes from 500 Inter to the Bold Grotzec cut. Perps is USD only, and Grotzec has `$`, so there is no glyph fallback. ## **Changelog** CHANGELOG entry: Updated the Perps withdraw amount input to the Grotzec typeface ## **Related issues** Fixes: [TMCU-1744](https://consensyssoftware.atlassian.net/browse/TMCU-1744) Epic: [TMCU-1741](https://consensyssoftware.atlassian.net/browse/TMCU-1741) Depends on: MetaMask#47564 Related: MetaMask#47565 (MM Pay custom amount twin) Split from: MetaMask#47557 ## **Manual testing steps** 1. Load this branch in the extension, open Perps and choose Withdraw. 2. Confirm the loading skeleton is 88px tall with rounded corners. 3. Enter `25` and confirm it renders in Grotzec at 88px. 4. Type `123456789012.34` one key at a time and confirm the amount steps down 88 → 72 → 60 → 48px and stays centred. 5. Enter more than the available balance and confirm the amount turns red. 6. Repeat in the expanded view, where long amounts stay larger instead of shrinking early, and in the side panel, where they step down smoothly as the width narrows. ## **Screenshots/Recordings** ### Before / After by code owner Before is `main` @adeaf9ad59 and After is the UAT head (MetaMask#47557) @28a7077e43, both recorded with the same typing script (type 5, then 500000000000000000, then clear). #### Perps withdraw | Before | After | | --- | --- | | <img width="360" src="https://github.com/user-attachments/assets/bde0cc8d-a0a6-493e-81cd-6754ac6a0a82" alt="Perps withdraw before, side panel"> | <img width="360" src="https://github.com/user-attachments/assets/87e17271-f2a9-4b2e-824f-92456a58a3eb" alt="Perps withdraw after, side panel"> | | <img width="360" src="https://github.com/user-attachments/assets/2c539038-48c1-4f5b-9ef4-85b21391df3b" alt="Perps withdraw before, expanded view"> | <img width="360" src="https://github.com/user-attachments/assets/cc7c54af-42e1-4bf9-bffc-92bd98312ead" alt="Perps withdraw after, expanded view"> | Full MP4s: [Side panel before](https://github.com/user-attachments/assets/49c2722c-88e1-41fb-8ff3-1fda48319b85) · [Side panel after](https://github.com/user-attachments/assets/573cd199-f321-4b96-aab8-790349a292a6) · [Expanded before](https://github.com/user-attachments/assets/0595640d-d948-4c3f-9ec8-fb505f8f01f7) · [Expanded after](https://github.com/user-attachments/assets/85f918b1-09ec-4359-927d-705da4ed3405) ## **Pre-merge author checklist** - [x] 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). - [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 - [ ] 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. <!-- CURSOR_AGENT_PR_BODY_END --> <div><a href="https://cursor.com/agents/bc-b3180cce-a244-5330-95e3-35b5951ff3b4?cursor_ref=pr_footer&cursor_cta=open_in_web"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/open-in-web-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/open-in-web-light.png"><img alt="Open in Web" width="114" height="28" src="https://cursor.com/assets/images/open-in-web-dark.png"></picture></a> <a href="https://cursor.com/background-agent?bcId=bc-b3180cce-a244-5330-95e3-35b5951ff3b4&cursor_ref=pr_footer&cursor_cta=open_in_cursor"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/open-in-cursor-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/open-in-cursor-light.png"><img alt="Open in Cursor" width="131" height="28" src="https://cursor.com/assets/images/open-in-cursor-dark.png"></picture></a> </div> [TMCU-1744]: https://consensyssoftware.atlassian.net/browse/TMCU-1744?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ [TMCU-1744]: https://consensyssoftware.atlassian.net/browse/TMCU-1744?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Low Risk** > Scoped UI swap on the Perps withdraw amount field with no changes to withdrawal submission, balance guards, or backend calls. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 52d1e02. 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 Agent <cursoragent@cursor.com> Co-authored-by: George Marshall <georgewrmarshall@users.noreply.github.com>
…ero cp-13.57.0 (MetaMask#47565) <!-- CURSOR_AGENT_PR_BODY_BEGIN --> Stacked on MetaMask#47564 (shared font-size helper) — merge that first. ## **Description** This is the @MetaMask/confirmations slice of the Grotzec large number amount inputs. It was split from the UAT build in MetaMask#47557. - Epic: [TMCU-1741 [Extension] Update large number amount inputs with Grotzec](https://consensyssoftware.atlassian.net/browse/TMCU-1741) - Ticket: a child ticket of [TMCU-1741](https://consensyssoftware.atlassian.net/browse/TMCU-1741) is still to be created for the MM Pay custom amount. **Depends on MetaMask#47564** (the shared amount scale and `useAmountInputFontSize` hook). This PR is stacked on MetaMask#47564's branch (`cursor/grotzec-amount-input-scale-f3b4`) and does not carry its own copy of the helper, so its diff shows only this slice. Merge MetaMask#47564 first, then retarget this PR to `main`. **What is the reason for the change?** `CustomAmount` (`ui/pages/confirmations/components/transactions/custom-amount/custom-amount.tsx`) is the MM Pay hero amount. It is used by Perps deposit, the Perps withdraw confirmation, mUSD conversion and Money account deposit and withdraw. It was still Inter at weight 500, sized 64/40/30/20px with line heights 70/44/33/22px, using legacy component-library `Text` and a raw `<input>` sized in `ch`. Mobile moves the same component to Grotzec in [MetaMask#38135](MetaMask/metamask-mobile#38135). **What is the improvement?** - **MMDS `Input`.** The `<input>` is now the MMDS `Input` (`textVariant={AmountDisplayLg}`, `font-hero`, `isStateStylesDisabled`). The symbol is MMDS `Text` `AmountDisplayLg` + `FontFamily.Hero`. - **Width.** The `ch` estimate is replaced with the hidden measuring `Text` that its Perps twin (`PerpsFiatHeroAmountInput`) uses. The measuring `Text` is set in the same font, so the input width is exact for Grotzec and for fallback symbols. - **Sizing.** Sizes come from the shared scale in MetaMask#47564: 88, 72, 60, 48, 40, 32, 24, 20px, taking the largest step at which the symbol and amount fit the input's measured width (`useAmountInputFontSize`, one `ResizeObserver` per input; 328px is only the fallback before the first measurement). Line height equals font size. In the expanded view long amounts stay large instead of shrinking early. At the 328px popup width, `$25` is 88px, `$1234567.89` is 72px and a 20-digit amount is 32px. The row and the `rounded-lg` skeleton are both 88px, as in Mobile MetaMask#38135. - **Unchanged.** Test IDs (`custom-amount-input`, `custom-amount-symbol`, `custom-amount-skeleton`), cents-only display, the 2-decimal input pattern, `autoFocus` and the alert and disabled colours are unchanged. The E2E page objects use the same test IDs. **Risks** - This changes the hero on five confirmation flows at once: Perps deposit, Perps withdraw, mUSD conversion, and Money deposit and withdraw. - Symbols Grotzec lacks (₹ ₩ ₿ …) render in the fallback family. The shared scale budgets for their extra width. - The weight changes from 500 Inter to the Bold Grotzec cut. ## **Changelog** CHANGELOG entry: Updated the MetaMask Pay amount input to the Grotzec typeface ## **Related issues** Epic: [TMCU-1741](https://consensyssoftware.atlassian.net/browse/TMCU-1741). A child ticket is still to be created. Depends on: MetaMask#47564 Split from: MetaMask#47557 ## **Manual testing steps** 1. Load this branch in the extension. 2. Start a Perps deposit. Confirm the amount is Grotzec at 88px for `25`. Then type `123456789012.34` one key at a time and confirm it steps down 88 → 72 → 60 → 48px and stays centred. 3. Click Max or a percentage and confirm the amount shows at most 2 decimals. 4. Enter more than the balance and confirm the amount turns red. 5. Repeat the short and long amount check in mUSD conversion and in Money account deposit and withdraw. 6. Repeat in the expanded view, where long amounts stay larger instead of shrinking early, and in the side panel, where they step down smoothly as the width narrows. ## **Screenshots/Recordings** ### Before / After by code owner Before is `main` @adeaf9ad59 and After is the UAT head (MetaMask#47557) @28a7077e43, both recorded with the same typing script (type 5, then 500000000000000000, then clear). #### MM Pay custom amount | Before | After | | --- | --- | | <img width="360" src="https://github.com/user-attachments/assets/ce28237e-b7de-4816-9a62-4dfab0d2577d" alt="MM Pay custom amount before, side panel"> | <img width="360" src="https://github.com/user-attachments/assets/10617750-5f69-4a1a-8700-a1e1ebef52be" alt="MM Pay custom amount after, side panel"> | | <img width="360" src="https://github.com/user-attachments/assets/a30507a6-420a-4c2a-b240-0176ec1c8f3c" alt="MM Pay custom amount before, expanded view"> | <img width="360" src="https://github.com/user-attachments/assets/7d9fbaf6-c0d0-4590-bac4-4d724808e4da" alt="MM Pay custom amount after, expanded view"> | Full MP4s: [Side panel before](https://github.com/user-attachments/assets/940444b2-140e-47f1-ae07-ad0e2a79fb68) · [Side panel after](https://github.com/user-attachments/assets/b754992c-b785-4fe0-a25c-50da625a0453) · [Expanded before](https://github.com/user-attachments/assets/377356c2-15f9-4d26-9572-af2ee51624e0) · [Expanded after](https://github.com/user-attachments/assets/96562d58-8e05-4ebb-99bf-0285eaf55c1b) ## **Pre-merge author checklist** - [x] 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). - [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 - [ ] 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. <!-- CURSOR_AGENT_PR_BODY_END --> <div><a href="https://cursor.com/agents/bc-b3180cce-a244-5330-95e3-35b5951ff3b4?cursor_ref=pr_footer&cursor_cta=open_in_web"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/open-in-web-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/open-in-web-light.png"><img alt="Open in Web" width="114" height="28" src="https://cursor.com/assets/images/open-in-web-dark.png"></picture></a> <a href="https://cursor.com/background-agent?bcId=bc-b3180cce-a244-5330-95e3-35b5951ff3b4&cursor_ref=pr_footer&cursor_cta=open_in_cursor"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/open-in-cursor-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/open-in-cursor-light.png"><img alt="Open in Cursor" width="131" height="28" src="https://cursor.com/assets/images/open-in-cursor-dark.png"></picture></a> </div> [TMCU-1741]: https://consensyssoftware.atlassian.net/browse/TMCU-1741?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ [TMCU-1741]: https://consensyssoftware.atlassian.net/browse/TMCU-1741?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Medium Risk** > The same hero control drives several MM Pay confirmation flows; visual and sizing behavior change via the shared component, though fiat display rules and input constraints stay equivalent. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 30842bf. 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 Agent <cursoragent@cursor.com> Co-authored-by: George Marshall <georgewrmarshall@users.noreply.github.com>
…tom amount input in Grotzec Hero (#47679) - chore(confirmations): set the MM Pay custom amount input in Grotzec Hero cp-13.57.0 (#47565) <!-- CURSOR_AGENT_PR_BODY_BEGIN --> Stacked on #47564 (shared font-size helper) — merge that first. ## **Description** This is the @MetaMask/confirmations slice of the Grotzec large number amount inputs. It was split from the UAT build in #47557. - Epic: [TMCU-1741 [Extension] Update large number amount inputs with Grotzec](https://consensyssoftware.atlassian.net/browse/TMCU-1741) - Ticket: a child ticket of [TMCU-1741](https://consensyssoftware.atlassian.net/browse/TMCU-1741) is still to be created for the MM Pay custom amount. **Depends on #47564** (the shared amount scale and `useAmountInputFontSize` hook). This PR is stacked on #47564's branch (`cursor/grotzec-amount-input-scale-f3b4`) and does not carry its own copy of the helper, so its diff shows only this slice. Merge #47564 first, then retarget this PR to `main`. **What is the reason for the change?** `CustomAmount` (`ui/pages/confirmations/components/transactions/custom-amount/custom-amount.tsx`) is the MM Pay hero amount. It is used by Perps deposit, the Perps withdraw confirmation, mUSD conversion and Money account deposit and withdraw. It was still Inter at weight 500, sized 64/40/30/20px with line heights 70/44/33/22px, using legacy component-library `Text` and a raw `<input>` sized in `ch`. Mobile moves the same component to Grotzec in [#38135](MetaMask/metamask-mobile#38135). **What is the improvement?** - **MMDS `Input`.** The `<input>` is now the MMDS `Input` (`textVariant={AmountDisplayLg}`, `font-hero`, `isStateStylesDisabled`). The symbol is MMDS `Text` `AmountDisplayLg` + `FontFamily.Hero`. - **Width.** The `ch` estimate is replaced with the hidden measuring `Text` that its Perps twin (`PerpsFiatHeroAmountInput`) uses. The measuring `Text` is set in the same font, so the input width is exact for Grotzec and for fallback symbols. - **Sizing.** Sizes come from the shared scale in #47564: 88, 72, 60, 48, 40, 32, 24, 20px, taking the largest step at which the symbol and amount fit the input's measured width (`useAmountInputFontSize`, one `ResizeObserver` per input; 328px is only the fallback before the first measurement). Line height equals font size. In the expanded view long amounts stay large instead of shrinking early. At the 328px popup width, `$25` is 88px, `$1234567.89` is 72px and a 20-digit amount is 32px. The row and the `rounded-lg` skeleton are both 88px, as in Mobile #38135. - **Unchanged.** Test IDs (`custom-amount-input`, `custom-amount-symbol`, `custom-amount-skeleton`), cents-only display, the 2-decimal input pattern, `autoFocus` and the alert and disabled colours are unchanged. The E2E page objects use the same test IDs. **Risks** - This changes the hero on five confirmation flows at once: Perps deposit, Perps withdraw, mUSD conversion, and Money deposit and withdraw. - Symbols Grotzec lacks (₹ ₩ ₿ …) render in the fallback family. The shared scale budgets for their extra width. - The weight changes from 500 Inter to the Bold Grotzec cut. ## **Changelog** CHANGELOG entry: Updated the MetaMask Pay amount input to the Grotzec typeface ## **Related issues** Epic: [TMCU-1741](https://consensyssoftware.atlassian.net/browse/TMCU-1741). A child ticket is still to be created. Depends on: #47564 Split from: #47557 ## **Manual testing steps** 1. Load this branch in the extension. 2. Start a Perps deposit. Confirm the amount is Grotzec at 88px for `25`. Then type `123456789012.34` one key at a time and confirm it steps down 88 → 72 → 60 → 48px and stays centred. 3. Click Max or a percentage and confirm the amount shows at most 2 decimals. 4. Enter more than the balance and confirm the amount turns red. 5. Repeat the short and long amount check in mUSD conversion and in Money account deposit and withdraw. 6. Repeat in the expanded view, where long amounts stay larger instead of shrinking early, and in the side panel, where they step down smoothly as the width narrows. ## **Screenshots/Recordings** ### Before / After by code owner Before is `main` @adeaf9ad59 and After is the UAT head (#47557) @28a7077e43, both recorded with the same typing script (type 5, then 500000000000000000, then clear). #### MM Pay custom amount | Before | After | | --- | --- | | <img width="360" src="https://github.com/user-attachments/assets/ce28237e-b7de-4816-9a62-4dfab0d2577d" alt="MM Pay custom amount before, side panel"> | <img width="360" src="https://github.com/user-attachments/assets/10617750-5f69-4a1a-8700-a1e1ebef52be" alt="MM Pay custom amount after, side panel"> | | <img width="360" src="https://github.com/user-attachments/assets/a30507a6-420a-4c2a-b240-0176ec1c8f3c" alt="MM Pay custom amount before, expanded view"> | <img width="360" src="https://github.com/user-attachments/assets/7d9fbaf6-c0d0-4590-bac4-4d724808e4da" alt="MM Pay custom amount after, expanded view"> | Full MP4s: [Side panel before](https://github.com/user-attachments/assets/940444b2-140e-47f1-ae07-ad0e2a79fb68) · [Side panel after](https://github.com/user-attachments/assets/b754992c-b785-4fe0-a25c-50da625a0453) · [Expanded before](https://github.com/user-attachments/assets/377356c2-15f9-4d26-9572-af2ee51624e0) · [Expanded after](https://github.com/user-attachments/assets/96562d58-8e05-4ebb-99bf-0285eaf55c1b) ## **Pre-merge author checklist** - [x] 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). - [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 - [ ] 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. <!-- CURSOR_AGENT_PR_BODY_END --> <div><a href="https://cursor.com/agents/bc-b3180cce-a244-5330-95e3-35b5951ff3b4?cursor_ref=pr_footer&cursor_cta=open_in_web"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/open-in-web-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/open-in-web-light.png"><img alt="Open in Web" width="114" height="28" src="https://cursor.com/assets/images/open-in-web-dark.png"></picture></a> <a href="https://cursor.com/background-agent?bcId=bc-b3180cce-a244-5330-95e3-35b5951ff3b4&cursor_ref=pr_footer&cursor_cta=open_in_cursor"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/open-in-cursor-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/open-in-cursor-light.png"><img alt="Open in Cursor" width="131" height="28" src="https://cursor.com/assets/images/open-in-cursor-dark.png"></picture></a> </div> [TMCU-1741]: https://consensyssoftware.atlassian.net/browse/TMCU-1741?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ [TMCU-1741]: https://consensyssoftware.atlassian.net/browse/TMCU-1741?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Medium Risk** > The same hero control drives several MM Pay confirmation flows; visual and sizing behavior change via the shared component, though fiat display rules and input constraints stay equivalent. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 30842bf. 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 Agent <cursoragent@cursor.com> Co-authored-by: George Marshall <georgewrmarshall@users.noreply.github.com> [d8e24a8](d8e24a8) [TMCU-1741]: https://consensyssoftware.atlassian.net/browse/TMCU-1741?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ [TMCU-1741]: https://consensyssoftware.atlassian.net/browse/TMCU-1741?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ --------- Co-authored-by: George Marshall <george.marshall@consensys.net> Co-authored-by: Cursor Agent <cursoragent@cursor.com> Co-authored-by: George Marshall <georgewrmarshall@users.noreply.github.com> Co-authored-by: metamask-ci[bot] <271559518+metamask-ci[bot]@users.noreply.github.com>
…put in Grotzec Hero (#47672) - chore(perps): set the withdraw amount input in Grotzec Hero cp-13.57.0 (#47560) <!-- CURSOR_AGENT_PR_BODY_BEGIN --> Stacked on #47564 (shared font-size helper) — merge that first. ## **Description** This is the @MetaMask/perps slice of the Grotzec large number amount inputs. It was split from the UAT build in #47557, which has the full plan, the input inventory and the risks. - Ticket: [TMCU-1744](https://consensyssoftware.atlassian.net/browse/TMCU-1744) - Epic: [TMCU-1741 [Extension] Update large number amount inputs with Grotzec](https://consensyssoftware.atlassian.net/browse/TMCU-1741) **Depends on #47564** (the shared amount scale and `useAmountInputFontSize` hook). This PR is stacked on #47564's branch (`cursor/grotzec-amount-input-scale-f3b4`) and does not carry its own copy of the helper, so its diff shows only this slice. Merge #47564 first, then retarget this PR to `main`. **What is the reason for the change?** The Perps withdraw amount was Inter at weight 500 and 64/40/30/20px. Perps balances and prices moved to Grotzec in #47465. This input is the twin of the MM Pay `CustomAmount`, which Mobile moves to Grotzec at 88px in [#38135](MetaMask/metamask-mobile#38135). **What is the improvement?** - **MMDS `Input`.** The `<input>` is now the MMDS `Input` (`textVariant={AmountDisplayLg}`, `font-hero`). The hidden-text measuring pattern stays. The symbol and measuring element are MMDS `Text` (`AmountDisplayLg` + `FontFamily.Hero`), so all three share the same family, weight and size. The explicit `fontWeight: 500` is dropped, as on Mobile. - **Sizing: shared scale.** The withdraw amount uses the scale in #47564 (`ui/helpers/utils/amount-input-font-size.ts`), the same one used by Swap/Bridge, Ramps Buy and the MM Pay amount. It has steps of 88, 72, 60, 48, 40, 32, 24 and 20px, takes the largest step at which `$` and the amount fit the input's measured width (`useAmountInputFontSize`, one `ResizeObserver` per input; 328px is only the fallback before the first measurement), and sets line height equal to font size. In the expanded view long amounts stay large instead of shrinking early. At the 328px popup width, `$25` is 88px, `$1234567.89` is 72px and `$123456789012.34` is 48px. - **Mobile reference.** The 88px start, 88px row, 88px `rounded-lg` skeleton and 20px floor match Mobile #38135. Mobile's MM Pay drops straight from 88px to 40px; Extension steps down gradually so mid-length amounts stay larger. - **Twin stays in sync.** The local length-based `getFontSize` is removed. Its twin, the confirmations `CustomAmount`, moves to the same scale in #47565, so the two can no longer drift. **Risks** - The weight changes from 500 Inter to the Bold Grotzec cut. Perps is USD only, and Grotzec has `$`, so there is no glyph fallback. ## **Changelog** CHANGELOG entry: Updated the Perps withdraw amount input to the Grotzec typeface ## **Related issues** Fixes: [TMCU-1744](https://consensyssoftware.atlassian.net/browse/TMCU-1744) Epic: [TMCU-1741](https://consensyssoftware.atlassian.net/browse/TMCU-1741) Depends on: #47564 Related: #47565 (MM Pay custom amount twin) Split from: #47557 ## **Manual testing steps** 1. Load this branch in the extension, open Perps and choose Withdraw. 2. Confirm the loading skeleton is 88px tall with rounded corners. 3. Enter `25` and confirm it renders in Grotzec at 88px. 4. Type `123456789012.34` one key at a time and confirm the amount steps down 88 → 72 → 60 → 48px and stays centred. 5. Enter more than the available balance and confirm the amount turns red. 6. Repeat in the expanded view, where long amounts stay larger instead of shrinking early, and in the side panel, where they step down smoothly as the width narrows. ## **Screenshots/Recordings** ### Before / After by code owner Before is `main` @adeaf9ad59 and After is the UAT head (#47557) @28a7077e43, both recorded with the same typing script (type 5, then 500000000000000000, then clear). #### Perps withdraw | Before | After | | --- | --- | | <img width="360" src="https://github.com/user-attachments/assets/bde0cc8d-a0a6-493e-81cd-6754ac6a0a82" alt="Perps withdraw before, side panel"> | <img width="360" src="https://github.com/user-attachments/assets/87e17271-f2a9-4b2e-824f-92456a58a3eb" alt="Perps withdraw after, side panel"> | | <img width="360" src="https://github.com/user-attachments/assets/2c539038-48c1-4f5b-9ef4-85b21391df3b" alt="Perps withdraw before, expanded view"> | <img width="360" src="https://github.com/user-attachments/assets/cc7c54af-42e1-4bf9-bffc-92bd98312ead" alt="Perps withdraw after, expanded view"> | Full MP4s: [Side panel before](https://github.com/user-attachments/assets/49c2722c-88e1-41fb-8ff3-1fda48319b85) · [Side panel after](https://github.com/user-attachments/assets/573cd199-f321-4b96-aab8-790349a292a6) · [Expanded before](https://github.com/user-attachments/assets/0595640d-d948-4c3f-9ec8-fb505f8f01f7) · [Expanded after](https://github.com/user-attachments/assets/85f918b1-09ec-4359-927d-705da4ed3405) ## **Pre-merge author checklist** - [x] 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). - [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 - [ ] 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. <!-- CURSOR_AGENT_PR_BODY_END --> <div><a href="https://cursor.com/agents/bc-b3180cce-a244-5330-95e3-35b5951ff3b4?cursor_ref=pr_footer&cursor_cta=open_in_web"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/open-in-web-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/open-in-web-light.png"><img alt="Open in Web" width="114" height="28" src="https://cursor.com/assets/images/open-in-web-dark.png"></picture></a> <a href="https://cursor.com/background-agent?bcId=bc-b3180cce-a244-5330-95e3-35b5951ff3b4&cursor_ref=pr_footer&cursor_cta=open_in_cursor"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/open-in-cursor-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/open-in-cursor-light.png"><img alt="Open in Cursor" width="131" height="28" src="https://cursor.com/assets/images/open-in-cursor-dark.png"></picture></a> </div> [TMCU-1744]: https://consensyssoftware.atlassian.net/browse/TMCU-1744?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ [TMCU-1744]: https://consensyssoftware.atlassian.net/browse/TMCU-1744?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Low Risk** > Scoped UI swap on the Perps withdraw amount field with no changes to withdrawal submission, balance guards, or backend calls. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 52d1e02. 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 Agent <cursoragent@cursor.com> Co-authored-by: George Marshall <georgewrmarshall@users.noreply.github.com> [b0f7657](b0f7657) [TMCU-1744]: https://consensyssoftware.atlassian.net/browse/TMCU-1744?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ [TMCU-1744]: https://consensyssoftware.atlassian.net/browse/TMCU-1744?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ --------- Co-authored-by: George Marshall <george.marshall@consensys.net> Co-authored-by: Cursor Agent <cursoragent@cursor.com> Co-authored-by: George Marshall <georgewrmarshall@users.noreply.github.com> Co-authored-by: metamask-ci[bot] <271559518+metamask-ci[bot]@users.noreply.github.com> Co-authored-by: sleepytanya <104780023+sleepytanya@users.noreply.github.com>
|
No release label on PR. Adding release label release-13.57.0 on PR, as PR was added to branch 13.57.0 when release was cut. |


Description
This adds
HeroAmountInput, a shared component underui/components/ui/hero-amount-input/for the large Grotzec (Hero) amount inputs. It is the base of the Grotzec amount input stack; the UAT build in #47557 combines it with every consumer.What is the reason for the change? Swap/Bridge, Ramps Buy, Perps withdraw and the MM Pay custom amount each had their own amount field and their own font-size rules, so the same amount rendered at different sizes on different screens and long amounts overflowed in some of them (for example a 10-digit KRW amount in Ramps). Design asked for one aligned behavior for every large number input.
What is the improvement? One component owns the field, the optional currency prefix, the font-size scale and the loading skeleton:
HERO_AMOUNT_FONT_SIZES), the same 88px start and 20px floor as the Mobile Grotzec inputs. Line height always equals font size so the row keeps one height.maxFontSizelets a tight layout (Swap/Bridge) start lower on the same steps. Values that don't fit at 20px stay at 20px and scroll inside the field.ResizeObserver, so typing never reads layout. The prefix is measured from an offscreen probe at a fixed 100px size, remeasured when web fonts load and when the probe mounts after the loading skeleton. Until then the prefix is estimated atprefix.length * 0.43em. Before the row has a width (for example in jsdom) the popup content width of 328px is used.shrink-0and the digit box ismin-w-0 overflow-hidden, so long amounts never paint over the$. Font size changes animate with a short transition that respectsprefers-reduced-motion.inputMode="decimal", at most one.or,separator, and an optionalmaxDecimalslimit. Error, disabled (muted text) and loading states are built in.data-testid(-prefix,-value,-input,-skeleton), andprefixProps,valuePropsandinputPropsreach the child elements, so consumer tests don't need to mock the component.test/lib/mock-resize-observer.tslets tests drive row widths.Text/Input/Skeletonand Tailwind, with no SCSS. The six smaller steps map to--font-size-10…--font-size-5; 88 and 72 have no token yet, so the chosen step is applied as an inline font size. The mapping is documented inhero-amount-input.constants.tsfor a later move to tokens.Components/UI/HeroAmountInputcovers the default, long amount, currency code, max decimals, error, disabled, read-only, loading, swap field and wide layouts.This branch also fixes two tests that #46148 broke on
mainwhen it removed "Please" from locale strings, which fails every PR based onmain:token-list-item.test.tsxbuilds the native-token scam warning from the locale message.bridge-alert-banner-list.test.tsxsnapshot uses "Select a different quote."Currency-sign alignment across experiences is tracked separately in TMCU-1761. Send is out of scope.
Merge order. Merge this PR first. The consumer PRs are stacked on this branch (
cursor/grotzec-amount-input-scale-f3b4); retarget each tomainafter this merges:Changelog
CHANGELOG entry: null
Related issues
Epic: TMCU-1741
Manual testing steps
yarn storybookand open Components / UI / HeroAmountInput.$stays fully visible.Screenshots/Recordings
Before
No Before:
HeroAmountInputis a new component.After
Screen.Recording.2026-11-04.at.8.16.37.PM.mov
Each editable story has
500000000000000000typed into it:maxFontSize40): stays at 40pxFirefox
firefox.mov
Pre-merge author checklist
Pre-merge reviewer checklist
Note
Low Risk
Additive UI module with no production wiring in this PR; behavior is covered by unit tests and Storybook, with only local amount-string validation logic.
Reviewed by Cursor Bugbot for commit 4bb5bf6. Bugbot is set up for automated code reviews on this repo. Configure here.