Skip to content
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

[DSRN] Add ButtonBase component #384

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Conversation

brianacnguyen
Copy link
Contributor

Description

This PR adds the ButtonBase component to the Primitives folder

Related issues

Fixes: #176

Manual testing steps

  1. Run yarn storybook:ios from root
  2. Go to Primitives > ButtonBase
  3. Observe component

Screenshots/Recordings

Before

After

Simulator.Screen.Recording.-.iPhone.15.Pro.Max.-.2025-01-29.at.10.11.52.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 Jan 29, 2025
@brianacnguyen brianacnguyen requested a review from a team as a code owner January 29, 2025 18:14
@@ -40,7 +40,9 @@ const ButtonAnimated = ({
};

return (
<Animated.View style={scaleStyle}>
<Animated.View
style={[scaleStyle, { alignItems: 'center', justifyContent: 'center' }]}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updating this to make sure the scale animation works as intended

Copy link
Contributor

@georgewrmarshall georgewrmarshall Jan 29, 2025

Choose a reason for hiding this comment

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

non-blocking: You could make this primitive more reusable by moving the scale animation to ButtonBase, depending on the values used in ButtonIcon.

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! Well structured component, good testing coverage. Some non-blocking comments similar to TextButton PR

@@ -40,7 +40,9 @@ const ButtonAnimated = ({
};

return (
<Animated.View style={scaleStyle}>
<Animated.View
style={[scaleStyle, { alignItems: 'center', justifyContent: 'center' }]}
Copy link
Contributor

@georgewrmarshall georgewrmarshall Jan 29, 2025

Choose a reason for hiding this comment

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

non-blocking: You could make this primitive more reusable by moving the scale animation to ButtonBase, depending on the values used in ButtonIcon.

testID: 'end-icon',
},
onPress: () => {
console.log('Button pressed');
Copy link
Contributor

Choose a reason for hiding this comment

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

non-blocking: We shouldn't use a console.log as default props. You could consider using a no-op function (() => {}) or removing the default onPress handler entirely.

Comment on lines +7 to +20
export enum ButtonBaseSize {
/**
* Represents a small button size (32px).
*/
Sm = '32',
/**
* Represents a medium button size (40px).
*/
Md = '40',
/**
* Represents a large button size (48px).
*/
Lg = '48',
}
Copy link
Contributor

Choose a reason for hiding this comment

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

non-blocking: What is the reason to use strings instead of numbers here? Using numbers may be more appropriate for size values like this and it would prevent type coercion.


### `size`

Optional prop to control the size of the `ButtonBase`.
Copy link
Contributor

Choose a reason for hiding this comment

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

non-blocking: could add it defaults to size large here

>
<View
style={tw`absolute inset-0 flex items-center justify-center opacity-${
isLoading ? '100' : '0'
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: it could be cleaner to use the whole classname here

          isLoading ? 'opacity-100' : 'opacity-0'

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 ButtonBase component in shared UI component library
2 participants