Skip to content

Commit 2251fc6

Browse files
hejsztynxCopilot
andauthored
docs: mention guides refinement and text alignment section tweak (#778)
# Summary - now you can reclick an `alignment` option in the `Text alignment` demo, to set the `alignment` back to `'auto'` - in both mention guides the layout jumped when query changed, provided a bottom margin, so list has the space to render - now in `emoji picker` guide, you can apply an emoji (call `setMention`), by closing the query with a typed `':'` --------- Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
1 parent 0585b57 commit 2251fc6

3 files changed

Lines changed: 29 additions & 8 deletions

File tree

docs/src/examples/EmojiEditor.tsx

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ export default function App() {
3232

3333
const suggestions = useMemo(() => {
3434
if (!open) return [];
35-
// A trailing ":" (as in ":smile:") is part of the query - drop it.
36-
const q = query.replace(/:$/, '').toLowerCase();
37-
return EMOJIS.filter(emoji => emoji.shortcode.startsWith(q));
35+
return EMOJIS.filter(emoji =>
36+
emoji.shortcode.startsWith(query.toLowerCase())
37+
);
3838
}, [open, query]);
3939

4040
const openPicker = () => {
@@ -50,6 +50,16 @@ export default function App() {
5050
const updateQuery = ({ text }: OnChangeMentionEvent) => {
5151
setOpen(true);
5252
setQuery(text);
53+
54+
if (text.endsWith(':')) {
55+
const strippedQuery = text.slice(0, text.length - 1).toLowerCase();
56+
const autoChosenEmoji = EMOJIS.find(
57+
emoji => emoji.shortcode === strippedQuery
58+
);
59+
if (autoChosenEmoji) {
60+
pick(autoChosenEmoji);
61+
}
62+
}
5363
};
5464

5565
const pick = (emoji: Emoji) => {
@@ -61,7 +71,7 @@ export default function App() {
6171
};
6272

6373
return (
64-
<View style={styles.container}>
74+
<View>
6575
<EnrichedTextInput
6676
ref={ref}
6777
style={styles.input}
@@ -102,16 +112,20 @@ const htmlStyle: HtmlStyle = {
102112
};
103113

104114
const styles = StyleSheet.create({
105-
container: { gap: 8 },
106115
input: {
107116
fontSize: 18,
108117
color: '#232736',
109118
padding: 12,
119+
marginBottom: 186,
110120
borderRadius: 12,
111121
minHeight: 96,
112122
backgroundColor: '#eef0ff',
113123
},
114124
picker: {
125+
position: 'absolute',
126+
top: '100%',
127+
marginTop: -170,
128+
width: '100%',
115129
borderWidth: 1,
116130
borderColor: '#dfe3f5',
117131
borderRadius: 12,

docs/src/examples/MentionOnlyEditor.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ export default function App() {
7070
};
7171

7272
return (
73-
<View style={styles.container}>
73+
<View>
7474
<EnrichedTextInput
7575
ref={ref}
7676
style={styles.input}
@@ -118,16 +118,20 @@ const htmlStyle: HtmlStyle = {
118118
};
119119

120120
const styles = StyleSheet.create({
121-
container: { gap: 8 },
122121
input: {
123122
fontSize: 18,
124123
color: '#232736',
125124
padding: 12,
125+
marginBottom: 192,
126126
borderRadius: 12,
127127
minHeight: 96,
128128
backgroundColor: '#eef0ff',
129129
},
130130
picker: {
131+
position: 'absolute',
132+
top: '100%',
133+
marginTop: -176,
134+
width: '100%',
131135
borderWidth: 1,
132136
borderColor: '#dfe3f5',
133137
borderRadius: 12,

docs/src/examples/TextAlignmentEditor.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,10 @@ export default function App() {
2020
<Pressable
2121
key={alignment}
2222
style={[styles.button, isActive && styles.buttonActive]}
23-
onPress={() => ref.current?.setTextAlignment(alignment)}>
23+
onPress={() => {
24+
const alignmentToSet = isActive ? 'auto' : alignment;
25+
ref.current?.setTextAlignment(alignmentToSet);
26+
}}>
2427
<Text style={[styles.text, isActive && styles.textActive]}>
2528
{alignment}
2629
</Text>

0 commit comments

Comments
 (0)