Skip to content

Commit 7cd0b42

Browse files
NickGerlemanfacebook-github-bot
authored andcommitted
Add text examples combining textAlign, attachments, script direction, and layout direction (#52445)
Summary: Pull Request resolved: #52445 This shows some broken stuff (TM), but also asserts current behaviors Changelog: [Internal] Reviewed By: joevilches Differential Revision: D77702743 fbshipit-source-id: a20d5b09e84d86a16e2443726ac82416b13796a8
1 parent fc535ef commit 7cd0b42

1 file changed

Lines changed: 86 additions & 0 deletions

File tree

packages/rn-tester/js/examples/Text/TextSharedExamples.js

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,85 @@ function NumberOfLinesTextLayoutExample(): React.Node {
110110
);
111111
}
112112

113+
component RtlInlineViewExample(
114+
label: string,
115+
testID: string,
116+
children: React.Node,
117+
) {
118+
return (
119+
<View testID={testID} style={{flexDirection: 'row', flexGrow: 1}}>
120+
<RNTesterText variant="label" style={{width: 100, fontSize: 10}}>
121+
{label}
122+
</RNTesterText>
123+
<View style={{flexGrow: 1}}>{children}</View>
124+
</View>
125+
);
126+
}
127+
128+
component RtlAndInlineViewsExample() {
129+
return (
130+
<View style={{rowGap: 5}}>
131+
<RtlInlineViewExample
132+
label="RTL script in LTR Layout with end attachment"
133+
testID="rtl-inline-view-example-1">
134+
<RNTesterText style={{textAlign: 'left', direction: 'ltr'}}>
135+
مَٰنِ ٱلرَّحِيمِ
136+
<View style={{width: 10, height: 10, backgroundColor: 'red'}} />
137+
</RNTesterText>
138+
</RtlInlineViewExample>
139+
140+
<RtlInlineViewExample
141+
label="LTR script in RTL layout with middle attachment"
142+
testID="rtl-inline-view-example-2">
143+
<RNTesterText style={{textAlign: 'left', direction: 'rtl'}}>
144+
Hello
145+
<View style={{width: 10, height: 10, backgroundColor: 'red'}} />{' '}
146+
World!
147+
</RNTesterText>
148+
</RtlInlineViewExample>
149+
150+
<RtlInlineViewExample
151+
label="RTL script in LTR layout with start attachment"
152+
testID="rtl-inline-view-example-3">
153+
<RNTesterText style={{textAlign: 'left', direction: 'ltr'}}>
154+
<View style={{width: 10, height: 10, backgroundColor: 'red'}} />
155+
مَٰنِ ٱلرَّحِيمِ
156+
</RNTesterText>
157+
</RtlInlineViewExample>
158+
159+
<RtlInlineViewExample
160+
label="RTL script in RTL layout with end attachment"
161+
testID="rtl-inline-view-example-4">
162+
<RNTesterText style={{textAlign: 'left', direction: 'rtl'}}>
163+
مَٰنِ ٱلرَّحِيمِ
164+
<View style={{width: 10, height: 10, backgroundColor: 'red'}} />
165+
</RNTesterText>
166+
</RtlInlineViewExample>
167+
168+
<RtlInlineViewExample
169+
label="RTL dominant BiDi script in RTL layout with end attachments"
170+
testID="rtl-inline-view-example-5">
171+
<RNTesterText style={{textAlign: 'left', direction: 'rtl'}}>
172+
مَٰنِ ٱلرَّحِيمِ
173+
<View style={{width: 10, height: 10, backgroundColor: 'red'}} /> Hello
174+
<View style={{width: 10, height: 10, backgroundColor: 'blue'}} />
175+
</RNTesterText>
176+
</RtlInlineViewExample>
177+
178+
<RtlInlineViewExample
179+
label="LTR dominant BiDi script in RTL layout with end attachments"
180+
testID="rtl-inline-view-example-6">
181+
<RNTesterText style={{textAlign: 'left', direction: 'rtl'}}>
182+
Hello
183+
<View style={{width: 10, height: 10, backgroundColor: 'red'}} />
184+
مَٰنِ ٱلرَّحِيمِ
185+
<View style={{width: 10, height: 10, backgroundColor: 'blue'}} />
186+
</RNTesterText>
187+
</RtlInlineViewExample>
188+
</View>
189+
);
190+
}
191+
113192
export default [
114193
{
115194
title: 'Empty Text',
@@ -124,6 +203,13 @@ export default [
124203
expect: 'The red box should align correctly with the rest of the text.',
125204
render: TextInlineViewsExample,
126205
},
206+
{
207+
title: 'RTL and Inline Views',
208+
name: 'rtlInlineViews',
209+
description: 'RTL Script and Layout Direction, Combined with Inline Views',
210+
scrollable: true,
211+
render: RtlAndInlineViewsExample,
212+
},
127213
{
128214
title: 'numberOfLines with onTextLayout',
129215
name: 'numberOfLinesLayout',

0 commit comments

Comments
 (0)