@openpeepshq/rn-components 0.6.1 → 0.6.3

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 (37) hide show
  1. package/package.json +7 -6
  2. package/src/components/conversations/ConversationMessageBubble.tsx +11 -1
  3. package/src/components/custom/navigation/side-menu.tsx +2 -1
  4. package/src/components/icons/index.ts +8 -0
  5. package/src/components/index.ts +1 -0
  6. package/src/components/layout/PlusButton.tsx +4 -2
  7. package/src/components/layout/pageChrome.tsx +2 -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 +241 -0
  22. package/src/components/post/post-form/index.ts +1 -0
  23. package/src/components/post/types/index.ts +1 -0
  24. package/src/components/post/types/resource/FullResource.tsx +177 -0
  25. package/src/components/resources/ResourceCard.tsx +289 -0
  26. package/src/components/resources/ResourceLibrary.tsx +371 -0
  27. package/src/components/resources/index.ts +4 -0
  28. package/src/global.css +42 -42
  29. package/src/pages/conversations/Index.tsx +12 -59
  30. package/src/pages/groups/Show.tsx +19 -1
  31. package/src/pages/index.ts +3 -0
  32. package/src/pages/resources/Edit.tsx +72 -0
  33. package/src/pages/resources/Index.tsx +25 -0
  34. package/src/pages/resources/New.tsx +55 -0
  35. package/src/theme/defaults.ts +21 -105
  36. package/src/theme/utils.ts +15 -9
  37. package/tailwind.config.js +33 -30
package/src/global.css CHANGED
@@ -4,50 +4,50 @@
4
4
 
5
5
  @layer base {
6
6
  :root {
7
- --background: 255 255 255;
8
- --foreground: 10 10 11;
9
- --card: 255 255 255;
10
- --card-foreground: 10 10 11;
11
- --popover: 255 255 255;
12
- --popover-foreground: 10 10 11;
13
- --primary: 22 22 26;
14
- --primary-foreground: 250 250 250;
15
- --secondary: 244 244 245;
16
- --secondary-foreground: 22 22 26;
17
- --muted: 244 244 246;
18
- --muted-foreground: 113 113 122;
19
- --accent: 244 244 245;
20
- --accent-foreground: 22 22 26;
21
- --destructive: 239 68 68;
22
- --destructive-foreground: 250 250 250;
23
- --border: 228 228 231;
24
- --input: 228 228 231;
25
- --ring: 22 22 26;
26
- --alpha: 250 250 250;
27
- --surface-2: 228 228 231;
7
+ --background: #ffffff;
8
+ --foreground: #0a0a0b;
9
+ --card: #ffffff;
10
+ --card-foreground: #0a0a0b;
11
+ --popover: #ffffff;
12
+ --popover-foreground: #0a0a0b;
13
+ --primary: #16161a;
14
+ --primary-foreground: #fafafa;
15
+ --secondary: #f4f4f5;
16
+ --secondary-foreground: #16161a;
17
+ --muted: #f4f4f6;
18
+ --muted-foreground: #71717a;
19
+ --accent: #f4f4f5;
20
+ --accent-foreground: #16161a;
21
+ --destructive: #ef4444;
22
+ --destructive-foreground: #fafafa;
23
+ --border: #e4e4e7;
24
+ --input: #e4e4e7;
25
+ --ring: #16161a;
26
+ --alpha: #fafafa;
27
+ --surface-2: #e4e4e7;
28
28
  }
29
29
 
30
30
  .dark:root {
31
- --background: 10 10 15;
32
- --foreground: 250 250 250;
33
- --card: 10 10 15;
34
- --card-foreground: 250 250 250;
35
- --popover: 10 10 15;
36
- --popover-foreground: 250 250 250;
37
- --primary: 250 250 250;
38
- --primary-foreground: 22 22 26;
39
- --secondary: 40 40 46;
40
- --secondary-foreground: 250 250 250;
41
- --muted: 39 39 42;
42
- --muted-foreground: 161 161 170;
43
- --accent: 40 40 46;
44
- --accent-foreground: 250 250 250;
45
- --destructive: 220 38 38;
46
- --destructive-foreground: 250 250 250;
47
- --border: 40 40 46;
48
- --input: 40 40 46;
49
- --ring: 212 212 216;
50
- --alpha: 24 24 27;
51
- --surface-2: 63 63 70;
31
+ --background: #0a0a0f;
32
+ --foreground: #fafafa;
33
+ --card: #0a0a0f;
34
+ --card-foreground: #fafafa;
35
+ --popover: #0a0a0f;
36
+ --popover-foreground: #fafafa;
37
+ --primary: #fafafa;
38
+ --primary-foreground: #16161a;
39
+ --secondary: #28282e;
40
+ --secondary-foreground: #fafafa;
41
+ --muted: #27272a;
42
+ --muted-foreground: #a1a1aa;
43
+ --accent: #28282e;
44
+ --accent-foreground: #fafafa;
45
+ --destructive: #dc2626;
46
+ --destructive-foreground: #fafafa;
47
+ --border: #28282e;
48
+ --input: #28282e;
49
+ --ring: #d4d4d8;
50
+ --alpha: #18181b;
51
+ --surface-2: #3f3f46;
52
52
  }
53
53
  }
@@ -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}
@@ -22,7 +22,9 @@ import {
22
22
  EventsFeed,
23
23
  NewEventButton,
24
24
  NewNoteButton,
25
+ NewResourceButton,
25
26
  } from '../../components/post/index';
27
+ import { ResourceLibrary } from '../../components/resources';
26
28
  import {
27
29
  Tabs,
28
30
  TabsContent,
@@ -38,7 +40,7 @@ type GroupProps = CompositeScreenProps<
38
40
  NativeStackScreenProps<TabStackParamList>
39
41
  >;
40
42
 
41
- type Tab = 'posts' | 'events' | 'description';
43
+ type Tab = 'posts' | 'events' | 'resources' | 'description';
42
44
 
43
45
  export const GroupShow = ({ route, navigation }: GroupProps) => {
44
46
  const { openpeepsApi } = useOpenpeeps();
@@ -114,6 +116,12 @@ export const GroupShow = ({ route, navigation }: GroupProps) => {
114
116
  <TabsTrigger value="events" className={tabClass('events')}>
115
117
  <ThemedText>{t('groups.sections.events')}</ThemedText>
116
118
  </TabsTrigger>
119
+ <TabsTrigger
120
+ value="resources"
121
+ className={tabClass('resources')}
122
+ >
123
+ <ThemedText>{t('groups.sections.resources')}</ThemedText>
124
+ </TabsTrigger>
117
125
  <TabsTrigger
118
126
  value="description"
119
127
  className={tabClass('description')}
@@ -159,6 +167,9 @@ export const GroupShow = ({ route, navigation }: GroupProps) => {
159
167
  query={eventsTab === 'upcoming' ? upcomingEvents : pastEvents}
160
168
  />
161
169
  </TabsContent>
170
+ <TabsContent value="resources" className="p-0">
171
+ <ResourceLibrary groupId={group.id} />
172
+ </TabsContent>
162
173
  <TabsContent value="description" className="p-2">
163
174
  <GroupInfoAsComponent id={group.id} />
164
175
  </TabsContent>
@@ -180,6 +191,13 @@ export const GroupShow = ({ route, navigation }: GroupProps) => {
180
191
  group={group}
181
192
  />
182
193
  ) : null}
194
+ {group && tab === 'resources' ? (
195
+ <NewResourceButton
196
+ visibility="group"
197
+ currentProfile={currentProfile}
198
+ group={group}
199
+ />
200
+ ) : null}
183
201
  </ThemedView>
184
202
  );
185
203
  };
@@ -49,6 +49,9 @@ export { Tags } from './Tags';
49
49
  export { Explore } from './Explore';
50
50
  export { FeedsBookmarks } from './feeds/Bookmarks';
51
51
  export { ArticlesIndex } from './articles/Index';
52
+ export { ResourcesIndex } from './resources/Index';
53
+ export { NewResource } from './resources/New';
54
+ export { EditResource } from './resources/Edit';
52
55
  export { LanguageSettings } from './settings/Language';
53
56
  export { TimezoneSettings } from './settings/Timezone';
54
57
  export { NotificationSettings } from './settings/Notifications';
@@ -0,0 +1,72 @@
1
+ import React from 'react';
2
+ import { ActivityIndicator } from 'react-native';
3
+ import { KeyboardAwareScrollView } from 'react-native-keyboard-aware-scroll-view';
4
+ import { useTranslation } from 'react-i18next';
5
+ import Toast from 'react-native-toast-message';
6
+ import { truncateText } from '@openpeepshq/common/lib';
7
+ import { useEditResource } from '@openpeepshq/react';
8
+ import { HeaderActionButton, useSetPageHeader } from '../../components/layout';
9
+ import { ThemedView } from '../../components/ui/themed-view';
10
+ import { MainScreenProps } from '../../components/navigation/types/index';
11
+ import { ResourceForm } from '../../components/post/index';
12
+ import { ThemedText } from '../../components/ui/themed-text';
13
+
14
+ type EditResourceProps = MainScreenProps<'EditResource'>;
15
+
16
+ export const EditResource: React.FC<EditResourceProps> = ({ route }) => {
17
+ const { id } = route.params;
18
+ const { t } = useTranslation();
19
+ const {
20
+ postQuery,
21
+ postData,
22
+ setPostData,
23
+ resourceTitle,
24
+ submitting,
25
+ error,
26
+ clearError,
27
+ submit,
28
+ } = useEditResource(id);
29
+
30
+ React.useEffect(() => {
31
+ if (!error) return;
32
+ Toast.show({ type: 'error', text1: error });
33
+ clearError();
34
+ }, [error, clearError]);
35
+
36
+ const title = resourceTitle
37
+ ? `${t('resources.edit')} ${truncateText(resourceTitle)}`
38
+ : t('resources.edit');
39
+
40
+ useSetPageHeader(
41
+ title,
42
+ <HeaderActionButton
43
+ title={
44
+ submitting
45
+ ? t('common.saving', { defaultValue: 'Saving…' })
46
+ : t('resources.update.title', { defaultValue: 'Update resource' })
47
+ }
48
+ onPress={() => void submit()}
49
+ disabled={submitting || !postData}
50
+ loading={submitting}
51
+ />
52
+ );
53
+
54
+ return (
55
+ <ThemedView className="flex-1">
56
+ {postQuery.isLoading ? (
57
+ <ActivityIndicator size="small" />
58
+ ) : !postQuery.data || !postData ? (
59
+ <ThemedText className="p-8 text-center text-2xl">
60
+ {t('resources.notFound')}
61
+ </ThemedText>
62
+ ) : (
63
+ <KeyboardAwareScrollView
64
+ contentContainerClassName="grow"
65
+ className="pb-12"
66
+ >
67
+ <ResourceForm postData={postData} onChange={setPostData} isEdit />
68
+ </KeyboardAwareScrollView>
69
+ )}
70
+ </ThemedView>
71
+ );
72
+ };
@@ -0,0 +1,25 @@
1
+ import React from 'react';
2
+ import { useTranslation } from 'react-i18next';
3
+ import { useCurrentProfile, useDefaultVisibility } from '@openpeepshq/react';
4
+ import { useSetPageHeader } from '../../components/layout';
5
+ import { NewResourceButton } from '../../components/post/index';
6
+ import { ResourceLibrary } from '../../components/resources/index';
7
+ import { ThemedView } from '../../components/ui/themed-view';
8
+
9
+ export const ResourcesIndex = () => {
10
+ const { t } = useTranslation();
11
+ const currentProfile = useCurrentProfile();
12
+ const visibility = useDefaultVisibility();
13
+
14
+ useSetPageHeader(t('navigation.resources', { defaultValue: 'Resources' }));
15
+
16
+ return (
17
+ <ThemedView className="relative flex-1">
18
+ <ResourceLibrary />
19
+ <NewResourceButton
20
+ visibility={visibility}
21
+ currentProfile={currentProfile}
22
+ />
23
+ </ThemedView>
24
+ );
25
+ };
@@ -0,0 +1,55 @@
1
+ import React from 'react';
2
+ import { KeyboardAwareScrollView } from 'react-native-keyboard-aware-scroll-view';
3
+ import { useTranslation } from 'react-i18next';
4
+ import Toast from 'react-native-toast-message';
5
+ import { useNewResource } from '@openpeepshq/react';
6
+ import { HeaderActionButton, useSetPageHeader } from '../../components/layout';
7
+ import { ThemedView } from '../../components/ui/themed-view';
8
+ import { MainScreenProps } from '../../components/navigation/types/index';
9
+ import { ResourceForm } from '../../components/post/index';
10
+
11
+ type NewResourceProps = MainScreenProps<'NewResource'>;
12
+
13
+ export const NewResource: React.FC<NewResourceProps> = () => {
14
+ const { t } = useTranslation();
15
+ const {
16
+ postData,
17
+ setPostData,
18
+ canSubmit,
19
+ submitting,
20
+ error,
21
+ clearError,
22
+ submit,
23
+ } = useNewResource();
24
+
25
+ React.useEffect(() => {
26
+ if (!error) return;
27
+ Toast.show({ type: 'error', text1: error });
28
+ clearError();
29
+ }, [error, clearError]);
30
+
31
+ useSetPageHeader(
32
+ t('resources.new', { defaultValue: 'New resource' }),
33
+ <HeaderActionButton
34
+ title={
35
+ submitting
36
+ ? t('common.submitting', { defaultValue: 'Submitting…' })
37
+ : t('resources.create.title', { defaultValue: 'Create resource' })
38
+ }
39
+ onPress={() => void submit()}
40
+ disabled={submitting || !canSubmit}
41
+ loading={submitting}
42
+ />
43
+ );
44
+
45
+ return (
46
+ <ThemedView className="flex-1">
47
+ <KeyboardAwareScrollView
48
+ contentContainerClassName="grow"
49
+ className="pb-12"
50
+ >
51
+ <ResourceForm postData={postData} onChange={setPostData} />
52
+ </KeyboardAwareScrollView>
53
+ </ThemedView>
54
+ );
55
+ };
@@ -1,111 +1,27 @@
1
1
  import type { OpenPeepsTheme, ColorName, ColorValue } from './types';
2
2
 
3
3
  export const DEFAULT_COLORS: ColorValue[] = [
4
- {
5
- name: 'background',
6
- light: '#ffffff',
7
- dark: '#0a0a0f',
8
- },
9
- {
10
- name: 'foreground',
11
- light: '#0a0a0b',
12
- dark: '#fafafa',
13
- },
14
- {
15
- name: 'card',
16
- light: '#ffffff',
17
- dark: '#0a0a0f',
18
- },
19
- {
20
- name: 'card-foreground',
21
- light: '#0a0a0b',
22
- dark: '#fafafa',
23
- },
24
- {
25
- name: 'popover',
26
- light: '#ffffff',
27
- dark: '#0a0a0f',
28
- },
29
- {
30
- name: 'popover-foreground',
31
- light: '#0a0a0b',
32
- dark: '#fafafa',
33
- },
34
- {
35
- name: 'primary',
36
- light: '#16161a',
37
- dark: '#fafafa',
38
- },
39
- {
40
- name: 'primary-foreground',
41
- light: '#fafafa',
42
- dark: '#16161a',
43
- },
44
- {
45
- name: 'secondary',
46
- light: '#f4f4f5',
47
- dark: '#28282e',
48
- },
49
- {
50
- name: 'secondary-foreground',
51
- light: '#16161a',
52
- dark: '#fafafa',
53
- },
54
- {
55
- name: 'muted',
56
- light: '#f4f4f6',
57
- dark: '#27272a',
58
- },
59
- {
60
- name: 'muted-foreground',
61
- light: '#71717a',
62
- dark: '#a1a1aa',
63
- },
64
- {
65
- name: 'accent',
66
- light: '#f4f4f5',
67
- dark: '#28282e',
68
- },
69
- {
70
- name: 'accent-foreground',
71
- light: '#16161a',
72
- dark: '#fafafa',
73
- },
74
- {
75
- name: 'destructive',
76
- light: '#ef4444',
77
- dark: '#dc2626',
78
- },
79
- {
80
- name: 'destructive-foreground',
81
- light: '#fafafa',
82
- dark: '#fafafa',
83
- },
84
- {
85
- name: 'border',
86
- light: '#e4e4e7',
87
- dark: '#28282e',
88
- },
89
- {
90
- name: 'input',
91
- light: '#e4e4e7',
92
- dark: '#28282e',
93
- },
94
- {
95
- name: 'ring',
96
- light: '#16161a',
97
- dark: '#d4d4d8',
98
- },
99
- {
100
- name: 'alpha',
101
- light: '#fafafa',
102
- dark: '#18181b',
103
- },
104
- {
105
- name: 'surface-2',
106
- light: '#e4e4e7',
107
- dark: '#3f3f46',
108
- },
4
+ { name: 'background', light: '#ffffff', dark: '#0a0a0f' },
5
+ { name: 'foreground', light: '#0a0a0b', dark: '#fafafa' },
6
+ { name: 'card', light: '#ffffff', dark: '#0a0a0f' },
7
+ { name: 'card-foreground', light: '#0a0a0b', dark: '#fafafa' },
8
+ { name: 'popover', light: '#ffffff', dark: '#0a0a0f' },
9
+ { name: 'popover-foreground', light: '#0a0a0b', dark: '#fafafa' },
10
+ { name: 'primary', light: '#16161a', dark: '#fafafa' },
11
+ { name: 'primary-foreground', light: '#fafafa', dark: '#16161a' },
12
+ { name: 'secondary', light: '#f4f4f5', dark: '#28282e' },
13
+ { name: 'secondary-foreground', light: '#16161a', dark: '#fafafa' },
14
+ { name: 'muted', light: '#f4f4f6', dark: '#27272a' },
15
+ { name: 'muted-foreground', light: '#71717a', dark: '#a1a1aa' },
16
+ { name: 'accent', light: '#f4f4f5', dark: '#28282e' },
17
+ { name: 'accent-foreground', light: '#16161a', dark: '#fafafa' },
18
+ { name: 'destructive', light: '#ef4444', dark: '#dc2626' },
19
+ { name: 'destructive-foreground', light: '#fafafa', dark: '#fafafa' },
20
+ { name: 'border', light: '#e4e4e7', dark: '#28282e' },
21
+ { name: 'input', light: '#e4e4e7', dark: '#28282e' },
22
+ { name: 'ring', light: '#16161a', dark: '#d4d4d8' },
23
+ { name: 'alpha', light: '#fafafa', dark: '#18181b' },
24
+ { name: 'surface-2', light: '#e4e4e7', dark: '#3f3f46' },
109
25
  ];
110
26
 
111
27
  export const mapColors = (isDark: boolean) =>
@@ -2,8 +2,10 @@ import { vars } from 'nativewind';
2
2
  import { mapColors } from './defaults';
3
3
  import type { OpenPeepsTheme } from './types';
4
4
 
5
- /** Convert a hex color (#rrggbb) to "R G B" channel string for CSS `rgb()` usage. */
6
- const hexToRgbChannels = (hex: string): string => {
5
+ /** Convert a hex color (#rrggbb) to "R G B" channel string for use in
6
+ * `rgb()` expressions in inline styles (NativeWind doesn't support `/N`
7
+ * opacity modifiers on CSS-variable colors). */
8
+ export const hexToRgbChannels = (hex: string): string => {
7
9
  const sanitized = hex.replaceAll('##', '#');
8
10
  const m = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(sanitized);
9
11
  if (!m) return hex;
@@ -12,19 +14,23 @@ const hexToRgbChannels = (hex: string): string => {
12
14
  return `${parseInt(r, 16)} ${parseInt(g, 16)} ${parseInt(b, 16)}`;
13
15
  };
14
16
 
17
+ /** Convert a hex color to an `rgba(r, g, b, a)` string for inline styles. */
18
+ export const hexWithOpacity = (hex: string, opacity: number): string => {
19
+ const sanitized = hex.replaceAll('##', '#');
20
+ const m = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(sanitized);
21
+ if (!m) return hex;
22
+ const [, r, g, b] = m;
23
+ if (r === undefined || g === undefined || b === undefined) return hex;
24
+ return `rgba(${parseInt(r, 16)}, ${parseInt(g, 16)}, ${parseInt(b, 16)}, ${opacity})`;
25
+ };
26
+
15
27
  export const getThemeVars = (
16
28
  colors: OpenPeepsTheme['colors'],
17
29
  radii?: { buttonRadius?: string; radius?: string }
18
30
  ) =>
19
31
  vars({
20
- // CSS custom properties consumed by Tailwind `channel()` classes need
21
- // "R G B" channel format so `rgb(var(--x) / <alpha-value>)` resolves.
22
- // The `colors` object keeps hex strings for direct RN style usage.
23
32
  ...Object.fromEntries(
24
- Object.entries(colors).map(([key, value]) => [
25
- `--${key}`,
26
- hexToRgbChannels(value),
27
- ])
33
+ Object.entries(colors).map(([key, value]) => [`--${key}`, value])
28
34
  ),
29
35
  '--theme-rounded-base': radii?.buttonRadius || '9999px',
30
36
  '--theme-rounded-container': radii?.radius || '0.5rem',