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

fix: Updated ButtonLink to use text when size is auto #7971

Merged
merged 2 commits into from
Dec 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -88,25 +88,19 @@ exports[`CustomSpendCap should match snapshot 1`] = `
/>
</View>
</View>
<TouchableOpacity
activeOpacity={1}
<Text
accessibilityRole="text"
onPress={[Function]}
onPressIn={[Function]}
onPressOut={[Function]}
style={
Object {
"alignItems": "center",
"alignSelf": "flex-start",
"backgroundColor": "transparent",
"borderRadius": 0,
"flexDirection": "row",
"height": "auto",
"justifyContent": "center",
"paddingHorizontal": 0,
"color": "#24272A",
}
}
suppressHighlighting={true}
textVariant="sBodyMD"
variant="Link"
>
<Text
accessibilityRole="text"
Expand All @@ -123,7 +117,7 @@ exports[`CustomSpendCap should match snapshot 1`] = `
>
Use site suggestion
</Text>
</TouchableOpacity>
</Text>
</View>
<View
style={
Expand Down Expand Up @@ -225,24 +219,18 @@ exports[`CustomSpendCap should match snapshot 1`] = `
>
This allows the third party to spend all your token balance until it reaches the cap or you revoke the spending cap. If this is not intended, consider setting a lower spending cap.

<TouchableOpacity
activeOpacity={1}
<Text
accessibilityRole="text"
onPress={[Function]}
onPressIn={[Function]}
onPressOut={[Function]}
style={
Object {
"alignItems": "center",
"alignSelf": "flex-start",
"backgroundColor": "transparent",
"borderRadius": 0,
"flexDirection": "row",
"height": "auto",
"justifyContent": "center",
"paddingHorizontal": 0,
"color": "#24272A",
}
}
variant="Link"
suppressHighlighting={true}
>
<Text
accessibilityRole="text"
Expand All @@ -259,7 +247,7 @@ exports[`CustomSpendCap should match snapshot 1`] = `
>
Learn more
</Text>
</TouchableOpacity>
</Text>
</Text>
</View>
</View>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,24 +72,18 @@ exports[`BannerAlert should render BannerAlert 1`] = `
>
Sample Banner Alert Description
</Text>
<TouchableOpacity
activeOpacity={1}
<Text
accessibilityRole="text"
onPress={[Function]}
onPressIn={[Function]}
onPressOut={[Function]}
style={
Object {
"alignItems": "center",
"alignSelf": "flex-start",
"backgroundColor": "transparent",
"borderRadius": 0,
"flexDirection": "row",
"height": "auto",
"justifyContent": "center",
"paddingHorizontal": 0,
"color": "#24272A",
}
}
variant="Link"
suppressHighlighting={true}
>
<Text
accessibilityRole="text"
Expand All @@ -106,7 +100,7 @@ exports[`BannerAlert should render BannerAlert 1`] = `
>
Sample Action Button Label
</Text>
</TouchableOpacity>
</Text>
</View>
<View
style={
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,24 +82,18 @@ exports[`BannerTip should render default settings correctly 1`] = `
>
Sample Banner Tip Description
</Text>
<TouchableOpacity
activeOpacity={1}
<Text
accessibilityRole="text"
onPress={[Function]}
onPressIn={[Function]}
onPressOut={[Function]}
style={
Object {
"alignItems": "center",
"alignSelf": "flex-start",
"backgroundColor": "transparent",
"borderRadius": 0,
"flexDirection": "row",
"height": "auto",
"justifyContent": "center",
"paddingHorizontal": 0,
"color": "#24272A",
}
}
variant="Link"
suppressHighlighting={true}
>
<Text
accessibilityRole="text"
Expand All @@ -116,7 +110,7 @@ exports[`BannerTip should render default settings correctly 1`] = `
>
Sample Action Button Label
</Text>
</TouchableOpacity>
</Text>
</View>
<View
style={
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { GestureResponderEvent } from 'react-native';
import Text from '../../../../Texts/Text';
import { useStyles } from '../../../../../hooks';
import Button from '../../foundation/ButtonBase';
import { ButtonSize } from '../../Button.types';

// Internal dependencies.
import { ButtonLinkProps } from './ButtonLink.types';
Expand Down Expand Up @@ -71,15 +72,30 @@ const ButtonLink: React.FC<ButtonLinkProps> = ({
);

return (
<Button
style={styles.base}
label={renderLabel()}
labelColor={getLabelColor()}
onPressIn={triggerOnPressedIn}
onPressOut={triggerOnPressedOut}
size={size}
{...props}
/>
<>
{size === ButtonSize.Auto ? (
<Text
style={styles.base}
suppressHighlighting
onPressIn={triggerOnPressedIn}
onPressOut={triggerOnPressedOut}
accessibilityRole="link"
{...props}
>
{renderLabel()}
</Text>
) : (
<Button
style={styles.base}
label={renderLabel()}
labelColor={getLabelColor()}
onPressIn={triggerOnPressedIn}
onPressOut={triggerOnPressedOut}
size={size}
{...props}
/>
)}
</>
);
};

Expand Down
Original file line number Diff line number Diff line change
@@ -1,25 +1,26 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Link should render correctly 1`] = `
<ButtonBase
label={
<Fragment>
<Text
accessibilityRole="link"
onPress={[Function]}
onPressIn={[Function]}
onPressOut={[Function]}
style={
Object {
"backgroundColor": "transparent",
}
}
suppressHighlighting={true}
>
<Text
color="Primary"
style={false}
variant="sBodyMD"
>
I'm a Link!
</Text>
}
labelColor="Primary"
onPress={[Function]}
onPressIn={[Function]}
onPressOut={[Function]}
size="auto"
style={
Object {
"backgroundColor": "transparent",
}
}
/>
</Text>
</Fragment>
`;
Loading