@openpeepshq/rn-components 0.3.6 → 0.3.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/package.json +1 -1
  2. package/src/components/custom/common/empty-state-container.tsx +42 -114
  3. package/src/components/custom/common/index.ts +1 -0
  4. package/src/components/custom/common/plus-fab.tsx +23 -0
  5. package/src/components/custom/headers/tab-screens-header.tsx +3 -4
  6. package/src/components/custom/navigation/side-menu.tsx +40 -78
  7. package/src/components/icons/index.ts +6 -0
  8. package/src/components/jams/CreateNewJam.tsx +3 -4
  9. package/src/components/navigation/auth-wrapper.tsx +1 -1
  10. package/src/components/notifications/NotificationItem.tsx +1 -1
  11. package/src/components/notifications/NotificationsList.tsx +5 -1
  12. package/src/components/post/Feed.tsx +3 -1
  13. package/src/components/post/FeedPost.tsx +32 -37
  14. package/src/components/post/FeedPostContent.tsx +6 -8
  15. package/src/components/post/NewEventButton.tsx +3 -8
  16. package/src/components/post/NewNoteButton.tsx +3 -5
  17. package/src/components/post/feed/events/EventsFeed.tsx +1 -0
  18. package/src/components/post/pieces/PostActions.tsx +46 -121
  19. package/src/components/post/pieces/PostInfoHeader.tsx +9 -5
  20. package/src/components/post/post-form/Footer.tsx +47 -64
  21. package/src/components/post/post-form/OpenpeepsMarkdownInput.tsx +3 -0
  22. package/src/components/post/post-form/PollComposerFields.tsx +2 -2
  23. package/src/components/post/post-form/PostForm.tsx +133 -129
  24. package/src/components/post/types/Note.tsx +1 -1
  25. package/src/components/post/types/Poll.tsx +1 -1
  26. package/src/components/post/types/article/CardArticle.tsx +1 -1
  27. package/src/components/post/types/event/CardEvent.tsx +1 -1
  28. package/src/components/post/types/event/FullEvent.tsx +21 -20
  29. package/src/components/profile/ProfileCard.tsx +1 -1
  30. package/src/components/profile/ProfileHeader.tsx +8 -10
  31. package/src/pages/Explore.tsx +30 -5
  32. package/src/pages/Members.tsx +2 -2
  33. package/src/pages/Tags.tsx +8 -2
  34. package/src/pages/articles/Index.tsx +18 -2
  35. package/src/pages/conversations/Index.tsx +21 -4
  36. package/src/pages/conversations/New.tsx +8 -1
  37. package/src/pages/feeds/Local.tsx +8 -2
  38. package/src/pages/feeds/My.tsx +13 -3
  39. package/src/pages/groups/Index.tsx +23 -1
  40. package/src/pages/groups/Info.tsx +4 -4
  41. package/src/pages/groups/Show.tsx +42 -3
  42. package/src/pages/posts/Edit.tsx +43 -5
  43. package/src/pages/posts/New.tsx +121 -74
  44. package/src/pages/posts/Reply.tsx +77 -49
  45. package/src/pages/profile/Followers.tsx +4 -1
  46. package/src/pages/profile/Following.tsx +4 -1
@@ -1,5 +1,4 @@
1
1
  import React from 'react';
2
- import { Pressable } from 'react-native';
3
2
  import { useTranslation } from 'react-i18next';
4
3
  import { useNavigation } from '@react-navigation/native';
5
4
  import { NativeStackNavigationProp } from '@react-navigation/native-stack';
@@ -10,6 +9,7 @@ import {
10
9
  type VisibilityType,
11
10
  } from '@openpeepshq/common';
12
11
  import { getNewPostStores, useAuthData } from '@openpeepshq/react';
12
+ import { PlusFab } from '../custom/common/plus-fab';
13
13
  import { PlusIcon } from '../icons/index';
14
14
  import { MainStackParamList } from '../navigation/types/index';
15
15
 
@@ -43,13 +43,8 @@ export const NewEventButton = ({
43
43
  };
44
44
 
45
45
  return (
46
- <Pressable
47
- accessibilityRole="button"
48
- accessibilityLabel={t('events.form.title')}
49
- onPress={openNewEvent}
50
- className="absolute bottom-10 right-6 z-20 size-16 items-center justify-center rounded-full bg-foreground"
51
- >
46
+ <PlusFab accessibilityLabel={t('events.form.title')} onPress={openNewEvent}>
52
47
  <PlusIcon size={24} className="text-background" />
53
- </Pressable>
48
+ </PlusFab>
54
49
  );
55
50
  };
@@ -1,5 +1,4 @@
1
1
  import React from 'react';
2
- import { Pressable } from 'react-native';
3
2
  import { useTranslation } from 'react-i18next';
4
3
  import {
5
4
  canCreatePost,
@@ -8,6 +7,7 @@ import {
8
7
  type VisibilityType,
9
8
  } from '@openpeepshq/common';
10
9
  import { useAuthData } from '@openpeepshq/react';
10
+ import { PlusFab } from '../custom/common/plus-fab';
11
11
  import { PencilLineIcon } from '../icons/index';
12
12
  import { useNewPostModal } from './post-form/NewPostModalContext';
13
13
 
@@ -34,13 +34,11 @@ export const NewNoteButton = ({
34
34
  if (!canPost) return null;
35
35
 
36
36
  return (
37
- <Pressable
38
- accessibilityRole="button"
37
+ <PlusFab
39
38
  accessibilityLabel={t('posts.form.title')}
40
39
  onPress={() => openNewPost({ visibility, group })}
41
- className="absolute bottom-10 right-6 z-20 size-16 items-center justify-center rounded-full bg-foreground"
42
40
  >
43
41
  <PencilLineIcon size={24} className="text-background" />
44
- </Pressable>
42
+ </PlusFab>
45
43
  );
46
44
  };
@@ -67,6 +67,7 @@ export const EventsFeed = ({ query, searchQuery, type = 'event' }: Props) => {
67
67
  ) : (
68
68
  <EmptyStateContainer
69
69
  type={type === 'event' ? 'events' : 'my-jams'}
70
+ copyKey="feed.empty"
70
71
  />
71
72
  )}
72
73
  </>
@@ -1,38 +1,24 @@
1
- import React, { useState } from 'react';
2
- import { View, ActivityIndicator } from 'react-native';
1
+ import React from 'react';
2
+ import { View } from 'react-native';
3
3
  import { Button } from '../../ui/button';
4
4
  import { ThemedText } from '../../ui/themed-text';
5
- import {
6
- Repeat2Icon,
7
- MessageSquareIcon,
8
- ThumbsUpIcon,
9
- } from '../../icons/index';
10
- import { Separator } from '../../ui/separator';
5
+ import { Repeat2Icon, ReplyIcon, ThumbsUpIcon } from '../../icons/index';
11
6
  import { type PublicPost } from '@openpeepshq/common';
12
- import { getReactionCount } from '@openpeepshq/common';
13
7
  import { useTranslation } from 'react-i18next';
14
- import { useNavigation } from '@react-navigation/native';
15
- import { NativeStackNavigationProp } from '@react-navigation/native-stack';
16
- import { MainStackParamList } from '../../navigation/types/index';
17
8
  import { useFeedPostActions } from '@openpeepshq/react';
18
9
 
19
10
  interface PostActionsProps {
20
11
  post: PublicPost;
21
12
  previewMode?: boolean;
22
- onPostPress?: () => void;
23
13
  }
24
14
 
25
15
  export const PostActions = ({
26
16
  post,
27
- onPostPress,
28
17
  previewMode = false,
29
18
  }: PostActionsProps) => {
30
19
  const { t } = useTranslation();
31
- const [isReacting, setIsReacting] = useState(false);
32
- const [isReposting, setIsReposting] = useState(false);
33
- const navigation =
34
- useNavigation<NativeStackNavigationProp<MainStackParamList>>();
35
20
  const {
21
+ me,
36
22
  myRepost,
37
23
  iReacted,
38
24
  canReply,
@@ -42,113 +28,52 @@ export const PostActions = ({
42
28
  toggleRepost,
43
29
  toggleReaction,
44
30
  } = useFeedPostActions(post);
45
- const hasReposted = !!myRepost;
46
31
 
47
- const reactionCount = getReactionCount(post);
32
+ if (!me) {
33
+ return null;
34
+ }
48
35
 
49
- const handleReplyPress = () => {
50
- reply();
51
- };
52
-
53
- const handleRepost = async () => {
54
- setIsReposting(true);
55
- try {
56
- await toggleRepost();
57
- } finally {
58
- setIsReposting(false);
59
- }
60
- };
61
-
62
- const handleFavorite = async () => {
63
- setIsReacting(true);
64
- try {
65
- await toggleReaction();
66
- } finally {
67
- setIsReacting(false);
68
- }
69
- };
70
-
71
- const handleSeeThread = () => {
72
- onPostPress ? onPostPress() : navigation.navigate('Post', { id: post.id });
73
- };
36
+ const actionClass = 'flex-1 flex-row items-center gap-2 native:p-2';
74
37
 
75
38
  return (
76
- <View className="px-5">
77
- <Separator className="my-3" />
78
- <View className="flex-row justify-between">
79
- <Button
80
- disabled={previewMode}
81
- onPress={handleSeeThread}
82
- variant="ghost"
83
- className="flex-row items-center native:p-0 gap-2"
84
- >
85
- <ThemedText>
86
- {post.data?.type === 'event'
87
- ? t('posts.actions.seeEvent')
88
- : t('posts.actions.seeThread')}
89
- </ThemedText>
90
- </Button>
91
- <Button
92
- disabled={previewMode || !canReply}
93
- onPress={handleReplyPress}
94
- variant="ghost"
95
- className="flex-row items-center native:p-0 gap-2"
96
- >
97
- <MessageSquareIcon size={18} className="text-foreground" />
98
- <ThemedText className="text-xl font-semibold">
99
- {post.replyCount}
100
- </ThemedText>
101
- </Button>
102
-
103
- <Button
104
- disabled={isReacting || previewMode || !canReact}
105
- onPress={handleFavorite}
106
- variant="ghost"
107
- className="flex-row items-center native:p-0 gap-2"
108
- >
109
- <ThumbsUpIcon
110
- size={18}
111
- className={iReacted ? 'text-destructive' : 'text-foreground'}
112
- fill={iReacted ? 'red' : 'none'}
113
- />
114
- {isReacting ? (
115
- <ActivityIndicator size="small" />
116
- ) : (
117
- <ThemedText className={iReacted ? 'text-destructive' : ''}>
118
- {reactionCount['👍']}
119
- </ThemedText>
120
- )}
121
- </Button>
122
-
123
- <Button
124
- onPress={handleRepost}
125
- variant="ghost"
126
- disabled={isReposting || previewMode || !canRepost}
127
- className="flex-row items-center native:p-0 gap-2"
128
- >
129
- {hasReposted ? (
130
- <>
131
- <Repeat2Icon size={18} className="text-foreground" fill="green" />
132
- {isReposting && <ActivityIndicator size="small" />}
133
- {!isReposting && (
134
- <ThemedText className="text-xl text-green-500 font-semibold">
135
- {post.repostCount}
136
- </ThemedText>
137
- )}
138
- </>
139
- ) : (
140
- <>
141
- <Repeat2Icon size={18} className="text-foreground" />
142
- {isReposting && <ActivityIndicator size="small" />}
143
- {!isReposting && (
144
- <ThemedText className="text-xl font-semibold">
145
- {post.repostCount}
146
- </ThemedText>
147
- )}
148
- </>
149
- )}
150
- </Button>
151
- </View>
39
+ <View className="w-full flex-row items-center py-2">
40
+ <Button
41
+ variant="ghost"
42
+ disabled={previewMode || !canReply}
43
+ onPress={() => reply()}
44
+ className={`${actionClass} justify-start`}
45
+ >
46
+ <ReplyIcon size={16} className="text-foreground" />
47
+ <ThemedText className="text-sm">{t('posts.footer.reply')}</ThemedText>
48
+ </Button>
49
+ <Button
50
+ variant="ghost"
51
+ disabled={previewMode || !canRepost}
52
+ onPress={() => void toggleRepost()}
53
+ className={`${actionClass} justify-center`}
54
+ >
55
+ <Repeat2Icon
56
+ size={16}
57
+ className={myRepost ? 'text-primary' : 'text-foreground'}
58
+ />
59
+ <ThemedText className={`text-sm ${myRepost ? 'text-primary' : ''}`}>
60
+ {t('posts.footer.repost')}
61
+ </ThemedText>
62
+ </Button>
63
+ <Button
64
+ variant="ghost"
65
+ disabled={previewMode || !canReact}
66
+ onPress={() => void toggleReaction()}
67
+ className={`${actionClass} justify-end`}
68
+ >
69
+ <ThumbsUpIcon
70
+ size={16}
71
+ className={iReacted ? 'text-primary' : 'text-foreground'}
72
+ />
73
+ <ThemedText className={`text-sm ${iReacted ? 'text-primary' : ''}`}>
74
+ {t('posts.footer.like')}
75
+ </ThemedText>
76
+ </Button>
152
77
  </View>
153
78
  );
154
79
  };
@@ -8,6 +8,7 @@ import { NativeStackNavigationProp } from '@react-navigation/native-stack';
8
8
  import { MainStackParamList } from '../../navigation/types/index';
9
9
  import { ProfileAvatar } from '../../profile/Avatar';
10
10
  import { ProfileHandle, ProfileName } from '../../profile/ProfilePieces';
11
+ import { ThemedText } from '../../ui/themed-text';
11
12
  import { ThemedView } from '../../ui/themed-view';
12
13
 
13
14
  interface PostHeaderProps {
@@ -25,8 +26,8 @@ export const PostInfoHeader = ({
25
26
  useNavigation<NativeStackNavigationProp<MainStackParamList>>();
26
27
 
27
28
  return (
28
- <ThemedView className="flex-row mt-3 mb-5 px-5 justify-between items-center">
29
- <ThemedView className="flex-row gap-3">
29
+ <ThemedView className="flex-row items-center justify-between py-2">
30
+ <ThemedView className="flex-row gap-2">
30
31
  <TouchableOpacity
31
32
  onPress={() =>
32
33
  navigation.navigate('Profile', {
@@ -34,12 +35,15 @@ export const PostInfoHeader = ({
34
35
  })
35
36
  }
36
37
  >
37
- <ProfileAvatar profile={post.profile} className="size-14" />
38
+ <ProfileAvatar profile={post.profile} className="size-10" />
38
39
  </TouchableOpacity>
39
40
  <ThemedView>
40
41
  <ProfileName profile={[post.profile]} />
41
- <ProfileHandle profile={[post.profile]} />
42
- <UpdatingDate date={post.createdAt as string} />
42
+ <ThemedView className="flex-row items-center gap-1">
43
+ <ProfileHandle profile={[post.profile]} />
44
+ <ThemedText className="text-xs text-muted-foreground">·</ThemedText>
45
+ <UpdatingDate date={post.createdAt as string} />
46
+ </ThemedView>
43
47
  </ThemedView>
44
48
  </ThemedView>
45
49
  {showMenu && <PostMenu post={post} deleteCallback={deleteCallback} />}
@@ -1,78 +1,61 @@
1
1
  import { View } from 'react-native';
2
- import React from 'react';
3
- import { ThemedText } from '../../ui/themed-text';
2
+ import React, { type ReactNode } from 'react';
4
3
  import { Button } from '../../ui/button';
5
- import {
6
- ImageIcon,
7
- FilmIcon,
8
- ChartColumnIcon,
9
- NotebookIcon,
10
- PaperclipIcon,
11
- NewspaperIcon,
12
- } from '../../icons/index';
13
- import { PostCreationData, PostType } from '@openpeepshq/common';
14
- import { maxContentLength, maxArticleContentLength } from '../../../lib/utils';
4
+ import { ImageIcon, AudioLinesIcon, PaperclipIcon } from '../../icons/index';
5
+ import { useTranslation } from 'react-i18next';
15
6
 
16
7
  interface FooterProps {
17
- content: PostCreationData;
18
8
  onImagePress: () => void;
19
- onMicPress: () => void;
20
- onVideoPress: () => void;
21
- onPollPress: () => void;
9
+ onAudioPress: () => void;
22
10
  onDocumentPress: () => void;
23
- onArticlePress: () => void;
24
- postType?: PostType | undefined;
11
+ typeSwitcher?: ReactNode;
12
+ hideMedia?: boolean;
25
13
  }
26
14
 
27
- export default function Footer({
28
- content,
15
+ export const Footer = ({
29
16
  onImagePress,
30
- onVideoPress,
31
- onPollPress,
17
+ onAudioPress,
32
18
  onDocumentPress,
33
- onArticlePress,
34
- postType = 'note',
35
- }: FooterProps) {
19
+ typeSwitcher,
20
+ hideMedia = false,
21
+ }: FooterProps) => {
22
+ const { t } = useTranslation();
23
+
36
24
  return (
37
- <View className="absolute bottom-2 w-full">
38
- <View className="flex-row justify-between items-center p-4">
39
- <ThemedText className="text-muted-foreground">
40
- {String(
41
- (postType === 'note' || postType === 'question'
42
- ? maxContentLength
43
- : maxArticleContentLength) - (content?.data.content ?? '').length
44
- )}
45
- </ThemedText>
46
- <View className="flex-row gap-8">
47
- {postType !== 'article' && (
48
- <>
49
- <Button size={'icon'} variant={'ghost'} onPress={onImagePress}>
50
- <ImageIcon size={24} className="text-foreground" />
51
- </Button>
52
- <Button size={'icon'} variant={'ghost'} onPress={onDocumentPress}>
53
- <PaperclipIcon size={24} className="text-foreground" />
54
- </Button>
55
- <Button size={'icon'} variant={'ghost'} onPress={onVideoPress}>
56
- <FilmIcon size={24} className="text-foreground" />
57
- </Button>
58
- </>
59
- )}
60
- <Button size={'icon'} variant={'ghost'} onPress={onPollPress}>
61
- {postType === 'question' ? (
62
- <NotebookIcon size={24} className="text-foreground" />
63
- ) : (
64
- <ChartColumnIcon size={24} className="text-foreground" />
65
- )}
66
- </Button>
67
- <Button size={'icon'} variant={'ghost'} onPress={onArticlePress}>
68
- {postType === 'article' ? (
69
- <NotebookIcon size={24} className="text-foreground" />
70
- ) : (
71
- <NewspaperIcon size={24} className="text-foreground" />
72
- )}
73
- </Button>
74
- </View>
25
+ <View className="border-t border-border bg-background px-4 py-3">
26
+ <View className="flex-row items-center justify-between">
27
+ {hideMedia ? (
28
+ <View />
29
+ ) : (
30
+ <View className="flex-row items-center gap-2">
31
+ <Button
32
+ size="icon"
33
+ variant="ghost"
34
+ accessibilityLabel={t('posts.form.addImage')}
35
+ onPress={onImagePress}
36
+ >
37
+ <ImageIcon size={20} className="text-foreground" />
38
+ </Button>
39
+ <Button
40
+ size="icon"
41
+ variant="ghost"
42
+ accessibilityLabel={t('posts.form.addAudio')}
43
+ onPress={onAudioPress}
44
+ >
45
+ <AudioLinesIcon size={20} className="text-foreground" />
46
+ </Button>
47
+ <Button
48
+ size="icon"
49
+ variant="ghost"
50
+ accessibilityLabel={t('posts.form.addDocument')}
51
+ onPress={onDocumentPress}
52
+ >
53
+ <PaperclipIcon size={20} className="text-foreground" />
54
+ </Button>
55
+ </View>
56
+ )}
57
+ {typeSwitcher}
75
58
  </View>
76
59
  </View>
77
60
  );
78
- }
61
+ };
@@ -30,6 +30,7 @@ export interface OpenpeepsMarkdownInputProps {
30
30
  /** Extra classes for the textarea. */
31
31
  className?: string;
32
32
  testId?: string;
33
+ autoFocus?: boolean;
33
34
  }
34
35
 
35
36
  const mentionQueryFrom = (text: string, cursor: number) => {
@@ -51,6 +52,7 @@ export const OpenpeepsMarkdownInput = ({
51
52
  previewButton = true,
52
53
  className,
53
54
  testId,
55
+ autoFocus = false,
54
56
  }: OpenpeepsMarkdownInputProps) => {
55
57
  const { t } = useTranslation();
56
58
  const { openpeepsApi } = useOpenpeeps();
@@ -191,6 +193,7 @@ export const OpenpeepsMarkdownInput = ({
191
193
  ) : null}
192
194
 
193
195
  <Textarea
196
+ autoFocus={autoFocus}
194
197
  numberOfLines={rows}
195
198
  value={value}
196
199
  maxLength={maxLength}
@@ -31,7 +31,7 @@ export const PollComposerFields: React.FC<PollFormProps> = ({
31
31
  };
32
32
 
33
33
  return (
34
- <View className="px-4 pt-4 w-full flex flex-col gap-4">
34
+ <View className="pt-4 w-full flex flex-col gap-4">
35
35
  {options?.map((_, index) => (
36
36
  <View key={index} className="flex-row gap-x-1 items-center w-full">
37
37
  <FormField
@@ -92,7 +92,7 @@ export const PollComposerFields: React.FC<PollFormProps> = ({
92
92
  <ThemedText className="text-muted-foreground">
93
93
  {expiresAt
94
94
  ? formatDateTime(new Date(expiresAt))
95
- : '03/15/2025, 02:50 PM'}
95
+ : t('posts.form.poll.expiresAt')}
96
96
  </ThemedText>
97
97
  </TouchableOpacity>
98
98
  </View>