Skip to content

[DSRN] Add BadgeNetwork#470

Merged
brianacnguyen merged 7 commits intomainfrom
dsrn/badge-network
Mar 21, 2025
Merged

[DSRN] Add BadgeNetwork#470
brianacnguyen merged 7 commits intomainfrom
dsrn/badge-network

Conversation

@brianacnguyen
Copy link
Copy Markdown
Contributor

@brianacnguyen brianacnguyen commented Mar 11, 2025

Description

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

Related issues

Fixes: #396

Manual testing steps

  1. Run yarn storybook:ios from root
  2. Go to Components > BadgeNetwork

Screenshots/Recordings

Before

After

Simulator.Screen.Recording.-.iPhone.15.Pro.Max.-.2025-03-13.at.08.59.54.mp4

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 Mar 11, 2025
@brianacnguyen brianacnguyen requested a review from a team as a code owner March 11, 2025 02:58
@brianacnguyen brianacnguyen marked this pull request as draft March 11, 2025 02:58
Copy link
Copy Markdown
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.

Coming along! Some more stories and it will be close.

@brianacnguyen brianacnguyen marked this pull request as ready for review March 13, 2025 16:02
twClassName: '',
},
render: (args) => <BadgeNetwork {...args} src={storyImageSource} />,
};
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should there be more stories here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@georgewrmarshall there are no sizes, so no size stories. what other stories are you looking for?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Generally we should have a story for each prop, what does the badge look like when there is no image or the image fails? What doest the fallback look like? etc

Comment thread packages/design-system-react-native/src/components/BadgeNetwork/BadgeNetwork.tsx Outdated
Copy link
Copy Markdown
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.

Looking good! I think it might be good to expose some of the intentional props that we want to carry over from AvatarNetwork as well as add the stories and tests for them.

Copy link
Copy Markdown
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.

Left a couple non-blocking comments

Comment on lines +21 to +27
### `name` (Optional)

Used to generate fallback text when the image or SVG fails to load.

| TYPE | REQUIRED | DEFAULT |
| :------- | :------- | :---------- |
| `string` | No | `undefined` |
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If name is used for the fallback if the image fails should it be required?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

it's currently not required in mobile

Comment on lines +9 to +28
describe('BadgeNetwork', () => {
it('renders an AvatarNetwork with size forced to Xs and forwards additional props', () => {
const { getByTestId } = render(
<BadgeNetwork
src={remoteImageSrc}
testID="badge-network"
imageProps={{ testID: 'image-or-svg' }}
/>,
);
const renderedComponent = getByTestId('badge-network');
expect(renderedComponent).toBeTruthy();
expect(renderedComponent.props.style[0].height.toString()).toStrictEqual(
(Number(AvatarNetworkSize.Xs) + 2).toString(),
);

expect(renderedComponent.props.children[1].props.src).toStrictEqual(
remoteImageSrc,
);
});
});
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

non-blocking: Not sure if we need to test for the default size? Some things to consider, what happens when the image fails? Should name be a required prop?

@brianacnguyen brianacnguyen merged commit 0671d38 into main Mar 21, 2025
36 checks passed
@brianacnguyen brianacnguyen deleted the dsrn/badge-network branch March 21, 2025 20:43
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 Native]: Create BadgeNetwork component in shared UI component library

2 participants