@openpeepshq/rn-components 0.12.3 → 0.12.5

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 +3 -3
  2. package/src/components/CapabilityMatrix.tsx +44 -6
  3. package/src/components/conversations/ConversationMessageBubble.tsx +3 -6
  4. package/src/components/custom/common/popover.tsx +4 -1
  5. package/src/components/custom/modals/media/document-picker-sheet.tsx +10 -3
  6. package/src/components/custom/modals/media/image-picker-sheet.test.tsx +201 -0
  7. package/src/components/custom/modals/media/image-picker-sheet.tsx +27 -17
  8. package/src/components/custom/modals/media/send-media-sheet.tsx +4 -1
  9. package/src/components/groups/GroupMembersList.test.tsx +156 -0
  10. package/src/components/groups/GroupMembersList.tsx +4 -1
  11. package/src/components/jams/JamCallParticipant.tsx +6 -1
  12. package/src/components/jams/JamDesktopFooter.tsx +6 -1
  13. package/src/components/jams/JamFooter.tsx +6 -1
  14. package/src/components/jams/JamGuestForm.tsx +6 -1
  15. package/src/components/jams/JamObserverShell.tsx +4 -1
  16. package/src/components/jams/JamRoomIndicators.test.tsx +143 -0
  17. package/src/components/jams/JamRoomIndicators.tsx +15 -8
  18. package/src/components/jams/JamToolbarButton.tsx +7 -1
  19. package/src/components/post/feed/events/EventsCalendar.tsx +6 -2
  20. package/src/components/post/pieces/EventOccurrenceList.tsx +7 -2
  21. package/src/components/post/pieces/UnreadPostIndicator.tsx +4 -4
  22. package/src/components/post/post-form/ComposeAttachments.tsx +6 -2
  23. package/src/components/post/post-form/ResourceForm.tsx +16 -16
  24. package/src/components/post/post-form/VisibilitySheet.tsx +3 -1
  25. package/src/components/post/types/event/FullEvent.test.tsx +136 -15
  26. package/src/components/post/types/event/FullEvent.tsx +21 -5
  27. package/src/components/profile/ProfileSelector.test.tsx +115 -0
  28. package/src/components/profile/ProfileSelector.tsx +2 -2
  29. package/src/components/profile/ReportProfileOrPostModal.tsx +4 -1
  30. package/src/components/resources/CategoryPathPicker.tsx +117 -0
  31. package/src/components/resources/ResourceCard.test.tsx +12 -0
  32. package/src/components/resources/ResourceCard.tsx +8 -3
  33. package/src/components/resources/ResourceLibrary.test.tsx +334 -0
  34. package/src/components/resources/ResourceLibrary.tsx +5 -5
  35. package/src/components/resources/index.ts +2 -0
  36. package/src/pages/Welcome.tsx +4 -1
  37. package/src/theme/OpenPeepsThemeProvider.tsx +6 -5
  38. package/src/theme/color.ts +29 -0
  39. package/src/theme/useThemeOpacity.ts +30 -0
  40. package/src/theme/utils.ts +11 -22
@@ -52,20 +52,56 @@ jest.mock('react-i18next', () => ({
52
52
  }));
53
53
 
54
54
  // --- openpeeps context + server info --------------------------------------
55
- jest.mock('@openpeepshq/react', () => ({
56
- useOpenpeeps: () => ({
57
- currentProfile: mockProfile,
58
- openpeepsApi: {
59
- rsvpManageAction: () => ({}),
60
- useJamAttendance: () => ({ isSuccess: false, data: [] }),
61
- useJamState: () => ({ data: mockJamState }),
62
- usePostRecordings: () => ({ data: [] }),
63
- usePostContext: () => ({ data: undefined }),
55
+ // `useEventDisplayTimeZone` is stubbed as a thin pass-through over these two
56
+ // mocked values, so the RN suite exercises the same contract as the real hook:
57
+ // profile settings -> community default -> event zone; no device-zone tier.
58
+ let mockProfileSettingsTimeZone: string | undefined = undefined;
59
+ const setProfileSettingsTimeZone = (timeZone?: string) => {
60
+ mockProfileSettingsTimeZone = timeZone;
61
+ };
62
+ let mockCommunityDefaultTimeZone: string | undefined = undefined;
63
+ const setCommunityDefaultTimeZone = (timeZone?: string) => {
64
+ mockCommunityDefaultTimeZone = timeZone;
65
+ };
66
+ jest.mock('@openpeepshq/react', () => {
67
+ return {
68
+ useOpenpeeps: () => ({
69
+ currentProfile: mockProfile,
70
+ openpeepsApi: {
71
+ rsvpManageAction: () => ({}),
72
+ useJamAttendance: () => ({ isSuccess: false, data: [] }),
73
+ useJamState: () => ({ data: mockJamState }),
74
+ usePostRecordings: () => ({ data: [] }),
75
+ usePostContext: () => ({ data: undefined }),
76
+ },
77
+ client: mockClient,
78
+ }),
79
+ useServerInfo: mockUseServerInfo,
80
+ // Pass-through over the mocked tiers, gated by Intl's own IANA check —
81
+ // the ESM @openpeepshq/common dist cannot be required under the jest node
82
+ // env, so this mirrors eventDisplayTimeZone's isIanaTimeZone gate only.
83
+ useEventDisplayTimeZone: (eventTimeZone?: string | null) => {
84
+ const isIana = (tz?: string | null): tz is string => {
85
+ if (!tz) return false;
86
+ try {
87
+ new Intl.DateTimeFormat('en-US', { timeZone: tz });
88
+ return true;
89
+ } catch {
90
+ return false;
91
+ }
92
+ };
93
+ return (
94
+ (isIana(mockProfileSettingsTimeZone)
95
+ ? mockProfileSettingsTimeZone
96
+ : undefined) ??
97
+ (isIana(mockCommunityDefaultTimeZone)
98
+ ? mockCommunityDefaultTimeZone
99
+ : undefined) ??
100
+ (isIana(eventTimeZone) ? eventTimeZone : undefined)
101
+ );
64
102
  },
65
- client: mockClient,
66
- }),
67
- useServerInfo: mockUseServerInfo,
68
- }));
103
+ };
104
+ });
69
105
 
70
106
  // --- shared (pure) helpers -------------------------------------------------
71
107
  jest.mock('@openpeepshq/common', () => ({
@@ -76,8 +112,17 @@ jest.mock('@openpeepshq/common/lib', () => ({
76
112
  canAccessJamRecordings: () => false,
77
113
  canModerateJam: () => false,
78
114
  canViewJamAttendees: () => false,
79
- effectiveEventTimes: () => ({}),
80
- eventTimeZoneOptions: () => ({ label: 'UTC' }),
115
+ effectiveEventTimes: (event?: { start?: string }) =>
116
+ event?.start ? { start: event.start } : {},
117
+ eventTimeZoneOptions: (timeZone?: string | null) => {
118
+ if (typeof timeZone !== 'string') return {};
119
+ try {
120
+ new Intl.DateTimeFormat('en-US', { timeZone });
121
+ return { timeZone };
122
+ } catch {
123
+ return {};
124
+ }
125
+ },
81
126
  formatEventClockTime: () => '',
82
127
  formatEventRecurrence: () => '',
83
128
  listRsvpOccurrences: () => [],
@@ -224,6 +269,7 @@ jest.mock('../../../icons/index', () => ({
224
269
  PencilIcon: () => null,
225
270
  FlagIcon: () => null,
226
271
  }));
272
+
227
273
  // The components barrel (EventRsvpButton, ReplyBox, ShareMenu, useNewPostModal, ...)
228
274
  jest.mock('../../index', () => ({
229
275
  EventMenu: () => null,
@@ -307,6 +353,8 @@ function render(
307
353
  beforeEach(() => {
308
354
  mockJamState = undefined;
309
355
  mockProfile = { id: 'u-1', displayName: 'Att', handle: 'att' };
356
+ mockProfileSettingsTimeZone = undefined;
357
+ mockCommunityDefaultTimeZone = undefined;
310
358
  mockUseServerInfo.mockReset();
311
359
  mockUseServerInfo.mockReturnValue({ jams: { livekit: { enabled: true } } });
312
360
  });
@@ -465,3 +513,76 @@ describe('tappable Jam URL', () => {
465
513
  tree.unmount();
466
514
  });
467
515
  });
516
+
517
+ // Display time zone (issue #2129): FullEvent resolves the viewer's zone via
518
+ // useEventDisplayTimeZone (profile settings -> community default -> event
519
+ // zone) and appends the "in your time zone" suffix whenever the resolved zone
520
+ // is a resolvable zone that differs from the event's own zone.
521
+ describe('event display time zone', () => {
522
+ const timedPost = {
523
+ ...BASE_POST,
524
+ data: {
525
+ ...BASE_POST.data,
526
+ timeZone: 'America/New_York',
527
+ start: '2026-06-15T14:30:00Z',
528
+ },
529
+ };
530
+
531
+ test('12. profile settings time zone differing from the event zone -> suffix renders', () => {
532
+ setProfileSettingsTimeZone('Europe/Berlin');
533
+ const tree = render(timedPost);
534
+ const json = JSON.stringify(tree.toJSON());
535
+ expect(json).toContain('in your time zone');
536
+ expect(json).toContain('(Europe/Berlin)');
537
+ tree.unmount();
538
+ });
539
+
540
+ test('13. display zone matching the event zone -> no suffix', () => {
541
+ setProfileSettingsTimeZone('America/New_York');
542
+ const tree = render(timedPost);
543
+ const json = JSON.stringify(tree.toJSON());
544
+ expect(json).not.toContain('in your time zone');
545
+ tree.unmount();
546
+ });
547
+
548
+ test('14. no profile settings time zone -> falls back to event zone, no suffix', () => {
549
+ setProfileSettingsTimeZone(undefined);
550
+ const tree = render(timedPost);
551
+ const json = JSON.stringify(tree.toJSON());
552
+ expect(json).not.toContain('in your time zone');
553
+ tree.unmount();
554
+ });
555
+
556
+ test('15. community default time zone used when the profile has none -> suffix renders', () => {
557
+ setProfileSettingsTimeZone(undefined);
558
+ setCommunityDefaultTimeZone('Europe/Berlin');
559
+ const tree = render(timedPost);
560
+ const json = JSON.stringify(tree.toJSON());
561
+ expect(json).toContain('in your time zone');
562
+ expect(json).toContain('(Europe/Berlin)');
563
+ tree.unmount();
564
+ });
565
+
566
+ test('16. unresolvable zones -> no suffix and no zone label', () => {
567
+ setProfileSettingsTimeZone('Not/AZone');
568
+ const tree = render({
569
+ ...timedPost,
570
+ data: { ...timedPost.data, timeZone: undefined },
571
+ });
572
+ const json = JSON.stringify(tree.toJSON());
573
+ expect(json).not.toContain('in your time zone');
574
+ expect(json).not.toContain('Not/AZone');
575
+ tree.unmount();
576
+ });
577
+
578
+ test('17. invalid profile zone ignored, community default wins -> suffix renders', () => {
579
+ setProfileSettingsTimeZone('Not/AZone');
580
+ setCommunityDefaultTimeZone('Europe/Berlin');
581
+ const tree = render(timedPost);
582
+ const json = JSON.stringify(tree.toJSON());
583
+ expect(json).toContain('in your time zone');
584
+ expect(json).toContain('(Europe/Berlin)');
585
+ expect(json).not.toContain('Not/AZone');
586
+ tree.unmount();
587
+ });
588
+ });
@@ -38,6 +38,7 @@ import { Button } from '../../../ui/button';
38
38
  import { UpdatingDate } from '../../../custom/date/updating-date';
39
39
  import { VideoPlayer } from '../../pieces/VideoPlayer';
40
40
  import { profileName, truncateText } from '../../../../lib/utils';
41
+ import { useThemeOpacity } from '../../../../theme/useThemeOpacity';
41
42
  import { useNavigation } from '@react-navigation/native';
42
43
  import { NativeStackNavigationProp } from '@react-navigation/native-stack';
43
44
  import { MainStackParamList } from '../../../navigation/types/index';
@@ -67,6 +68,7 @@ import {
67
68
  import { ThemedView } from '../../../ui/themed-view';
68
69
  import { EventOccurrenceList } from '../../pieces/EventOccurrenceList';
69
70
  import { EventRsvpList } from '../../pieces/EventRsvpList';
71
+ import { useEventDisplayTimeZone } from '@openpeepshq/react';
70
72
 
71
73
  import {
72
74
  EventMenu,
@@ -88,6 +90,7 @@ export interface FullEventProps {
88
90
 
89
91
  export const FullEvent: React.FC<FullEventProps> = ({ post, occurrence }) => {
90
92
  const { t } = useTranslation();
93
+ const { border } = useThemeOpacity();
91
94
  const { currentProfile, openpeepsApi, client } = useOpenpeeps();
92
95
  const navigation =
93
96
  useNavigation<NativeStackNavigationProp<MainStackParamList>>();
@@ -126,7 +129,8 @@ export const FullEvent: React.FC<FullEventProps> = ({ post, occurrence }) => {
126
129
  }
127
130
  };
128
131
  const times = effectiveEventTimes(event, occurrence);
129
- const tz = eventTimeZoneOptions(event?.timeZone);
132
+ const displayTz = useEventDisplayTimeZone(event?.timeZone);
133
+ const tz = eventTimeZoneOptions(displayTz);
130
134
  const recurrenceLabel = event?.recurrence
131
135
  ? formatEventRecurrence(event.recurrence, t, event.start)
132
136
  : '';
@@ -280,7 +284,10 @@ export const FullEvent: React.FC<FullEventProps> = ({ post, occurrence }) => {
280
284
  </View>
281
285
  {times.start && (
282
286
  <View className="mt-8 flex-row gap-x-4">
283
- <View className="border-foreground/20 border-[0.5px] rounded-md px-3 py-1">
287
+ <View
288
+ style={border('foreground', 0.2)}
289
+ className="border-[0.5px] rounded-md px-3 py-1"
290
+ >
284
291
  <ThemedText className="text-center">
285
292
  {new Date(times.start).toLocaleString('en-US', {
286
293
  month: 'short',
@@ -305,22 +312,30 @@ export const FullEvent: React.FC<FullEventProps> = ({ post, occurrence }) => {
305
312
  </ThemedText>
306
313
  <ThemedText className="text-muted-foreground mt-2">
307
314
  {formatEventClockTime(times.start, {
308
- timeZone: event?.timeZone,
315
+ timeZone: displayTz,
309
316
  locale: 'en-US',
310
317
  })}
311
318
  {times.end
312
319
  ? ` - ${formatEventClockTime(times.end, {
313
- timeZone: event?.timeZone,
320
+ timeZone: displayTz,
314
321
  locale: 'en-US',
315
322
  })}`
316
323
  : ''}
317
324
  {tz.timeZone ? ` (${tz.timeZone})` : ''}
325
+ {displayTz && displayTz !== event?.timeZone
326
+ ? ` — ${t('events.inYourTimeZone', {
327
+ defaultValue: 'in your time zone',
328
+ })}`
329
+ : ''}
318
330
  </ThemedText>
319
331
  </View>
320
332
  </View>
321
333
  )}
322
334
  <View className="mt-8 flex-row gap-x-4">
323
- <View className="border-foreground/20 border-[0.5px] flex items-center justify-center rounded-md px-4 py-1">
335
+ <View
336
+ style={border('foreground', 0.2)}
337
+ className="border-[0.5px] flex items-center justify-center rounded-md px-4 py-1"
338
+ >
324
339
  {event?.physicalLocation ? (
325
340
  <MapPinIcon className="text-muted-foreground my-3" size={18} />
326
341
  ) : event?.jam ? (
@@ -385,6 +400,7 @@ export const FullEvent: React.FC<FullEventProps> = ({ post, occurrence }) => {
385
400
  occurrences={upcomingOccurrences}
386
401
  currentOccurrenceId={occurrence}
387
402
  recurrenceLabel={recurrenceLabel}
403
+ timeZone={displayTz}
388
404
  />
389
405
  ) : null}
390
406
  <EventRsvpButton post={post as PublicPost} recurrenceId={occurrence} />
@@ -0,0 +1,115 @@
1
+ /**
2
+ * Regression tests for the ProfileSelector sheet title (issue #1666).
3
+ *
4
+ * The sheet used to hard-code the English string "Add members", so every
5
+ * caller that omitted `title` (jam moderators, group members, event
6
+ * moderators) rendered untranslated copy, and the audience picker could be
7
+ * re-titled to a non-matching string. Web defaults to
8
+ * `profile.selector.title` ("Select profiles"); RN must match.
9
+ */
10
+
11
+ const React = require('react');
12
+ const ReactTestRenderer = require('react-test-renderer');
13
+
14
+ const mockT = (key: string) => MESSAGES[key] ?? key;
15
+
16
+ const MESSAGES: Record<string, string> = {
17
+ 'profile.selector.title': 'Select profiles',
18
+ 'profile.search.placeholder': 'Search profiles',
19
+ 'profile.search.noResults': 'No results found',
20
+ 'common.members.addSuccess': 'Added',
21
+ 'common.members.addError': 'Failed',
22
+ 'common.members.adding': 'Adding',
23
+ 'common.actions.add': 'Add',
24
+ };
25
+
26
+ jest.mock('react-native', () => ({
27
+ View: (props: { children?: unknown }) =>
28
+ React.createElement('View', null, props.children),
29
+ ScrollView: (props: { children?: unknown }) =>
30
+ React.createElement('ScrollView', null, props.children),
31
+ ActivityIndicator: () => null,
32
+ }));
33
+
34
+ jest.mock('react-i18next', () => ({
35
+ useTranslation: () => ({ t: mockT }),
36
+ }));
37
+
38
+ jest.mock('@openpeepshq/react', () => ({
39
+ useOpenpeeps: () => ({
40
+ openpeepsApi: {
41
+ // Stable array identity: the component's effect depends on `profiles`
42
+ // and a fresh literal each render would loop forever.
43
+ useProfiles: () => ({ data: PROFILES, isLoading: false }),
44
+ },
45
+ currentProfile: null,
46
+ }),
47
+ }));
48
+
49
+ const PROFILES: unknown[] = [];
50
+
51
+ jest.mock('../../lib/utils', () => ({
52
+ profileMatchesQuery: () => true,
53
+ }));
54
+
55
+ jest.mock('../icons/index', () => ({
56
+ CheckIcon: () => React.createElement('CheckIcon'),
57
+ SearchIcon: () => React.createElement('SearchIcon'),
58
+ }));
59
+
60
+ jest.mock('../ui/input', () => ({
61
+ Input: () => null,
62
+ }));
63
+
64
+ jest.mock('../ui/themed-text', () => ({
65
+ ThemedText: (props: Record<string, unknown>) =>
66
+ React.createElement('ThemedText', props, props.children),
67
+ }));
68
+
69
+ jest.mock('../custom/modals/common', () => ({
70
+ BaseSheet: (props: { children?: unknown }) =>
71
+ React.createElement('BaseSheet', null, props.children),
72
+ SheetFooter: () => null,
73
+ }));
74
+
75
+ jest.mock('react-native-toast-message', () => ({ show: jest.fn() }));
76
+
77
+ jest.mock('../../lib/bottom-sheet-ref', () => ({
78
+ bottomSheetClose: jest.fn(),
79
+ }));
80
+
81
+ jest.mock('./ProfileCard', () => ({
82
+ MiniProfileCard: () => null,
83
+ ProfileCard: () => null,
84
+ }));
85
+
86
+ import type { ProfilePickerSheetProps } from './ProfileSelector';
87
+ import { ProfileSelector } from './ProfileSelector';
88
+
89
+ const renderSelector = (props: Partial<ProfilePickerSheetProps> = {}) => {
90
+ let tree: ReturnType<typeof ReactTestRenderer.create>;
91
+ ReactTestRenderer.act(() => {
92
+ tree = ReactTestRenderer.create(
93
+ React.createElement(ProfileSelector, props as ProfilePickerSheetProps)
94
+ );
95
+ });
96
+ return tree;
97
+ };
98
+
99
+ const titleText = (tree: ReturnType<typeof ReactTestRenderer.create>) =>
100
+ tree.root
101
+ .findAllByType('ThemedText')
102
+ .map((node: { props: { children?: unknown } }) => node.props.children)
103
+ .find((child) => typeof child === 'string');
104
+
105
+ describe('ProfileSelector sheet title (issue #1666)', () => {
106
+ it('falls back to the localized profile.selector.title when no title is passed', () => {
107
+ const tree = renderSelector();
108
+ expect(titleText(tree)).toBe('Select profiles');
109
+ });
110
+
111
+ it('uses an explicit title when the caller passes one', () => {
112
+ const tree = renderSelector({ title: 'Add members to Test Group' });
113
+ expect(titleText(tree)).toBe('Add members to Test Group');
114
+ });
115
+ });
@@ -33,7 +33,7 @@ export const ProfileSelector = forwardRef<
33
33
  {
34
34
  onSelect,
35
35
  asynOnSelect,
36
- title = 'Add members',
36
+ title,
37
37
  profilesToExclude,
38
38
  selectType = 'sync',
39
39
  initialProfiles,
@@ -131,7 +131,7 @@ export const ProfileSelector = forwardRef<
131
131
 
132
132
  <View className="w-full">
133
133
  <ThemedText className="text-center text-xl font-semibold mb-6">
134
- {title}
134
+ {title ?? t('profile.selector.title')}
135
135
  </ThemedText>
136
136
  <View className="flex-row items-center mb-4 w-full">
137
137
  <View className="rounded-l-md bg-surface p-3">
@@ -21,6 +21,7 @@ import { TextInput } from 'react-native';
21
21
  import { cn } from '../../lib/utils';
22
22
  import { Label } from '../ui/label';
23
23
  import { bottomSheetClose } from '../../lib/bottom-sheet-ref';
24
+ import { useThemeOpacity } from '../../theme/useThemeOpacity';
24
25
 
25
26
  interface ReportProfileOrPostSheetProps {
26
27
  reportCallback?: () => void | undefined;
@@ -34,6 +35,7 @@ export const ReportProfileOrPostModal = forwardRef<
34
35
  ReportProfileOrPostSheetProps
35
36
  >(({ reportType, profile, post, reportCallback }, ref) => {
36
37
  const { t } = useTranslation();
38
+ const { border } = useThemeOpacity();
37
39
  const { openpeepsApi } = useOpenpeeps();
38
40
  const { data: server } = openpeepsApi.useServerInfo();
39
41
  const reportMutation = openpeepsApi.createReportAction();
@@ -162,8 +164,9 @@ export const ReportProfileOrPostModal = forwardRef<
162
164
  {t(`reports.create.${reportType}.anythingElse`)}
163
165
  </Label>
164
166
  <TextInput
167
+ style={border('muted-foreground', 0.25)}
165
168
  className={cn(
166
- 'p-4 text-lg text-foreground border-muted-foreground/25 border-[1px] rounded-md w-full h-36'
169
+ 'p-4 text-lg text-foreground border-[1px] rounded-md w-full h-36'
167
170
  )}
168
171
  placeholder={t(
169
172
  `reports.create.${reportType}.anythingElse`
@@ -0,0 +1,117 @@
1
+ import { useState } from 'react';
2
+ import { Pressable, View } from 'react-native';
3
+ import type { CategoryNode } from '@openpeepshq/common/lib';
4
+ import { categoryPathKey } from '@openpeepshq/common/lib';
5
+ import { Input } from '../ui/input';
6
+ import { ThemedText } from '../ui/themed-text';
7
+ import { useTranslation } from 'react-i18next';
8
+
9
+ export interface CategoryPathPickerProps {
10
+ path: string[];
11
+ tree: CategoryNode[];
12
+ onChange: (path: string[]) => void;
13
+ }
14
+
15
+ const NodeList = ({
16
+ nodes,
17
+ selected,
18
+ onSelect,
19
+ }: {
20
+ nodes: CategoryNode[];
21
+ selected: string[];
22
+ onSelect: (path: string[]) => void;
23
+ }) => (
24
+ <View className="ml-3 border-l border-border pl-3">
25
+ {nodes.map((node) => {
26
+ const active =
27
+ selected.length === node.path.length &&
28
+ node.path.every((segment, index) => selected[index] === segment);
29
+ return (
30
+ <View key={categoryPathKey(node.path)} className="py-0.5">
31
+ <Pressable onPress={() => onSelect(node.path)}>
32
+ <ThemedText
33
+ className={`text-sm ${
34
+ active
35
+ ? 'font-semibold text-foreground'
36
+ : 'text-muted-foreground'
37
+ }`}
38
+ >
39
+ {node.name}
40
+ </ThemedText>
41
+ </Pressable>
42
+ {node.children.length ? (
43
+ <NodeList
44
+ nodes={node.children}
45
+ selected={selected}
46
+ onSelect={onSelect}
47
+ />
48
+ ) : null}
49
+ </View>
50
+ );
51
+ })}
52
+ </View>
53
+ );
54
+
55
+ export const CategoryPathPicker = ({
56
+ path,
57
+ tree,
58
+ onChange,
59
+ }: CategoryPathPickerProps) => {
60
+ const { t } = useTranslation();
61
+ const [level, setLevel] = useState('');
62
+
63
+ return (
64
+ <View className="gap-y-2">
65
+ <ThemedText className="text-sm text-muted-foreground">
66
+ {path.length
67
+ ? path.join(' / ')
68
+ : t('resources.form.uncategorized', {
69
+ defaultValue: 'Uncategorized',
70
+ })}
71
+ </ThemedText>
72
+ {tree.length ? (
73
+ <NodeList nodes={tree} selected={path} onSelect={onChange} />
74
+ ) : null}
75
+ <View className="flex-row gap-2">
76
+ <Input
77
+ value={level}
78
+ onChangeText={setLevel}
79
+ placeholder={t('resources.form.addLevel', {
80
+ defaultValue: 'Add a folder',
81
+ })}
82
+ />
83
+ <Pressable
84
+ className="border-border rounded-md border bg-background px-3 py-1.5"
85
+ onPress={() => {
86
+ const name = level.trim();
87
+ if (!name) return;
88
+ onChange([...path, name]);
89
+ setLevel('');
90
+ }}
91
+ accessibilityRole="button"
92
+ accessibilityLabel={t('common.actions.add', {
93
+ defaultValue: 'Add',
94
+ })}
95
+ >
96
+ <ThemedText className="text-sm text-foreground">
97
+ {t('common.actions.add', { defaultValue: 'Add' })}
98
+ </ThemedText>
99
+ </Pressable>
100
+ {path.length ? (
101
+ <Pressable
102
+ className="px-3 py-1.5"
103
+ onPress={() => onChange([])}
104
+ accessibilityRole="button"
105
+ accessibilityLabel={t('resources.form.clearPath', {
106
+ defaultValue: 'Clear',
107
+ })}
108
+ >
109
+ <ThemedText className="text-sm text-muted-foreground">
110
+ {t('resources.form.clearPath', { defaultValue: 'Clear' })}
111
+ </ThemedText>
112
+ </Pressable>
113
+ ) : null}
114
+ </View>
115
+ </View>
116
+ );
117
+ };
@@ -116,6 +116,18 @@ jest.mock('../icons', () => ({
116
116
  AudioLinesIcon: () => React.createElement('AudioLinesIcon'),
117
117
  }));
118
118
 
119
+ // The provider's import chain reaches @openpeepshq/common, whose node
120
+ // build is ESM (`dist/index.js`) and unparseable by the node jest env.
121
+ // Only getTheme is needed; its real return shape (config.theme.light
122
+ // with `dark: false`) is mirrored here.
123
+ jest.mock('@openpeepshq/common', () => ({
124
+ getTheme: () => ({
125
+ dark: false,
126
+ primaryHex: '#16161a',
127
+ buttonRadius: '9999px',
128
+ }),
129
+ }));
130
+
119
131
  import type { ResourceCardProps } from './ResourceCard';
120
132
  import { ResourceCard } from './ResourceCard';
121
133
 
@@ -29,6 +29,7 @@ import {
29
29
  ImageOffIcon,
30
30
  AudioLinesIcon,
31
31
  } from '../icons';
32
+ import { useThemeOpacity } from '../../theme/useThemeOpacity';
32
33
 
33
34
  export interface ResourceCardProps {
34
35
  post: PublicPost;
@@ -73,6 +74,7 @@ export const ResourceCard = ({
73
74
  inGroup = false,
74
75
  }: ResourceCardProps) => {
75
76
  const { t } = useTranslation();
77
+ const { text } = useThemeOpacity();
76
78
  const navigation =
77
79
  useNavigation<NativeStackNavigationProp<MainStackParamList>>();
78
80
  const goto = buildGoto(navigation);
@@ -301,7 +303,7 @@ export const ResourceCard = ({
301
303
  <View className="bg-muted flex h-full w-full items-center justify-center">
302
304
  <ImageOffIcon
303
305
  size={24}
304
- className="text-muted-foreground/50"
306
+ color={text('muted-foreground', 0.5).color}
305
307
  />
306
308
  </View>
307
309
  )}
@@ -311,11 +313,14 @@ export const ResourceCard = ({
311
313
  </View>
312
314
  ) : resource.resourceKind === 'audio' ? (
313
315
  <View className="h-48 w-full items-center justify-center rounded-md bg-muted">
314
- <AudioLinesIcon size={32} className="text-muted-foreground/50" />
316
+ <AudioLinesIcon
317
+ size={32}
318
+ color={text('muted-foreground', 0.5).color}
319
+ />
315
320
  </View>
316
321
  ) : resource.resourceKind === 'link' && resource.url ? (
317
322
  <View className="h-48 w-full items-center justify-center rounded-md bg-muted">
318
- <LinkIcon size={32} className="text-muted-foreground/50" />
323
+ <LinkIcon size={32} color={text('muted-foreground', 0.5).color} />
319
324
  </View>
320
325
  ) : null}
321
326
  <View className="absolute top-2 right-2">{renderBookmarkButton()}</View>