Skip to content

Commit 499c56d

Browse files
joevilchesfacebook-github-bot
authored andcommitted
Text with links RN Tester example (facebook#50811)
Summary: tsia, adding some accessibility examples that we have refined so far this half. Changelog: [Internal] Reviewed By: NickGerleman Differential Revision: D73281713
1 parent f6a8ce5 commit 499c56d

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

packages/rn-tester/js/examples/Accessibility/AccessibilityExample.js

+42
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,9 @@ const styles = StyleSheet.create({
106106
width: 25,
107107
height: 25,
108108
},
109+
link: {
110+
color: 'blue',
111+
},
109112
});
110113

111114
class AccessibilityExample extends React.Component<{}> {
@@ -1737,6 +1740,39 @@ function AccessibilityOrderExample(): React.Node {
17371740
);
17381741
}
17391742

1743+
function TextLinkExample(): React.Node {
1744+
const handleLinkPress = (linkText: string) => {
1745+
Alert.alert('Link Clicked', `You clicked on the ${linkText} link!`);
1746+
};
1747+
1748+
return (
1749+
<View style={{gap: 10}}>
1750+
<RNTesterText>
1751+
We can focus{' '}
1752+
<RNTesterText
1753+
accessibilityRole="link"
1754+
onPress={() => handleLinkPress('first')}
1755+
style={styles.link}>
1756+
links
1757+
</RNTesterText>{' '}
1758+
in text, even if there are{' '}
1759+
<RNTesterText
1760+
accessibilityRole="link"
1761+
onPress={() => handleLinkPress('second')}
1762+
style={styles.link}>
1763+
multiple of them!
1764+
</RNTesterText>
1765+
</RNTesterText>
1766+
<RNTesterText
1767+
accessibilityRole="link"
1768+
onPress={() => handleLinkPress('thrid')}
1769+
style={styles.link}>
1770+
We can also focus text that are entirly links!
1771+
</RNTesterText>
1772+
</View>
1773+
);
1774+
}
1775+
17401776
exports.title = 'Accessibility';
17411777
exports.documentationURL = 'https://reactnative.dev/docs/accessibilityinfo';
17421778
exports.description = 'Examples of using Accessibility APIs.';
@@ -1840,4 +1876,10 @@ exports.examples = [
18401876
return <AccessibilityOrderExample />;
18411877
},
18421878
},
1879+
{
1880+
title: 'Links in text',
1881+
render(): React.MixedElement {
1882+
return <TextLinkExample />;
1883+
},
1884+
},
18431885
];

0 commit comments

Comments
 (0)