Skip to content

Commit 111146c

Browse files
Fix right-side spacing: 16px gap between button and dismiss icon
Address design review feedback from dubielzyk-expensify: - Use gap4 (16px) between the CTA button and dismiss icon on wide layout - Bundle the button and dismiss icon into a single rightComponent so their spacing is controlled independently of the container gap Co-authored-by: Shubham Agrawal <shubham1206agra@users.noreply.github.com>
1 parent 9dee2f2 commit 111146c

1 file changed

Lines changed: 47 additions & 22 deletions

File tree

src/components/AgentPromotionalBanner.tsx

Lines changed: 47 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,14 @@ import {View} from 'react-native';
44
import {useMemoizedLazyExpensifyIcons, useMemoizedLazyIllustrations} from '@hooks/useLazyAsset';
55
import useLocalize from '@hooks/useLocalize';
66
import useResponsiveLayout from '@hooks/useResponsiveLayout';
7+
import useTheme from '@hooks/useTheme';
78
import useThemeStyles from '@hooks/useThemeStyles';
89
import BillingBanner from '@pages/settings/Subscription/CardSection/BillingBanner/BillingBanner';
10+
import CONST from '@src/CONST';
911
import Badge from './Badge';
1012
import Button from './Button';
13+
import Icon from './Icon';
14+
import {PressableWithoutFeedback} from './Pressable';
1115
import Text from './Text';
1216

1317
type AgentPromotionalBannerProps = {
@@ -38,6 +42,7 @@ type AgentPromotionalBannerProps = {
3842

3943
function AgentPromotionalBanner({title, subtitle, onDismiss, dismissSentryLabel, ctaText, onCtaPress, ctaSentryLabel, style}: AgentPromotionalBannerProps) {
4044
const styles = useThemeStyles();
45+
const theme = useTheme();
4146
const {translate} = useLocalize();
4247
const {shouldUseNarrowLayout} = useResponsiveLayout();
4348
const illustrations = useMemoizedLazyIllustrations(['AiBot']);
@@ -63,33 +68,57 @@ function AgentPromotionalBanner({title, subtitle, onDismiss, dismissSentryLabel,
6368
[title, styles, translate],
6469
);
6570

71+
const dismissIcon = useMemo(
72+
() => (
73+
<PressableWithoutFeedback
74+
onPress={onDismiss}
75+
style={[styles.touchableButtonImage]}
76+
role={CONST.ROLE.BUTTON}
77+
accessibilityLabel={translate('common.dismiss')}
78+
sentryLabel={dismissSentryLabel}
79+
>
80+
<Icon
81+
src={expensifyIcons.Close}
82+
fill={theme.icon}
83+
/>
84+
</PressableWithoutFeedback>
85+
),
86+
[onDismiss, styles.touchableButtonImage, translate, dismissSentryLabel, expensifyIcons.Close, theme.icon],
87+
);
88+
6689
const rightComponent = useMemo(() => {
6790
if (!hasCta) {
68-
return null;
91+
return dismissIcon;
6992
}
7093
if (shouldUseNarrowLayout) {
7194
return (
72-
<View style={[styles.flex0, styles.flexBasis100, styles.maxWidth100Percentage, styles.justifyContentCenter]}>
73-
<Button
74-
success
75-
medium
76-
text={ctaText}
77-
onPress={onCtaPress}
78-
sentryLabel={ctaSentryLabel}
79-
/>
80-
</View>
95+
<>
96+
{dismissIcon}
97+
<View style={[styles.flex0, styles.flexBasis100, styles.maxWidth100Percentage, styles.justifyContentCenter]}>
98+
<Button
99+
success
100+
medium
101+
text={ctaText}
102+
onPress={onCtaPress}
103+
sentryLabel={ctaSentryLabel}
104+
/>
105+
</View>
106+
</>
81107
);
82108
}
83109
return (
84-
<Button
85-
success
86-
medium
87-
text={ctaText}
88-
onPress={onCtaPress}
89-
sentryLabel={ctaSentryLabel}
90-
/>
110+
<View style={[styles.flexRow, styles.gap4, styles.alignItemsCenter]}>
111+
<Button
112+
success
113+
medium
114+
text={ctaText}
115+
onPress={onCtaPress}
116+
sentryLabel={ctaSentryLabel}
117+
/>
118+
{dismissIcon}
119+
</View>
91120
);
92-
}, [hasCta, shouldUseNarrowLayout, ctaText, onCtaPress, ctaSentryLabel, styles]);
121+
}, [hasCta, shouldUseNarrowLayout, ctaText, onCtaPress, ctaSentryLabel, styles, dismissIcon]);
93122

94123
return (
95124
<View style={style}>
@@ -99,10 +128,6 @@ function AgentPromotionalBanner({title, subtitle, onDismiss, dismissSentryLabel,
99128
subtitle={subtitle}
100129
subtitleStyle={[styles.mt1, styles.textLabel]}
101130
style={[styles.borderRadiusComponentLarge]}
102-
rightIcon={expensifyIcons.Close}
103-
onRightIconPress={onDismiss}
104-
rightIconAccessibilityLabel={translate('common.dismiss')}
105-
rightIconSentryLabel={dismissSentryLabel}
106131
rightComponent={rightComponent}
107132
/>
108133
</View>

0 commit comments

Comments
 (0)