Skip to content

[DSR] Added Box component #724

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Jun 6, 2025
Merged

[DSR] Added Box component #724

merged 11 commits into from
Jun 6, 2025

Conversation

brianacnguyen
Copy link
Contributor

Description

This PR adds the Box component to the @metamask/design-system-react package

Related issues

Fixes: #668

Manual testing steps

  1. Run yarn storybook
  2. Go to Components > Box

Screenshots/Recordings

Before

After

Screen.Recording.2025-06-05.at.1.38.53.PM.mov

Pre-merge author checklist

  • I've followed MetaMask Contributor Docs
  • I've completed the PR template to the best of my ability
  • I’ve included tests if applicable
  • I’ve documented my code using JSDoc format if applicable
  • I’ve applied the right labels on the PR (see labeling guidelines). 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.

@brianacnguyen brianacnguyen self-assigned this Jun 5, 2025
@brianacnguyen brianacnguyen requested a review from a team as a code owner June 5, 2025 20:41
Copy link
Contributor

github-actions bot commented Jun 5, 2025

📖 Storybook Preview

Copy link
Contributor

github-actions bot commented Jun 5, 2025

📖 Storybook Preview

Copy link
Contributor

@georgewrmarshall georgewrmarshall left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Comment on lines +153 to +158
export enum BoxFlexDirection {
Row = 'flex-row',
RowReverse = 'flex-row-reverse',
Column = 'flex-col',
ColumnReverse = 'flex-col-reverse',
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checked against extension ✅

export enum FlexDirection {
  Row = 'row',
  RowReverse = 'row-reverse',
  Column = 'column',
  ColumnReverse = 'column-reverse',
}

https://github.com/MetaMask/metamask-extension/blob/main/ui/helpers/constants/design-system.ts#L279-L284

Comment on lines +163 to +167
export enum BoxFlexWrap {
NoWrap = 'flex-nowrap',
Wrap = 'flex-wrap',
WrapReverse = 'flex-wrap-reverse',
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checked against extension ✅

export enum FlexWrap {
  Wrap = 'wrap',
  WrapReverse = 'wrap-reverse',
  NoWrap = 'nowrap',
}

https://github.com/MetaMask/metamask-extension/blob/main/ui/helpers/constants/design-system.ts#L299-L303

/**
* Box - all spacing-related props
*/
export type BoxSpacing = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the extension, we support responsive props by allowing property values to be specified as arrays. This lets developers set different values for each breakpoint. Including null in the type definition enables skipping a specific breakpoint—for example, margin={[4, null, 8]} applies a margin of 4 at the first breakpoint, skips the second, and sets 8 at the third. However, this pattern does not have to be supported in the monorepo version.
https://github.com/MetaMask/metamask-extension/blob/main/ui/components/component-library/box/box.types.ts#L103-L117

export type SizeNumber =
  | 0
  | 1
  | 2
  | 3
  | 4
  | 5
  | 6
  | 7
  | 8
  | 9
  | 10
  | 11
  | 12
  | null;

Comment on lines +172 to +178
export enum BoxAlignItems {
Start = 'items-start',
Center = 'items-center',
End = 'items-end',
Stretch = 'items-stretch',
Baseline = 'items-baseline',
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checking against extension we are supporting each but using a different name. I think this is a reasonably breaking change

export enum AlignItems {
  flexStart = 'flex-start',
  flexEnd = 'flex-end',
  center = 'center',
  baseline = 'baseline',
  stretch = 'stretch',
}

https://github.com/MetaMask/metamask-extension/blob/main/ui/helpers/constants/design-system.ts#L262-L268

Comment on lines +183 to +190
export enum BoxJustifyContent {
Start = 'justify-start',
Center = 'justify-center',
End = 'justify-end',
Between = 'justify-between',
Around = 'justify-around',
Evenly = 'justify-evenly',
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checking against extension we are supporting each but using a different name. I think this is a reasonably breaking change

export enum JustifyContent {
  flexStart = 'flex-start',
  flexEnd = 'flex-end',
  center = 'center',
  spaceAround = 'space-around',
  spaceBetween = 'space-between',
  spaceEvenly = 'space-evenly',
}

https://github.com/MetaMask/metamask-extension/blob/main/ui/helpers/constants/design-system.ts#L270-L277

@georgewrmarshall georgewrmarshall merged commit dd0c7a7 into main Jun 6, 2025
37 checks passed
@georgewrmarshall georgewrmarshall deleted the dsr/box-initial branch June 6, 2025 02:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[React] Create Box component in shared UI component library
2 participants