@openpeepshq/rn-components 0.6.2 → 0.6.4

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openpeepshq/rn-components",
3
- "version": "0.6.2",
3
+ "version": "0.6.4",
4
4
  "description": "React Native community screens and shared UI (extracted from the Black Ambition app) for the OpenPeeps stack.",
5
5
  "source": "./src/index.ts",
6
6
  "main": "./src/index.ts",
@@ -141,8 +141,8 @@
141
141
  "timezones-list": "^3.1.0",
142
142
  "validator": "^13.15.23",
143
143
  "zustand": "^5.0.3",
144
- "@openpeepshq/common": "^0.3.1",
145
- "@openpeepshq/react": "^0.6.1"
144
+ "@openpeepshq/react": "^0.6.1",
145
+ "@openpeepshq/common": "^0.3.1"
146
146
  },
147
147
  "devDependencies": {
148
148
  "@babel/core": "^7.26.7",
@@ -3,10 +3,17 @@ import { Pressable } from 'react-native';
3
3
  import { PlusIcon } from '../icons/index';
4
4
  import { usePageChrome } from './pageChrome';
5
5
 
6
+ // PlusButton is always fully round — it doesn't use the theme's buttonRadius
7
+ // setting (which is for regular buttons). On web, circular elements have a
8
+ // separate theme token; on RN we use a static 9999px (same as rounded-full).
9
+ const PLUS_BUTTON_RADIUS = 9999;
10
+
6
11
  export const PlusButton = () => {
7
12
  const { plus } = usePageChrome();
8
13
  if (!plus || Array.isArray(plus)) return null;
9
14
 
15
+ const Icon = plus.icon ?? PlusIcon;
16
+
10
17
  const onPress = () => {
11
18
  if (typeof plus.action === 'function') {
12
19
  void plus.action();
@@ -18,9 +25,10 @@ export const PlusButton = () => {
18
25
  accessibilityRole="button"
19
26
  accessibilityLabel={plus.title || 'New'}
20
27
  onPress={onPress}
21
- className="bg-foreground absolute bottom-10 right-6 z-20 size-16 items-center justify-center rounded-full"
28
+ style={{ borderRadius: PLUS_BUTTON_RADIUS }}
29
+ className="bg-primary absolute bottom-10 right-6 z-20 size-16 items-center justify-center rounded-button"
22
30
  >
23
- <PlusIcon size={24} className="text-background" />
31
+ <Icon size={24} className="text-primary-foreground" />
24
32
  </Pressable>
25
33
  );
26
34
  };
@@ -1,5 +1,6 @@
1
1
  import {
2
2
  createContext,
3
+ ComponentType,
3
4
  useContext,
4
5
  useLayoutEffect,
5
6
  useMemo,
@@ -9,6 +10,7 @@ import {
9
10
 
10
11
  export type PlusButtonAction = {
11
12
  action: string | (() => Promise<unknown> | unknown);
13
+ icon?: ComponentType<{ size?: number | string; className?: string }>;
12
14
  title?: string;
13
15
  };
14
16
 
@@ -77,7 +77,9 @@ export const ResourceForm = ({
77
77
  <View>
78
78
  <View className="mt-4 gap-y-4 px-3">
79
79
  <ThemedText className="text-sm font-medium">
80
- {t('resources.form.name')}
80
+ {t('resources.form.name', {
81
+ defaultValue: 'Title',
82
+ })}
81
83
  </ThemedText>
82
84
  <Input
83
85
  value={resource.title}
@@ -85,7 +87,9 @@ export const ResourceForm = ({
85
87
  />
86
88
 
87
89
  <ThemedText className="text-sm font-medium">
88
- {t('resources.form.kind')}
90
+ {t('resources.form.kind', {
91
+ defaultValue: 'Type',
92
+ })}
89
93
  </ThemedText>
90
94
  <View className="flex-row flex-wrap gap-2">
91
95
  {RESOURCE_KINDS.map((kind) => (
@@ -105,7 +109,7 @@ export const ResourceForm = ({
105
109
  : 'text-xs text-muted-foreground'
106
110
  }
107
111
  >
108
- {t(`resources.kinds.${kind}`)}
112
+ {t(`resources.kinds.${kind}`, { defaultValue: kind })}
109
113
  </ThemedText>
110
114
  </Pressable>
111
115
  ))}
@@ -114,7 +118,9 @@ export const ResourceForm = ({
114
118
  {resource.resourceKind === 'link' ? (
115
119
  <>
116
120
  <ThemedText className="text-sm font-medium">
117
- {t('resources.form.url')}
121
+ {t('resources.form.url', {
122
+ defaultValue: 'URL',
123
+ })}
118
124
  </ThemedText>
119
125
  <Input
120
126
  value={resource.url ?? ''}
@@ -128,7 +134,9 @@ export const ResourceForm = ({
128
134
  onPress={openMedia}
129
135
  className="items-center rounded-md border border-input px-3 py-2"
130
136
  >
131
- <ThemedText>{t('resources.form.addMedia')}</ThemedText>
137
+ <ThemedText>
138
+ {t('resources.form.addMedia', { defaultValue: 'Add files' })}
139
+ </ThemedText>
132
140
  </Pressable>
133
141
  <ComposeAttachments
134
142
  attachments={resource.attachments ?? []}
@@ -155,17 +163,23 @@ export const ResourceForm = ({
155
163
  maxLength={4000}
156
164
  value={resource.content ?? ''}
157
165
  onChange={(content) => patchResource({ content })}
158
- placeholder={t('resources.form.descriptionPlaceholder')}
166
+ placeholder={t('resources.form.descriptionPlaceholder', {
167
+ defaultValue: 'Describe this resource',
168
+ })}
159
169
  />
160
170
 
161
171
  <ThemedText className="text-sm font-medium">
162
- {t('resources.form.tags')}
172
+ {t('resources.form.tags', {
173
+ defaultValue: 'Tags',
174
+ })}
163
175
  </ThemedText>
164
176
  <Input
165
177
  value={tagDraft}
166
178
  onChangeText={setTagDraft}
167
179
  onSubmitEditing={addTag}
168
- placeholder={t('resources.form.tagsPlaceholder')}
180
+ placeholder={t('resources.form.tagsPlaceholder', {
181
+ defaultValue: 'Add tags, then press Enter',
182
+ })}
169
183
  />
170
184
  <View className="flex-row flex-wrap gap-1">
171
185
  {normalizeResourceTags(resource.tags).map((tag) => (
@@ -187,7 +201,9 @@ export const ResourceForm = ({
187
201
  </View>
188
202
 
189
203
  <ThemedText className="text-sm font-medium">
190
- {t('resources.form.hierarchy')}
204
+ {t('resources.form.hierarchy', {
205
+ defaultValue: 'Place in the library',
206
+ })}
191
207
  </ThemedText>
192
208
  <Input
193
209
  value={(resource.categoryPath ?? []).join(' / ')}
@@ -199,11 +215,15 @@ export const ResourceForm = ({
199
215
  .filter(Boolean),
200
216
  })
201
217
  }
202
- placeholder={t('resources.form.addLevel')}
218
+ placeholder={t('resources.form.addLevel', {
219
+ defaultValue: 'Add a folder',
220
+ })}
203
221
  />
204
222
 
205
223
  <ThemedText className="text-sm font-medium">
206
- {t('resources.form.visibility')}
224
+ {t('resources.form.visibility', {
225
+ defaultValue: 'Who can see this (Required)',
226
+ })}
207
227
  </ThemedText>
208
228
  <VisibilitySelector
209
229
  audienceSetting={postData}
@@ -159,7 +159,9 @@ export const ResourceLibrary = ({ groupId }: ResourceLibraryProps) => {
159
159
  <Input
160
160
  value={library.search}
161
161
  onChangeText={library.setSearch}
162
- placeholder={t('resources.library.search')}
162
+ placeholder={t('resources.library.search', {
163
+ defaultValue: 'Search resources',
164
+ })}
163
165
  />
164
166
  <View className="flex-row flex-wrap items-center justify-between gap-2">
165
167
  <View className="flex-row flex-wrap gap-2">
@@ -183,7 +185,7 @@ export const ResourceLibrary = ({ groupId }: ResourceLibraryProps) => {
183
185
  }
184
186
  >
185
187
  {kind === 'all'
186
- ? t('resources.library.allKinds')
188
+ ? t('resources.library.allKinds', { defaultValue: 'All' })
187
189
  : t(`resources.kinds.${kind}`)}
188
190
  </ThemedText>
189
191
  </Pressable>
@@ -1,8 +1,9 @@
1
1
  import { cva, type VariantProps } from 'class-variance-authority';
2
2
  import * as React from 'react';
3
- import { Pressable } from 'react-native';
3
+ import { Pressable, type StyleProp, type ViewStyle } from 'react-native';
4
4
  import { TextClassContext } from './themed-text';
5
5
  import { cn } from '../../lib/utils';
6
+ import { useThemeBorderRadius } from '../../theme/OpenPeepsThemeProvider';
6
7
 
7
8
  const buttonVariants = cva(
8
9
  'group flex items-center justify-center rounded-button web:ring-offset-background web:transition-colors web:focus-visible:outline-none web:focus-visible:ring-2 web:focus-visible:ring-ring web:focus-visible:ring-offset-2',
@@ -65,7 +66,11 @@ type ButtonProps = React.ComponentPropsWithoutRef<typeof Pressable> &
65
66
  const Button = React.forwardRef<
66
67
  React.ElementRef<typeof Pressable>,
67
68
  ButtonProps
68
- >(({ className, variant, size, ...props }, ref) => {
69
+ >(({ className, variant, size, style, ...props }, ref) => {
70
+ // NativeWind v4 doesn't resolve CSS variables for borderRadius, so
71
+ // apply the theme button radius via inline style as a fallback.
72
+ const borderRadius = useThemeBorderRadius();
73
+
69
74
  return (
70
75
  <TextClassContext.Provider
71
76
  value={cn(
@@ -80,6 +85,7 @@ const Button = React.forwardRef<
80
85
  )}
81
86
  ref={ref}
82
87
  role="button"
88
+ style={cn({ borderRadius }, style) as StyleProp<ViewStyle>}
83
89
  {...props}
84
90
  />
85
91
  </TextClassContext.Provider>
@@ -4,8 +4,11 @@ import {
4
4
  TouchableOpacity,
5
5
  View,
6
6
  } from 'react-native';
7
- import React, { useEffect, useMemo, useRef, useState } from 'react';
8
- import { MessageCircleOffIcon } from '../../components/icons/index';
7
+ import React, { useMemo, useRef, useState } from 'react';
8
+ import {
9
+ MessageCircleOffIcon,
10
+ MessageSquarePlusIcon,
11
+ } from '../../components/icons/index';
9
12
  import { ThemedText } from '../../components/ui/themed-text';
10
13
  import {
11
14
  useSetPageHeader,
@@ -13,20 +16,16 @@ import {
13
16
  } from '../../components/layout';
14
17
  import { KeyboardAwareScrollView } from 'react-native-keyboard-aware-scroll-view';
15
18
  import { useAuthData, useOpenpeeps } from '@openpeepshq/react';
16
- import { SearchIcon, XIcon } from '../../components/icons/index';
17
19
  import { CompositeScreenProps } from '@react-navigation/native';
18
20
  import { NativeStackScreenProps } from '@react-navigation/native-stack';
19
21
  import {
20
22
  TabStackParamList,
21
23
  MainStackParamList,
22
24
  } from '../../components/navigation/types/index';
23
- import { canCreatePost, PublicPost } from '@openpeepshq/common';
24
- import { Input } from '../../components/ui/input';
25
- import { profileMatchesQuery } from '../../lib/utils';
25
+ import { canCreatePost } from '@openpeepshq/common';
26
26
  import { BottomSheetModal } from '@gorhom/bottom-sheet';
27
27
  import {
28
28
  ConversationPreviewCard,
29
- DirectMessagesHeaderActions,
30
29
  useCreateNewConversation,
31
30
  } from '../../components/conversations/index';
32
31
  import { useTranslation } from 'react-i18next';
@@ -47,11 +46,6 @@ export const ConversationsIndex: React.FC<MessagesProps> = ({ navigation }) => {
47
46
  const { openCreateConversation } = useCreateNewConversation();
48
47
  const settingsRef = useRef<BottomSheetModal>(null);
49
48
  const [refreshing, setRefreshing] = useState(false);
50
- const [filteredConversations, setFilteredConversations] = useState<
51
- PublicPost[][]
52
- >([]);
53
- const [searchQuery, setSearchQuery] = useState('');
54
- const [isSearchToggled, setIsSearchToggled] = useState(false);
55
49
  const [tab, setTab] = useState<ConversationsTab>('active');
56
50
 
57
51
  const query = openpeepsApi.useConversations();
@@ -71,51 +65,8 @@ export const ConversationsIndex: React.FC<MessagesProps> = ({ navigation }) => {
71
65
  setRefreshing(false);
72
66
  }, [activeQuery]);
73
67
 
74
- useEffect(() => {
75
- const filtered = conversations.filter((conversation) =>
76
- conversation.some(
77
- (message) =>
78
- message?.data?.content
79
- ?.toLowerCase()
80
- .includes(searchQuery.toLowerCase()) ||
81
- profileMatchesQuery(message.profile, searchQuery)
82
- )
83
- );
84
- setFilteredConversations(filtered);
85
- }, [conversations, searchQuery]);
86
-
87
- useSetPageHeader(
88
- t('navigation.messages'),
89
- <View className="flex-row items-center gap-x-3">
90
- {isSearchToggled ? (
91
- <View className="max-w-[180px] flex-row items-center">
92
- <Input
93
- className="flex-1"
94
- placeholder={t('conversations.search.placeholder')}
95
- value={searchQuery}
96
- onChangeText={setSearchQuery}
97
- />
98
- <TouchableOpacity
99
- className="items-center justify-center px-2"
100
- onPress={() => {
101
- setSearchQuery('');
102
- setIsSearchToggled(false);
103
- }}
104
- >
105
- <XIcon size={20} className="text-foreground" />
106
- </TouchableOpacity>
107
- </View>
108
- ) : (
109
- <TouchableOpacity onPress={() => setIsSearchToggled(true)}>
110
- <SearchIcon size={20} className="text-foreground" />
111
- </TouchableOpacity>
112
- )}
113
- <DirectMessagesHeaderActions />
114
- </View>
115
- );
116
-
117
68
  const headerTabs = (
118
- <View className="flex-row border-b border-border">
69
+ <View className="flex-row">
119
70
  <TouchableOpacity
120
71
  onPress={() => setTab('active')}
121
72
  className={`px-4 py-2 text-sm ${
@@ -151,10 +102,13 @@ export const ConversationsIndex: React.FC<MessagesProps> = ({ navigation }) => {
151
102
  </View>
152
103
  );
153
104
 
105
+ useSetPageHeader(t('navigation.messages'), headerTabs);
106
+
154
107
  useSetPlusButtonActions(
155
108
  canCreate
156
109
  ? {
157
110
  title: t('conversations.newMessage'),
111
+ icon: MessageSquarePlusIcon,
158
112
  action: () => openCreateConversation(),
159
113
  }
160
114
  : undefined
@@ -164,7 +118,6 @@ export const ConversationsIndex: React.FC<MessagesProps> = ({ navigation }) => {
164
118
 
165
119
  return (
166
120
  <View className="flex-1">
167
- {headerTabs}
168
121
  <KeyboardAwareScrollView
169
122
  refreshControl={
170
123
  <RefreshControl refreshing={refreshing} onRefresh={onRefresh} />
@@ -173,7 +126,7 @@ export const ConversationsIndex: React.FC<MessagesProps> = ({ navigation }) => {
173
126
  className="w-full flex bg-background relative p-2"
174
127
  >
175
128
  {isLoading && <ActivityIndicator size={'small'} />}
176
- {!isLoading && filteredConversations?.length === 0 && (
129
+ {!isLoading && conversations?.length === 0 && (
177
130
  <View className="flex h-[80vh] items-center justify-center gap-2">
178
131
  <MessageCircleOffIcon size={40} className="text-muted-foreground" />
179
132
  <ThemedText className="text-muted-foreground">
@@ -184,7 +137,7 @@ export const ConversationsIndex: React.FC<MessagesProps> = ({ navigation }) => {
184
137
  </View>
185
138
  )}
186
139
  {!isLoading &&
187
- filteredConversations?.map((conversation, idx) => (
140
+ conversations?.map((conversation, idx) => (
188
141
  <ConversationPreviewCard
189
142
  key={idx}
190
143
  conversation={conversation}
@@ -11,7 +11,7 @@ export const ResourcesIndex = () => {
11
11
  const currentProfile = useCurrentProfile();
12
12
  const visibility = useDefaultVisibility();
13
13
 
14
- useSetPageHeader(t('navigation.resources'));
14
+ useSetPageHeader(t('navigation.resources', { defaultValue: 'Resources' }));
15
15
 
16
16
  return (
17
17
  <ThemedView className="relative flex-1">
@@ -4,7 +4,7 @@ import { colorScheme } from 'nativewind';
4
4
  import { useOpenpeeps } from '@openpeepshq/react';
5
5
  import { OpenPeepsTheme } from './types';
6
6
  import { defaultTheme } from './defaults';
7
- import { buildTheme, getThemeVars } from './utils';
7
+ import { buildTheme, getThemeVars, parseDimension } from './utils';
8
8
  import { CommunityConfig, getTheme } from '@openpeepshq/common';
9
9
 
10
10
  const OpenPeepsThemeContext = createContext<OpenPeepsTheme>(defaultTheme);
@@ -36,10 +36,20 @@ export const OpenPeepsThemeProvider = ({
36
36
 
37
37
  const theme = useMemo(
38
38
  () =>
39
- buildTheme(resolvedTheme.dark, resolvedTheme.primaryHex, () => {
40
- refetchProfileSettings();
41
- }),
42
- [refetchProfileSettings, resolvedTheme.dark, resolvedTheme.primaryHex]
39
+ buildTheme(
40
+ resolvedTheme.dark,
41
+ resolvedTheme.primaryHex,
42
+ resolvedTheme.buttonRadius,
43
+ () => {
44
+ refetchProfileSettings();
45
+ }
46
+ ),
47
+ [
48
+ refetchProfileSettings,
49
+ resolvedTheme.dark,
50
+ resolvedTheme.primaryHex,
51
+ resolvedTheme.buttonRadius,
52
+ ]
43
53
  );
44
54
 
45
55
  const themeVars = useMemo(
@@ -78,3 +88,11 @@ export const useOpenPeepsTheme = () => {
78
88
  }
79
89
  return context;
80
90
  };
91
+
92
+ /** Returns the theme button border-radius as a React Native numeric value.
93
+ * NativeWind v4 does not resolve CSS variables for borderRadius, so
94
+ * components must apply this via inline style instead of `rounded-button`. */
95
+ export const useThemeBorderRadius = (): number => {
96
+ const { buttonRadius } = useOpenPeepsTheme();
97
+ return parseDimension(buttonRadius);
98
+ };
@@ -35,5 +35,6 @@ export const mapColors = (isDark: boolean) =>
35
35
  export const defaultTheme: OpenPeepsTheme = {
36
36
  isDark: true,
37
37
  colors: mapColors(true),
38
+ buttonRadius: '9999px',
38
39
  refresh: () => {},
39
40
  };
@@ -33,4 +33,5 @@ export type OpenPeepsTheme = {
33
33
  colors: {
34
34
  [key in ColorName]: string;
35
35
  };
36
+ buttonRadius: string;
36
37
  };
@@ -36,9 +36,17 @@ export const getThemeVars = (
36
36
  '--theme-rounded-container': radii?.radius || '0.5rem',
37
37
  });
38
38
 
39
+ /** Parse a CSS dimension string (e.g. '9999px', '8px') into a React Native
40
+ * numeric pixel value. Returns 0 when the string can't be parsed. */
41
+ export const parseDimension = (value: string): number => {
42
+ const num = parseFloat(value);
43
+ return isNaN(num) ? 0 : num;
44
+ };
45
+
39
46
  export const buildTheme = (
40
47
  isDark: boolean,
41
48
  primaryColor: string | undefined,
49
+ buttonRadius: string | undefined,
42
50
  refresh: () => void | Promise<void>
43
51
  ) => {
44
52
  const colors = mapColors(isDark);
@@ -48,6 +56,7 @@ export const buildTheme = (
48
56
  ...colors,
49
57
  primary: primaryColor || colors.primary,
50
58
  },
59
+ buttonRadius: buttonRadius || '9999px',
51
60
  refresh,
52
61
  };
53
62
  };
@@ -66,10 +66,15 @@ export default {
66
66
  hairline: hairlineWidth(),
67
67
  },
68
68
  borderRadius: {
69
- button: 'var(--theme-rounded-base)',
69
+ // NativeWind v4 does not resolve CSS variables for borderRadius
70
+ // (only for colors via processColor). Components apply the theme
71
+ // button radius via inline style (see useThemeBorderRadius).
72
+ // Static fallback ensures non-square buttons as a safety net.
73
+ button: '9999px',
70
74
  lg: 'var(--theme-rounded-container, 0.5rem)',
71
75
  md: 'calc(var(--theme-rounded-container, 0.5rem) - 2px)',
72
76
  sm: 'calc(var(--theme-rounded-container, 0.5rem) - 4px)',
77
+ full: '9999px',
73
78
  },
74
79
  fontFamily: {
75
80
  sans: 'var(--theme-font-family-base, system-ui)',