Skip to content

Commit a82b411

Browse files
committed
feat(home): add press feedback to action grid buttons
Scale down on press and switch the pill from bg-muted to bg-muted-pressed to match MainActionButton interaction cues.
1 parent f3757a9 commit a82b411

1 file changed

Lines changed: 54 additions & 36 deletions

File tree

app/components/Views/Homepage/components/HomepageActionButtonsGrid/HomepageActionButton.tsx

Lines changed: 54 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from 'react';
2-
import { Pressable } from 'react-native';
2+
import { Animated, Pressable } from 'react-native';
33
import {
44
Box,
55
BoxAlignItems,
@@ -14,6 +14,7 @@ import {
1414
TextVariant,
1515
} from '@metamask/design-system-react-native';
1616
import { useTailwind } from '@metamask/design-system-twrnc-preset';
17+
import { useAnimatedPressable } from '../../../../../component-library/hooks';
1718

1819
export interface HomepageActionButtonProps {
1920
iconName: IconName;
@@ -28,6 +29,7 @@ export interface HomepageActionButtonProps {
2829
/**
2930
* Presentation-only circular action button (icon pill + label).
3031
* Navigation and analytics live in each `buttons/*Button.tsx` caller.
32+
* Press feedback: slight scale-down + muted → muted-pressed pill background.
3133
*/
3234
const HomepageActionButton = ({
3335
iconName,
@@ -39,45 +41,61 @@ const HomepageActionButton = ({
3941
}: HomepageActionButtonProps) => {
4042
const tw = useTailwind();
4143
const labelNumberOfLines = allowTwoLineLabel ? 2 : 1;
44+
const { scaleAnim, handlePressIn, handlePressOut } = useAnimatedPressable();
4245

4346
return (
44-
<Pressable
45-
accessibilityRole="button"
46-
accessibilityState={{ disabled: isDisabled }}
47-
disabled={isDisabled}
48-
onPress={isDisabled ? undefined : onPress}
49-
style={tw.style(
50-
'min-w-0 flex-1 items-center',
51-
isDisabled ? 'opacity-50' : 'opacity-100',
52-
)}
53-
testID={testID}
47+
<Animated.View
48+
style={[
49+
tw.style('min-w-0 flex-1'),
50+
{ transform: [{ scale: scaleAnim }] },
51+
]}
5452
>
55-
<Box
56-
alignItems={BoxAlignItems.Center}
57-
justifyContent={BoxJustifyContent.Center}
58-
twClassName="h-14 w-14 rounded-full border border-muted bg-muted"
53+
<Pressable
54+
accessibilityRole="button"
55+
accessibilityState={{ disabled: isDisabled }}
56+
disabled={isDisabled}
57+
onPress={isDisabled ? undefined : onPress}
58+
onPressIn={isDisabled ? undefined : handlePressIn}
59+
onPressOut={isDisabled ? undefined : handlePressOut}
60+
style={tw.style(
61+
'w-full items-center',
62+
isDisabled ? 'opacity-50' : 'opacity-100',
63+
)}
64+
testID={testID}
5965
>
60-
<Icon
61-
color={IconColor.IconAlternative}
62-
name={iconName}
63-
size={IconSize.Lg}
64-
/>
65-
</Box>
66-
<Text
67-
color={TextColor.TextDefault}
68-
ellipsizeMode="tail"
69-
fontWeight={FontWeight.Medium}
70-
numberOfLines={labelNumberOfLines}
71-
twClassName={
72-
allowTwoLineLabel
73-
? 'mt-2 min-h-[40px] w-full text-center'
74-
: 'mt-2 w-full text-center'
75-
}
76-
variant={TextVariant.BodySm}
77-
>
78-
{label}
79-
</Text>
80-
</Pressable>
66+
{({ pressed }) => (
67+
<>
68+
<Box
69+
alignItems={BoxAlignItems.Center}
70+
justifyContent={BoxJustifyContent.Center}
71+
twClassName={`h-14 w-14 rounded-full border border-muted ${
72+
pressed && !isDisabled ? 'bg-muted-pressed' : 'bg-muted'
73+
}`}
74+
>
75+
<Icon
76+
color={IconColor.IconAlternative}
77+
name={iconName}
78+
size={IconSize.Lg}
79+
/>
80+
</Box>
81+
<Text
82+
color={TextColor.TextDefault}
83+
ellipsizeMode="tail"
84+
fontWeight={FontWeight.Medium}
85+
numberOfLines={labelNumberOfLines}
86+
twClassName={
87+
allowTwoLineLabel
88+
? 'mt-2 min-h-[40px] w-full text-center'
89+
: 'mt-2 w-full text-center'
90+
}
91+
variant={TextVariant.BodySm}
92+
>
93+
{label}
94+
</Text>
95+
</>
96+
)}
97+
</Pressable>
98+
</Animated.View>
8199
);
82100
};
83101

0 commit comments

Comments
 (0)