@openpeepshq/rn-components 0.6.0 → 0.6.2

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 (40) hide show
  1. package/package.json +7 -6
  2. package/src/components/conversations/ConversationMessageBubble.tsx +11 -1
  3. package/src/components/conversations/ConversationParticipantsModal.tsx +6 -1
  4. package/src/components/conversations/ConversationPreviewCard.tsx +1 -1
  5. package/src/components/custom/navigation/side-menu.tsx +2 -1
  6. package/src/components/icons/index.ts +8 -0
  7. package/src/components/index.ts +1 -0
  8. package/src/components/navigation/helpers.ts +3 -0
  9. package/src/components/navigation/main-navigator.tsx +4 -0
  10. package/src/components/navigation/nativeRouter.tsx +11 -0
  11. package/src/components/navigation/tab-navigator.tsx +13 -3
  12. package/src/components/navigation/types/main.ts +6 -0
  13. package/src/components/navigation/types/tabs.ts +2 -0
  14. package/src/components/post/CompactReplyParent.tsx +22 -0
  15. package/src/components/post/FeedPostContent.tsx +4 -0
  16. package/src/components/post/NewResourceButton.tsx +57 -0
  17. package/src/components/post/PostDetail.tsx +3 -0
  18. package/src/components/post/index.ts +1 -0
  19. package/src/components/post/pieces/PostMenu.tsx +15 -9
  20. package/src/components/post/post-form/PostTypeSwitcher.tsx +19 -1
  21. package/src/components/post/post-form/ResourceForm.tsx +221 -0
  22. package/src/components/post/post-form/index.ts +1 -0
  23. package/src/components/post/types/Event.tsx +39 -20
  24. package/src/components/post/types/index.ts +1 -0
  25. package/src/components/post/types/resource/FullResource.tsx +177 -0
  26. package/src/components/resources/ResourceCard.tsx +289 -0
  27. package/src/components/resources/ResourceLibrary.tsx +369 -0
  28. package/src/components/resources/index.ts +4 -0
  29. package/src/components/ui/button.tsx +2 -2
  30. package/src/global.css +16 -14
  31. package/src/pages/conversations/Show.tsx +54 -12
  32. package/src/pages/groups/Show.tsx +19 -1
  33. package/src/pages/index.ts +3 -0
  34. package/src/pages/resources/Edit.tsx +72 -0
  35. package/src/pages/resources/Index.tsx +25 -0
  36. package/src/pages/resources/New.tsx +55 -0
  37. package/src/theme/OpenPeepsThemeProvider.tsx +1 -5
  38. package/src/theme/defaults.ts +22 -106
  39. package/src/theme/utils.ts +22 -0
  40. package/tailwind.config.js +78 -14
@@ -0,0 +1,289 @@
1
+ import React, { useMemo, useState } from 'react';
2
+ import type { ReactNode } from 'react';
3
+ import { Pressable, View } from 'react-native';
4
+ import { useTranslation } from 'react-i18next';
5
+ import type {
6
+ MediaAttachmentData,
7
+ PublicPost,
8
+ ResourceKind,
9
+ } from '@openpeepshq/common/types';
10
+ import {
11
+ attachmentMediaKind,
12
+ formatSize,
13
+ normalizeResourceTags,
14
+ truncateMarkdown,
15
+ } from '@openpeepshq/common/lib';
16
+ import { useOpenpeeps } from '@openpeepshq/react';
17
+ import { CachedImage } from '../custom/common';
18
+ import { ThemedText } from '../ui/themed-text';
19
+ import { VideoPlayOverlay } from '../post/VideoPlayOverlay';
20
+ import {
21
+ BookmarkPlusIcon,
22
+ BookmarkMinusIcon,
23
+ LinkIcon,
24
+ ImageOffIcon,
25
+ } from '../icons';
26
+
27
+ export interface ResourceCardProps {
28
+ post: PublicPost;
29
+ layout?: 'card' | 'list';
30
+ preview?: ReactNode;
31
+ }
32
+
33
+ const visualAttachments = (attachments: MediaAttachmentData[]) =>
34
+ attachments.filter((att) => attachmentMediaKind(att) !== 'audio');
35
+
36
+ const primaryActionLabel = (
37
+ kind: ResourceKind,
38
+ t: (key: string, opts?: { defaultValue?: string; count?: number }) => string
39
+ ) => {
40
+ switch (kind) {
41
+ case 'video':
42
+ return t('resources.actions.watch', { defaultValue: 'Watch' });
43
+ case 'file':
44
+ return t('resources.actions.download', { defaultValue: 'Download' });
45
+ case 'audio':
46
+ return t('resources.actions.listen', { defaultValue: 'Listen' });
47
+ case 'gallery':
48
+ return t('resources.actions.view', { defaultValue: 'View images' });
49
+ default:
50
+ return null;
51
+ }
52
+ };
53
+
54
+ export const ResourceCard = ({
55
+ post,
56
+ layout = 'card',
57
+ preview,
58
+ }: ResourceCardProps) => {
59
+ const { t } = useTranslation();
60
+ const { openpeepsApi } = useOpenpeeps();
61
+ const { data: currentProfile } = openpeepsApi.useCurrentProfile();
62
+ const bookmarkedIdsQuery = openpeepsApi.useCurrentProfileBookmarkedIds();
63
+ const isBookmarked = bookmarkedIdsQuery.data?.includes(post.id) ?? false;
64
+ const bookmarkPost = openpeepsApi.bookmarkPostAction({ id: post.id });
65
+ const unbookmarkPost = openpeepsApi.unbookmarkPostAction({ id: post.id });
66
+ const [erroredUrls, setErroredUrls] = useState<Set<string>>(new Set());
67
+
68
+ const resource = post.data?.type === 'resource' ? post.data : null;
69
+ const visuals = useMemo(
70
+ () => (resource ? visualAttachments(resource.attachments ?? []) : []),
71
+ [resource]
72
+ );
73
+ const isGallery =
74
+ !!resource && resource.resourceKind === 'gallery' && visuals.length > 1;
75
+ const tiles = isGallery ? visuals.slice(0, 4) : visuals.slice(0, 1);
76
+ const extra = isGallery ? Math.max(0, visuals.length - 4) : 0;
77
+ const excerpt = resource ? truncateMarkdown(resource.content, 2, 240) : null;
78
+ const tags = resource ? normalizeResourceTags(resource.tags) : [];
79
+ const actionLabel = resource
80
+ ? primaryActionLabel(resource.resourceKind, (key, opts) => t(key, opts))
81
+ : null;
82
+ const thumbnail = visuals[0];
83
+ const thumbSrc = thumbnail ? (thumbnail.previewUrl ?? thumbnail.url) : null;
84
+
85
+ const metaText = useMemo(() => {
86
+ if (!resource) return null;
87
+ if (resource.resourceKind === 'gallery' && visuals.length > 1) {
88
+ return t('resources.meta.imagesCount', {
89
+ count: visuals.length,
90
+ });
91
+ }
92
+ const fileAtt = (resource.attachments ?? []).find(
93
+ (att: MediaAttachmentData) =>
94
+ attachmentMediaKind(att) === 'file' ||
95
+ attachmentMediaKind(att) === 'video' ||
96
+ attachmentMediaKind(att) === 'audio'
97
+ );
98
+ const size = fileAtt?.meta?.size;
99
+ if (size) return formatSize(size);
100
+ return null;
101
+ }, [resource, visuals, t]);
102
+
103
+ if (!resource) return null;
104
+
105
+ const toggleBookmark = () => {
106
+ if (!currentProfile) return;
107
+ if (isBookmarked) {
108
+ unbookmarkPost(undefined);
109
+ } else {
110
+ bookmarkPost(undefined);
111
+ }
112
+ };
113
+
114
+ const renderBookmarkButton = () => (
115
+ <Pressable
116
+ onPress={toggleBookmark}
117
+ disabled={!currentProfile}
118
+ className="opacity-70"
119
+ >
120
+ {isBookmarked ? (
121
+ <BookmarkMinusIcon size={20} className="text-primary" />
122
+ ) : (
123
+ <BookmarkPlusIcon size={20} className="text-muted-foreground" />
124
+ )}
125
+ </Pressable>
126
+ );
127
+
128
+ const renderThumbnail = () => {
129
+ if (thumbSrc) {
130
+ return (
131
+ <CachedImage url={thumbSrc} className="h-12 w-12" resizeMode="cover" />
132
+ );
133
+ }
134
+ if (resource.resourceKind === 'link' && resource.url) {
135
+ return (
136
+ <View className="h-12 w-12 items-center justify-center rounded-md bg-muted">
137
+ <LinkIcon size={20} className="text-muted-foreground" />
138
+ </View>
139
+ );
140
+ }
141
+ return null;
142
+ };
143
+
144
+ if (layout === 'list') {
145
+ return (
146
+ <View className="w-full flex-row items-center justify-between px-4 py-3">
147
+ {renderThumbnail()}
148
+ <View className="min-w-0 flex-1">
149
+ <ThemedText className="text-lg font-semibold">
150
+ {resource.title}
151
+ </ThemedText>
152
+ {resource.categoryPath?.length ? (
153
+ <ThemedText className="text-xs text-muted-foreground">
154
+ {resource.categoryPath.join(' / ')}
155
+ </ThemedText>
156
+ ) : null}
157
+ {excerpt ? (
158
+ <ThemedText className="text-sm text-muted-foreground">
159
+ {excerpt}
160
+ </ThemedText>
161
+ ) : null}
162
+ {metaText ? (
163
+ <ThemedText className="text-xs text-muted-foreground">
164
+ {metaText}
165
+ </ThemedText>
166
+ ) : null}
167
+ </View>
168
+ <View className="flex-row items-center gap-2">
169
+ {resource.resourceKind !== 'link' && actionLabel ? (
170
+ actionLabel === 'Download' &&
171
+ resource.attachments?.find(
172
+ (att) => attachmentMediaKind(att) === 'file'
173
+ )?.url ? (
174
+ <ThemedText className="text-primary text-xs font-medium">
175
+ {actionLabel}
176
+ </ThemedText>
177
+ ) : (
178
+ <ThemedText className="text-muted-foreground text-xs">
179
+ {actionLabel}
180
+ </ThemedText>
181
+ )
182
+ ) : null}
183
+ {renderBookmarkButton()}
184
+ </View>
185
+ </View>
186
+ );
187
+ }
188
+
189
+ return (
190
+ <View className="w-full gap-y-2">
191
+ <View className="relative">
192
+ {preview ? (
193
+ preview
194
+ ) : tiles.length ? (
195
+ <View className={tiles.length > 1 ? 'h-48 flex-row flex-wrap' : ''}>
196
+ {tiles.map((att, index) => {
197
+ const src = att.previewUrl ?? att.url;
198
+ const last = index === tiles.length - 1 && extra > 0;
199
+ const hasErrored = erroredUrls.has(src ?? '');
200
+ return (
201
+ <View
202
+ key={`${att.url ?? index}-${index}`}
203
+ className={
204
+ tiles.length > 1 ? 'h-1/2 w-1/2 overflow-hidden p-px' : ''
205
+ }
206
+ >
207
+ {src && !hasErrored ? (
208
+ <View className="relative">
209
+ <CachedImage
210
+ url={src}
211
+ className={
212
+ tiles.length > 1 ? 'h-full w-full' : 'h-48 w-full'
213
+ }
214
+ resizeMode="cover"
215
+ onError={() =>
216
+ setErroredUrls((prev) => {
217
+ const n = new Set(prev);
218
+ n.add(src ?? '');
219
+ return n;
220
+ })
221
+ }
222
+ />
223
+ {attachmentMediaKind(att) === 'video' ? (
224
+ <VideoPlayOverlay video />
225
+ ) : null}
226
+ {last ? (
227
+ <View className="absolute inset-0 items-center justify-center bg-black/60">
228
+ <ThemedText className="text-lg font-semibold text-white">
229
+ +{extra}
230
+ </ThemedText>
231
+ </View>
232
+ ) : null}
233
+ </View>
234
+ ) : (
235
+ <View className="bg-muted flex h-full w-full items-center justify-center">
236
+ <ImageOffIcon
237
+ size={24}
238
+ className="text-muted-foreground/50"
239
+ />
240
+ </View>
241
+ )}
242
+ </View>
243
+ );
244
+ })}
245
+ </View>
246
+ ) : resource.resourceKind === 'link' && resource.url ? (
247
+ <View className="h-48 w-full items-center justify-center rounded-md bg-muted">
248
+ <LinkIcon size={32} className="text-muted-foreground/50" />
249
+ </View>
250
+ ) : null}
251
+ <View className="absolute top-2 right-2">{renderBookmarkButton()}</View>
252
+ </View>
253
+
254
+ <ThemedText className="text-lg font-semibold">
255
+ {resource.title}
256
+ </ThemedText>
257
+ {resource.categoryPath?.length ? (
258
+ <ThemedText className="text-xs text-muted-foreground">
259
+ {resource.categoryPath.join(' / ')}
260
+ </ThemedText>
261
+ ) : null}
262
+ {excerpt ? (
263
+ <ThemedText className="text-sm text-muted-foreground">
264
+ {excerpt}
265
+ </ThemedText>
266
+ ) : null}
267
+ {metaText ? (
268
+ <ThemedText className="text-xs text-muted-foreground">
269
+ {metaText}
270
+ </ThemedText>
271
+ ) : null}
272
+ {tags.length ? (
273
+ <View className="flex-row flex-wrap gap-1">
274
+ {tags.map((value) => (
275
+ <ThemedText
276
+ key={value}
277
+ className="rounded-full bg-muted px-2 py-0.5 text-xs text-muted-foreground"
278
+ >
279
+ #{value}
280
+ </ThemedText>
281
+ ))}
282
+ </View>
283
+ ) : null}
284
+ <ThemedText className="text-xs uppercase text-muted-foreground">
285
+ {t(`resources.kinds.${resource.resourceKind}`)}
286
+ </ThemedText>
287
+ </View>
288
+ );
289
+ };
@@ -0,0 +1,369 @@
1
+ import React, { useMemo, useState } from 'react';
2
+ import { Pressable, View, ScrollView } from 'react-native';
3
+ import { useTranslation } from 'react-i18next';
4
+ import type { ResourceKind } from '@openpeepshq/common/types';
5
+ import { RESOURCE_KINDS } from '@openpeepshq/common/lib';
6
+ import type { CategoryNode } from '@openpeepshq/common/lib';
7
+ import { useResourceLibrary } from '@openpeepshq/react';
8
+ import { Input } from '../ui/input';
9
+ import { LoadingSpinner } from '../ui/loading-spinner';
10
+ import { ThemedText } from '../ui/themed-text';
11
+ import {
12
+ LayoutGridIcon,
13
+ LayoutListIcon,
14
+ BookmarkIcon,
15
+ ChevronDownIcon,
16
+ ChevronRightIcon,
17
+ } from '../icons';
18
+ import { ResourceCard } from './ResourceCard';
19
+
20
+ export interface ResourceLibraryProps {
21
+ groupId?: string;
22
+ }
23
+
24
+ const COLLECTION_LIMIT = 5;
25
+
26
+ const Tree = ({
27
+ nodes,
28
+ selected,
29
+ onSelect,
30
+ counts,
31
+ expanded,
32
+ onToggle,
33
+ }: {
34
+ nodes: CategoryNode[];
35
+ selected: string[];
36
+ onSelect: (path: string[]) => void;
37
+ counts: Map<string, number>;
38
+ expanded: Set<string>;
39
+ onToggle: (nodeKey: string) => void;
40
+ }) => (
41
+ <View className="gap-y-1">
42
+ {nodes.map((node) => {
43
+ const nodeKey = node.path.join('/');
44
+ const nodeCount = counts.get(nodeKey) ?? 0;
45
+ const isExpanded = expanded.has(nodeKey);
46
+ const isSelected = selected.join('/') === nodeKey;
47
+ const hasChildren = node.children.length > 0;
48
+ return (
49
+ <View key={nodeKey}>
50
+ <View className="flex-row items-center gap-1">
51
+ <Pressable
52
+ onPress={hasChildren ? () => onToggle(nodeKey) : undefined}
53
+ className={hasChildren ? '' : 'invisible'}
54
+ >
55
+ <ChevronRightIcon
56
+ size={16}
57
+ className={`text-muted-foreground transition-transform ${
58
+ isExpanded ? 'rotate-90' : ''
59
+ }`}
60
+ />
61
+ </Pressable>
62
+ <Pressable onPress={() => onSelect(node.path)}>
63
+ <ThemedText
64
+ className={`text-sm ${
65
+ isSelected
66
+ ? 'font-semibold text-foreground'
67
+ : 'text-muted-foreground'
68
+ }`}
69
+ >
70
+ {node.name}{' '}
71
+ <ThemedText className="text-xs opacity-60">
72
+ ({nodeCount})
73
+ </ThemedText>
74
+ </ThemedText>
75
+ </Pressable>
76
+ </View>
77
+ {hasChildren && isExpanded ? (
78
+ <View className="ml-4">
79
+ <Tree
80
+ nodes={node.children}
81
+ selected={selected}
82
+ onSelect={onSelect}
83
+ counts={counts}
84
+ expanded={expanded}
85
+ onToggle={onToggle}
86
+ />
87
+ </View>
88
+ ) : null}
89
+ </View>
90
+ );
91
+ })}
92
+ </View>
93
+ );
94
+
95
+ export const ResourceLibrary = ({ groupId }: ResourceLibraryProps) => {
96
+ const { t } = useTranslation();
97
+ const library = useResourceLibrary(groupId);
98
+ const [expanded, setExpanded] = useState<Set<string>>(new Set());
99
+
100
+ const toggleNode = (nodeKey: string) => {
101
+ setExpanded((prev) => {
102
+ const next = new Set(prev);
103
+ if (next.has(nodeKey)) next.delete(nodeKey);
104
+ else next.add(nodeKey);
105
+ return next;
106
+ });
107
+ };
108
+
109
+ const collectionCounts = useMemo(() => {
110
+ const counts = new Map<string, number>();
111
+ let rootCount = 0;
112
+ for (const post of library.posts) {
113
+ if (post.data?.type !== 'resource') continue;
114
+ const path = post.data.categoryPath;
115
+ if (!path?.length) continue;
116
+ rootCount++;
117
+ for (let i = 1; i <= path.length; i++) {
118
+ const key = path.slice(0, i).join('/');
119
+ counts.set(key, (counts.get(key) ?? 0) + 1);
120
+ }
121
+ }
122
+ counts.set('', rootCount);
123
+ return counts;
124
+ }, [library.posts]);
125
+
126
+ const treeNodes = useMemo(() => {
127
+ if (library.tree.length === 0) return [];
128
+ return [
129
+ {
130
+ name: t('resources.library.allFolders', {
131
+ defaultValue: 'All folders',
132
+ }),
133
+ path: [] as string[],
134
+ children: library.tree,
135
+ },
136
+ ];
137
+ }, [library.tree, t]);
138
+
139
+ const sortedTags = useMemo(
140
+ () =>
141
+ library.tags
142
+ .filter((entry) => library.selectedTags.includes(entry.name))
143
+ .concat(
144
+ library.tags.filter(
145
+ (entry) => !library.selectedTags.includes(entry.name)
146
+ )
147
+ ),
148
+ [library.tags, library.selectedTags]
149
+ );
150
+
151
+ const visibleTags = library.tagsOpen
152
+ ? sortedTags
153
+ : sortedTags.slice(0, COLLECTION_LIMIT);
154
+ const hasMoreTags = sortedTags.length > COLLECTION_LIMIT;
155
+
156
+ return (
157
+ <View>
158
+ <View className="gap-y-3 p-4">
159
+ <Input
160
+ value={library.search}
161
+ onChangeText={library.setSearch}
162
+ placeholder={t('resources.library.search')}
163
+ />
164
+ <View className="flex-row flex-wrap items-center justify-between gap-2">
165
+ <View className="flex-row flex-wrap gap-2">
166
+ {(['all', ...RESOURCE_KINDS] as const).map((kind) => (
167
+ <Pressable
168
+ key={kind}
169
+ onPress={() =>
170
+ library.setKind(
171
+ kind === 'all' ? 'all' : (kind as ResourceKind)
172
+ )
173
+ }
174
+ className={`rounded-full px-3 py-1 ${
175
+ library.kind === kind ? 'bg-primary' : 'bg-muted'
176
+ }`}
177
+ >
178
+ <ThemedText
179
+ className={
180
+ library.kind === kind
181
+ ? 'text-primary-foreground text-xs'
182
+ : 'text-muted-foreground text-xs'
183
+ }
184
+ >
185
+ {kind === 'all'
186
+ ? t('resources.library.allKinds')
187
+ : t(`resources.kinds.${kind}`)}
188
+ </ThemedText>
189
+ </Pressable>
190
+ ))}
191
+ </View>
192
+ <View className="flex-row gap-1">
193
+ <Pressable
194
+ onPress={() => library.setView('list')}
195
+ className={`rounded-full p-2 ${
196
+ library.view === 'list' ? 'bg-primary' : 'bg-muted'
197
+ }`}
198
+ >
199
+ <LayoutListIcon
200
+ size={20}
201
+ className={
202
+ library.view === 'list'
203
+ ? 'text-primary-foreground'
204
+ : 'text-muted-foreground'
205
+ }
206
+ />
207
+ </Pressable>
208
+ <Pressable
209
+ onPress={() => library.setView('cards')}
210
+ className={`rounded-full p-2 ${
211
+ library.view === 'cards' ? 'bg-primary' : 'bg-muted'
212
+ }`}
213
+ >
214
+ <LayoutGridIcon
215
+ size={20}
216
+ className={
217
+ library.view === 'cards'
218
+ ? 'text-primary-foreground'
219
+ : 'text-muted-foreground'
220
+ }
221
+ />
222
+ </Pressable>
223
+ <Pressable
224
+ onPress={() => library.setSaved(!library.saved)}
225
+ className={`rounded-full p-2 ${
226
+ library.saved ? 'bg-primary' : 'bg-muted'
227
+ }`}
228
+ >
229
+ <BookmarkIcon
230
+ size={20}
231
+ className={
232
+ library.saved
233
+ ? 'text-primary-foreground'
234
+ : 'text-muted-foreground'
235
+ }
236
+ />
237
+ </Pressable>
238
+ </View>
239
+ </View>
240
+
241
+ {/* Breadcrumb + tree */}
242
+ <View>
243
+ <View className="flex-row items-center gap-2">
244
+ <Pressable onPress={() => library.setPathPrefix([])}>
245
+ <ThemedText className="text-sm text-muted-foreground">
246
+ All
247
+ </ThemedText>
248
+ </Pressable>
249
+ {library.pathPrefix.length > 0 ? (
250
+ <>
251
+ <ThemedText className="text-sm text-muted-foreground">
252
+ /
253
+ </ThemedText>
254
+ <ThemedText className="text-sm text-muted-foreground">
255
+ {library.pathPrefix.join(' / ')}
256
+ </ThemedText>
257
+ </>
258
+ ) : null}
259
+ <Pressable
260
+ onPress={() => library.setHierarchy(!library.hierarchy)}
261
+ className="ml-auto"
262
+ >
263
+ {library.hierarchy ? (
264
+ <ChevronDownIcon size={20} className="text-muted-foreground" />
265
+ ) : (
266
+ <ChevronRightIcon size={20} className="text-muted-foreground" />
267
+ )}
268
+ </Pressable>
269
+ </View>
270
+ {library.hierarchy && treeNodes.length ? (
271
+ <View className="ml-3 gap-y-1">
272
+ <Tree
273
+ nodes={treeNodes}
274
+ selected={library.pathPrefix}
275
+ onSelect={library.setPathPrefix}
276
+ counts={collectionCounts}
277
+ expanded={expanded}
278
+ onToggle={toggleNode}
279
+ />
280
+ </View>
281
+ ) : null}
282
+ </View>
283
+
284
+ {/* Tags (collapsible secondary discovery) */}
285
+ {library.tags.length ? (
286
+ <View className="gap-y-1">
287
+ <View className="flex-row flex-wrap gap-1">
288
+ {visibleTags.map((entry) => {
289
+ const isSelected = library.selectedTags.includes(entry.name);
290
+ return (
291
+ <Pressable
292
+ key={entry.name}
293
+ onPress={() => library.toggleTag(entry.name)}
294
+ className={`rounded-full px-2 py-0.5 ${
295
+ isSelected ? 'bg-primary' : 'bg-muted'
296
+ }`}
297
+ >
298
+ <ThemedText className="text-xs">
299
+ #{entry.name} {entry.count}
300
+ </ThemedText>
301
+ </Pressable>
302
+ );
303
+ })}
304
+ </View>
305
+ {hasMoreTags ? (
306
+ <Pressable
307
+ onPress={() => library.setTagsOpen(!library.tagsOpen)}
308
+ className="rounded-full bg-muted px-2 py-0.5"
309
+ >
310
+ <ThemedText className="text-xs text-muted-foreground">
311
+ {library.tagsOpen
312
+ ? t('resources.library.hideTags', {
313
+ defaultValue: 'Hide',
314
+ })
315
+ : t('resources.library.showHiddenTags', {
316
+ defaultValue: '+ {{count}}',
317
+ count: sortedTags.length - COLLECTION_LIMIT,
318
+ })}
319
+ </ThemedText>
320
+ </Pressable>
321
+ ) : null}
322
+ </View>
323
+ ) : null}
324
+
325
+ {/* Resource count */}
326
+ {library.posts.length > 0 ? (
327
+ <ThemedText className="text-xs text-muted-foreground">
328
+ {t('resources.library.resourceCount', {
329
+ defaultValue: 'Showing {{count}} resources',
330
+ count: library.posts.length,
331
+ })}
332
+ </ThemedText>
333
+ ) : null}
334
+ </View>
335
+
336
+ {library.query.isLoading ? (
337
+ <View className="h-32 items-center justify-center">
338
+ <LoadingSpinner size="large" />
339
+ </View>
340
+ ) : library.posts.length === 0 ? (
341
+ <ThemedText className="p-8 text-center text-muted-foreground">
342
+ {library.activeFilterCount > 0
343
+ ? t('resources.library.noResults', {
344
+ defaultValue: 'No resources match your filters.',
345
+ })
346
+ : library.pathPrefix.length
347
+ ? t('resources.library.emptyCollection', {
348
+ defaultValue: 'This collection has no resources yet.',
349
+ })
350
+ : t('resources.library.empty', {
351
+ defaultValue: 'No resources yet.',
352
+ })}
353
+ </ThemedText>
354
+ ) : library.view === 'list' ? (
355
+ <View className="divide-border">
356
+ {library.posts.map((post) => (
357
+ <ResourceCard key={post.id} post={post} layout="list" />
358
+ ))}
359
+ </View>
360
+ ) : (
361
+ <ScrollView horizontal={false} contentContainerClassName="gap-4 p-4">
362
+ {library.posts.map((post) => (
363
+ <ResourceCard key={post.id} post={post} layout="card" />
364
+ ))}
365
+ </ScrollView>
366
+ )}
367
+ </View>
368
+ );
369
+ };
@@ -0,0 +1,4 @@
1
+ export { ResourceLibrary } from './ResourceLibrary';
2
+ export type { ResourceLibraryProps } from './ResourceLibrary';
3
+ export { ResourceCard } from './ResourceCard';
4
+ export type { ResourceCardProps } from './ResourceCard';
@@ -20,8 +20,8 @@ const buttonVariants = cva(
20
20
  },
21
21
  size: {
22
22
  default: 'h-10 px-4 py-2 native:h-12 native:px-5 native:py-3',
23
- sm: 'h-9 rounded-md px-3',
24
- lg: 'h-11 rounded-md px-8 native:h-14',
23
+ sm: 'h-9 px-3',
24
+ lg: 'h-11 px-8 native:h-14',
25
25
  icon: 'h-10 w-10',
26
26
  },
27
27
  },