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] Added ButtonIcon #386

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

[DSRN] Added ButtonIcon #386

wants to merge 1 commit into from

Conversation

brianacnguyen
Copy link
Contributor

Description

This PR adds ButtonIcon to the dsrn library

Related issues

Fixes: #315

Manual testing steps

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

Screenshots/Recordings

Before

After

Simulator.Screen.Recording.-.iPhone.15.Pro.Max.-.2025-01-29.at.11.59.09.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 20:04
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.

Nice work! Well structured and documented component. One blocking question about an accessibilityLabel

Comment on lines +101 to +115
export const AllIcons: Story = {
render: () => (
<ScrollView>
<View style={{ flexWrap: 'wrap', flexDirection: 'row', padding: 16 }}>
{Object.values(IconName).map((iconName) => (
<ButtonIconStory
key={iconName}
iconName={iconName}
size={DEFAULT_BUTTONICON_PROPS.size}
/>
))}
</View>
</ScrollView>
),
};
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.

nit: This story seems more appropriate for icons.

Screenshot 2025-01-29 at 2 20 28 PM

ButtonIconProps,
'iconName' | 'size' | 'isDisabled' | 'isInverse' | 'isFloating'
> = {
iconName: IconName.Add,
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: would close be a more appropriate default icon as it's likely the most used with ButtonIcon


### `size`

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

Choose a reason for hiding this comment

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

nit: add default size

Comment on lines +23 to +62
export type ButtonIconProps = {
/**
* Optional prop to control the size of the icon
* Different sizes map to specific pixel dimensions
* @default IconSize.Md
*/
size?: ButtonIconSize;
/**
* Optional prop to specify an icon to show
*/
iconName: IconName;
/**
* Optional prop to pass additional properties to the icon
*/
iconProps?: Partial<IconProps>;
/**
* Optional prop that when true, disables the button
* @default false
*/
isDisabled?: boolean;
/**
* Optional prop to show the inverse state of the button, which is reserved for buttons on colored backgrounds.
* @default false
*/
isInverse?: boolean;
/**
* Optional prop to show the floating/contained state of the button, which is reserved for floating buttons.
* Note: This prop provides styling only. There is no positioning logic.
* @default false
*/
isFloating?: boolean;
/**
* Optional prop to add twrnc overriding classNames.
*/
twClassName?: string;
/**
* Optional prop to control the style.
*/
style?: StyleProp<ViewStyle>;
} & Omit<PressableProps, 'children'>;
Copy link
Contributor

Choose a reason for hiding this comment

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

possibly blocking: I noticed we don't have a required accessibilityLabel prop for the icon. I'm not very familiar with accessibility best practices for mobile, but I think labeling icon buttons is important. How should we handle the equivalent of aria-label in React Native, and how should it be applied here?

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 ButtonIcon component
2 participants