@openpeepshq/rn-components 0.12.2 → 0.12.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 +5 -5
- package/src/components/CapabilityMatrix.tsx +44 -6
- package/src/components/conversations/ConversationMessageBubble.tsx +3 -6
- package/src/components/custom/common/popover.tsx +4 -1
- package/src/components/custom/modals/media/document-picker-sheet.tsx +10 -3
- package/src/components/custom/modals/media/send-media-sheet.tsx +4 -1
- package/src/components/groups/GroupMembersList.tsx +4 -1
- package/src/components/jams/JamCallParticipant.tsx +6 -1
- package/src/components/jams/JamDesktopFooter.tsx +6 -1
- package/src/components/jams/JamFooter.tsx +6 -1
- package/src/components/jams/JamGuestForm.tsx +6 -1
- package/src/components/jams/JamObserverShell.tsx +4 -1
- package/src/components/jams/JamRoomIndicators.test.tsx +143 -0
- package/src/components/jams/JamRoomIndicators.tsx +15 -8
- package/src/components/jams/JamToolbarButton.tsx +7 -1
- package/src/components/post/feed/events/EventsCalendar.tsx +6 -2
- package/src/components/post/pieces/UnreadPostIndicator.tsx +4 -4
- package/src/components/post/post-form/ComposeAttachments.tsx +6 -2
- package/src/components/post/post-form/EventForm.tsx +4 -4
- package/src/components/post/types/event/FullEvent.test.tsx +1 -0
- package/src/components/post/types/event/FullEvent.tsx +10 -2
- package/src/components/profile/ReportProfileOrPostModal.tsx +4 -1
- package/src/components/resources/ResourceCard.test.tsx +12 -0
- package/src/components/resources/ResourceCard.tsx +8 -3
- package/src/pages/Welcome.tsx +4 -1
- package/src/theme/OpenPeepsThemeProvider.tsx +6 -5
- package/src/theme/color.ts +29 -0
- package/src/theme/useThemeOpacity.ts +30 -0
- package/src/theme/utils.ts +11 -22
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openpeepshq/rn-components",
|
|
3
|
-
"version": "0.12.
|
|
3
|
+
"version": "0.12.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",
|
|
@@ -142,8 +142,8 @@
|
|
|
142
142
|
"timezones-list": "^3.1.0",
|
|
143
143
|
"validator": "^13.15.23",
|
|
144
144
|
"zustand": "^5.0.3",
|
|
145
|
-
"@openpeepshq/common": "^0.6.
|
|
146
|
-
"@openpeepshq/react": "^0.11.
|
|
145
|
+
"@openpeepshq/common": "^0.6.2",
|
|
146
|
+
"@openpeepshq/react": "^0.11.1"
|
|
147
147
|
},
|
|
148
148
|
"devDependencies": {
|
|
149
149
|
"@babel/core": "^7.26.7",
|
|
@@ -161,7 +161,7 @@
|
|
|
161
161
|
"@react-native/jest-preset": "0.85.2",
|
|
162
162
|
"@react-native/metro-config": "0.85.2",
|
|
163
163
|
"@react-native/typescript-config": "0.85.2",
|
|
164
|
-
"@release-it/conventional-changelog": "^
|
|
164
|
+
"@release-it/conventional-changelog": "^12.0.2",
|
|
165
165
|
"@sentry/cli": "^3.3.5",
|
|
166
166
|
"@types/jest": "^29.5.14",
|
|
167
167
|
"@types/node": "^22.14.1",
|
|
@@ -182,7 +182,7 @@
|
|
|
182
182
|
"prettier": "^3.0.3",
|
|
183
183
|
"react-native-builder-bob": "^0.35.2",
|
|
184
184
|
"react-test-renderer": "19.2.3",
|
|
185
|
-
"release-it": "^
|
|
185
|
+
"release-it": "^19.0.0",
|
|
186
186
|
"ts-jest": "^29.3.4",
|
|
187
187
|
"typescript": "^6.0.2",
|
|
188
188
|
"@eslint/js": "^9.17.0"
|
|
@@ -11,6 +11,8 @@ import {
|
|
|
11
11
|
} from '@openpeepshq/react';
|
|
12
12
|
import { ThemedText } from './ui/themed-text';
|
|
13
13
|
import { cn } from '../lib/utils';
|
|
14
|
+
import { useThemeOpacity } from '../theme/useThemeOpacity';
|
|
15
|
+
import type { ColorName } from '../theme/types';
|
|
14
16
|
|
|
15
17
|
export interface CapabilityMatrixColumn {
|
|
16
18
|
key: string;
|
|
@@ -29,14 +31,35 @@ export interface CapabilityMatrixProps {
|
|
|
29
31
|
defaultCapabilities?: MatrixCapabilities;
|
|
30
32
|
}
|
|
31
33
|
|
|
34
|
+
// Border color classes use solid tokens; the implicit (wildcard) states need
|
|
35
|
+
// a 40% border and a faint tint, which NativeWind can't express on
|
|
36
|
+
// CSS-variable colors, so those are built as inline styles (see
|
|
37
|
+
// useThemeOpacity) via `cellBorder` / `cellBackground`.
|
|
32
38
|
const cellClass: Record<CapabilityCellState, string> = {
|
|
33
|
-
'none': 'border-border
|
|
34
|
-
'implicit-remove': '
|
|
35
|
-
'implicit-add': '
|
|
36
|
-
'specific-add': 'border-primary
|
|
37
|
-
'specific-remove': 'border-destructive
|
|
39
|
+
'none': 'border-border',
|
|
40
|
+
'implicit-remove': '',
|
|
41
|
+
'implicit-add': '',
|
|
42
|
+
'specific-add': 'border-primary',
|
|
43
|
+
'specific-remove': 'border-destructive',
|
|
38
44
|
};
|
|
39
45
|
|
|
46
|
+
const cellBorder: Record<CapabilityCellState, [ColorName, number] | null> = {
|
|
47
|
+
'none': null,
|
|
48
|
+
'implicit-remove': ['destructive', 0.4],
|
|
49
|
+
'implicit-add': ['primary', 0.4],
|
|
50
|
+
'specific-add': null,
|
|
51
|
+
'specific-remove': null,
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
const cellBackground: Record<CapabilityCellState, [ColorName, number] | null> =
|
|
55
|
+
{
|
|
56
|
+
'none': null,
|
|
57
|
+
'implicit-remove': ['destructive', 0.15],
|
|
58
|
+
'implicit-add': ['primary', 0.1],
|
|
59
|
+
'specific-add': ['primary', 0.25],
|
|
60
|
+
'specific-remove': ['destructive', 0.25],
|
|
61
|
+
};
|
|
62
|
+
|
|
40
63
|
const cellTextClass: Record<CapabilityCellState, string> = {
|
|
41
64
|
'none': 'text-foreground',
|
|
42
65
|
'implicit-remove': 'text-destructive',
|
|
@@ -70,6 +93,7 @@ export const CapabilityMatrix = ({
|
|
|
70
93
|
defaultCapabilities,
|
|
71
94
|
}: CapabilityMatrixProps) => {
|
|
72
95
|
const { t } = useTranslation();
|
|
96
|
+
const { background, border } = useThemeOpacity();
|
|
73
97
|
const options: CapabilityMatrixOptions = {
|
|
74
98
|
editorKeys,
|
|
75
99
|
columns: columns.map((column) => column.key),
|
|
@@ -93,6 +117,16 @@ export const CapabilityMatrix = ({
|
|
|
93
117
|
column,
|
|
94
118
|
cap
|
|
95
119
|
) !== state;
|
|
120
|
+
const borderStyle = cellBorder[state]
|
|
121
|
+
? border(cellBorder[state][0], cellBorder[state][1])
|
|
122
|
+
: undefined;
|
|
123
|
+
const backgroundStyle = cellBackground[state]
|
|
124
|
+
? background(cellBackground[state][0], cellBackground[state][1])
|
|
125
|
+
: undefined;
|
|
126
|
+
const cellStyle =
|
|
127
|
+
borderStyle || backgroundStyle
|
|
128
|
+
? { ...borderStyle, ...backgroundStyle }
|
|
129
|
+
: undefined;
|
|
96
130
|
return (
|
|
97
131
|
<View key={column} style={styles.cell} className="items-center p-1">
|
|
98
132
|
<Pressable
|
|
@@ -101,6 +135,7 @@ export const CapabilityMatrix = ({
|
|
|
101
135
|
onPress={() =>
|
|
102
136
|
onChange(cycleCapabilityCell(options, value, column, cap))
|
|
103
137
|
}
|
|
138
|
+
style={cellStyle}
|
|
104
139
|
className={cn(
|
|
105
140
|
'h-7 w-7 items-center justify-center rounded border',
|
|
106
141
|
cellClass[state],
|
|
@@ -170,7 +205,10 @@ export const CapabilityMatrix = ({
|
|
|
170
205
|
const groupLabel = group.prefix.replace(/-$/, '');
|
|
171
206
|
return (
|
|
172
207
|
<React.Fragment key={group.wildcard}>
|
|
173
|
-
<View
|
|
208
|
+
<View
|
|
209
|
+
style={background('muted', 0.6)}
|
|
210
|
+
className="flex-row items-center border-t border-border"
|
|
211
|
+
>
|
|
174
212
|
<View style={styles.label} className="p-2">
|
|
175
213
|
<ThemedText
|
|
176
214
|
className="text-xs font-medium"
|
|
@@ -3,10 +3,9 @@ import { View } from 'react-native';
|
|
|
3
3
|
import { useTranslation } from 'react-i18next';
|
|
4
4
|
import type { PublicPost } from '@openpeepshq/common/types';
|
|
5
5
|
import { useCurrentProfile, usePostReactionToggle } from '@openpeepshq/react';
|
|
6
|
-
import {
|
|
6
|
+
import { useThemeOpacity } from '../../theme/useThemeOpacity';
|
|
7
7
|
import { FeedPostContent } from '../post/FeedPostContent';
|
|
8
8
|
import { UnreadPostIndicator } from '../post/pieces/UnreadPostIndicator';
|
|
9
|
-
import { hexWithOpacity } from '../../theme/utils';
|
|
10
9
|
import { Button } from '../ui/button';
|
|
11
10
|
import { ThemedText } from '../ui/themed-text';
|
|
12
11
|
import { ThumbsUpIcon } from '../icons/index';
|
|
@@ -21,7 +20,7 @@ export const ConversationMessageBubble = ({
|
|
|
21
20
|
unread = false,
|
|
22
21
|
}: ConversationMessageBubbleProps) => {
|
|
23
22
|
const me = useCurrentProfile();
|
|
24
|
-
const
|
|
23
|
+
const { background } = useThemeOpacity();
|
|
25
24
|
const { t } = useTranslation();
|
|
26
25
|
const mine = message.profile.id === me?.id;
|
|
27
26
|
const { iReacted, canReact, toggleReaction } = usePostReactionToggle(message);
|
|
@@ -29,9 +28,7 @@ export const ConversationMessageBubble = ({
|
|
|
29
28
|
|
|
30
29
|
// NativeWind v4 can't apply `/N` opacity to CSS-variable colors (e.g.
|
|
31
30
|
// `bg-primary/10`), so we use an inline rgba style for own-message bubbles.
|
|
32
|
-
const bubbleStyle = mine
|
|
33
|
-
? { backgroundColor: hexWithOpacity(theme.colors.primary, 0.1) }
|
|
34
|
-
: undefined;
|
|
31
|
+
const bubbleStyle = mine ? background('primary', 0.1) : undefined;
|
|
35
32
|
|
|
36
33
|
return (
|
|
37
34
|
<View
|
|
@@ -13,6 +13,7 @@ import { useSafeAreaInsets } from 'react-native-safe-area-context';
|
|
|
13
13
|
import * as Slot from '@rn-primitives/slot';
|
|
14
14
|
import { cn } from '../../../lib/utils';
|
|
15
15
|
import { Button, buttonVariants } from '../../ui/button';
|
|
16
|
+
import { useThemeOpacity } from '../../../theme/useThemeOpacity';
|
|
16
17
|
|
|
17
18
|
const windowWidth = Dimensions.get('window').width;
|
|
18
19
|
|
|
@@ -150,6 +151,7 @@ const PopoverContent = React.forwardRef<
|
|
|
150
151
|
ref
|
|
151
152
|
) => {
|
|
152
153
|
const insets = useSafeAreaInsets();
|
|
154
|
+
const { background } = useThemeOpacity();
|
|
153
155
|
const {
|
|
154
156
|
triggerPosition,
|
|
155
157
|
setTriggerPosition,
|
|
@@ -177,7 +179,8 @@ const PopoverContent = React.forwardRef<
|
|
|
177
179
|
setTriggerPosition(null);
|
|
178
180
|
setContentLayout(null);
|
|
179
181
|
}}
|
|
180
|
-
|
|
182
|
+
style={background('background', 0.3)}
|
|
183
|
+
className={cn('flex-1', overlayClass)}
|
|
181
184
|
>
|
|
182
185
|
{!!triggerPosition && (
|
|
183
186
|
<Pressable
|
|
@@ -15,6 +15,7 @@ import {
|
|
|
15
15
|
} from '@react-native-documents/picker';
|
|
16
16
|
import { viewDocument } from '@react-native-documents/viewer';
|
|
17
17
|
import { formatSize, MediaAttachment } from '@openpeepshq/common';
|
|
18
|
+
import { useThemeOpacity } from '../../../../theme/useThemeOpacity';
|
|
18
19
|
import { useOpenpeeps } from '@openpeepshq/react';
|
|
19
20
|
import { Button } from '../../../ui/button';
|
|
20
21
|
import {
|
|
@@ -102,6 +103,7 @@ export const DocumentPickerSheet = forwardRef<
|
|
|
102
103
|
const [editingDocUri, setEditingDocUri] = useState<string | null>(null);
|
|
103
104
|
const [isConfirmLoading, setIsConfirmLoading] = useState(false);
|
|
104
105
|
const { t } = useTranslation();
|
|
106
|
+
const { background, text } = useThemeOpacity();
|
|
105
107
|
const { openpeepsApi } = useOpenpeeps();
|
|
106
108
|
const createAttachment = openpeepsApi.createMediaAttachmentAction();
|
|
107
109
|
|
|
@@ -289,7 +291,10 @@ export const DocumentPickerSheet = forwardRef<
|
|
|
289
291
|
<Text className="text-muted-foreground text-xs">
|
|
290
292
|
{formatSize(doc.size || 0)}
|
|
291
293
|
</Text>
|
|
292
|
-
<Text
|
|
294
|
+
<Text
|
|
295
|
+
style={text('muted-foreground', 0.5)}
|
|
296
|
+
className="text-[10px] ml-2"
|
|
297
|
+
>
|
|
293
298
|
{descriptions[doc.uri]?.trim()
|
|
294
299
|
? t('form.uploadEditModal.description.altText')
|
|
295
300
|
: t('form.uploadEditModal.description.placeholder')}
|
|
@@ -303,7 +308,8 @@ export const DocumentPickerSheet = forwardRef<
|
|
|
303
308
|
onPress={() => handlePreview(doc)}
|
|
304
309
|
accessibilityRole="button"
|
|
305
310
|
accessibilityLabel={t('form.preview')}
|
|
306
|
-
|
|
311
|
+
style={background('muted', 0.5)}
|
|
312
|
+
className="p-2 rounded-full"
|
|
307
313
|
>
|
|
308
314
|
<EyeOnIcon size={16} className="text-muted-foreground" />
|
|
309
315
|
</TouchableOpacity>
|
|
@@ -313,7 +319,8 @@ export const DocumentPickerSheet = forwardRef<
|
|
|
313
319
|
accessibilityLabel={t('posts.attachments.deleteTitle', {
|
|
314
320
|
defaultValue: 'Delete attachment',
|
|
315
321
|
})}
|
|
316
|
-
|
|
322
|
+
style={background('muted', 0.5)}
|
|
323
|
+
className="p-2 rounded-full"
|
|
317
324
|
>
|
|
318
325
|
<XIcon size={16} className="text-muted-foreground" />
|
|
319
326
|
</TouchableOpacity>
|
|
@@ -14,6 +14,7 @@ import { Button } from '../../../ui/button';
|
|
|
14
14
|
import { CameraIcon, ImageIcon } from '../../../icons/index';
|
|
15
15
|
import { launchCamera, launchImageLibrary } from 'react-native-image-picker';
|
|
16
16
|
import { ThemedText } from '../../../ui/themed-text';
|
|
17
|
+
import { useThemeOpacity } from '../../../../theme/useThemeOpacity';
|
|
17
18
|
import { useNewConversationStore } from '../../../../stores/useNewConversationStore';
|
|
18
19
|
import { useOpenpeeps } from '@openpeepshq/react';
|
|
19
20
|
import type { MediaAttachment, PostCreationData } from '@openpeepshq/common';
|
|
@@ -58,6 +59,7 @@ export const SendMediaSheet = forwardRef<BottomSheetModal, SendMediaSheetProps>(
|
|
|
58
59
|
});
|
|
59
60
|
const [currentImageIndex, setCurrentImageIndex] = useState(0);
|
|
60
61
|
const { t } = useTranslation();
|
|
62
|
+
const { background } = useThemeOpacity();
|
|
61
63
|
|
|
62
64
|
const addImages = (uris: string[]) =>
|
|
63
65
|
setSelectedImages((prev) => [
|
|
@@ -161,7 +163,8 @@ export const SendMediaSheet = forwardRef<BottomSheetModal, SendMediaSheetProps>(
|
|
|
161
163
|
prev.filter((img) => img !== uri)
|
|
162
164
|
)
|
|
163
165
|
}
|
|
164
|
-
|
|
166
|
+
style={background('background', 0.5)}
|
|
167
|
+
className="absolute top-4 right-8 w-8 h-8 rounded-full items-center justify-center"
|
|
165
168
|
>
|
|
166
169
|
<ThemedText className="text-lg">×</ThemedText>
|
|
167
170
|
</TouchableOpacity>
|
|
@@ -32,6 +32,7 @@ import { Input } from '../ui/input';
|
|
|
32
32
|
import { ThemedText } from '../ui/themed-text';
|
|
33
33
|
import { ChangeGroupRolesModal } from './ChangeGroupRolesModal';
|
|
34
34
|
import { ConfirmMemberRemovalModal } from './ConfirmMemberRemovalModal';
|
|
35
|
+
import { useThemeOpacity } from '../../theme/useThemeOpacity';
|
|
35
36
|
|
|
36
37
|
export interface GroupMembersListProps {
|
|
37
38
|
group: GroupWithMeta;
|
|
@@ -44,6 +45,7 @@ type ActiveModal =
|
|
|
44
45
|
|
|
45
46
|
export const GroupMembersList = ({ group }: GroupMembersListProps) => {
|
|
46
47
|
const { t } = useTranslation();
|
|
48
|
+
const { background } = useThemeOpacity();
|
|
47
49
|
const me = useCurrentProfile();
|
|
48
50
|
const { openpeepsApi } = useOpenpeeps();
|
|
49
51
|
const navigation =
|
|
@@ -100,7 +102,8 @@ export const GroupMembersList = ({ group }: GroupMembersListProps) => {
|
|
|
100
102
|
{member.roles.map((role) => (
|
|
101
103
|
<View
|
|
102
104
|
key={role}
|
|
103
|
-
|
|
105
|
+
style={background('primary', 0.1)}
|
|
106
|
+
className="rounded px-1.5 py-0.5"
|
|
104
107
|
>
|
|
105
108
|
<ThemedText className="text-xs uppercase text-primary">
|
|
106
109
|
{t(`groups.roles.${role}`, { defaultValue: role })}
|
|
@@ -40,6 +40,7 @@ import { cn } from '../../lib/utils';
|
|
|
40
40
|
import { ProfileAvatar } from '../profile/Avatar';
|
|
41
41
|
import { JamAnimatedEmoji } from './JamAnimatedEmoji';
|
|
42
42
|
import { useConnectionLost } from './useParticipantConnection';
|
|
43
|
+
import { useThemeOpacity } from '../../theme/useThemeOpacity';
|
|
43
44
|
|
|
44
45
|
export interface JamCallParticipantProps {
|
|
45
46
|
/** Camera track reference (or placeholder when the camera is off). */
|
|
@@ -166,6 +167,7 @@ const JamParticipantOverlay = ({
|
|
|
166
167
|
onToggleSpotlight?: () => void;
|
|
167
168
|
}) => {
|
|
168
169
|
const { t } = useTranslation();
|
|
170
|
+
const { background } = useThemeOpacity();
|
|
169
171
|
const participant = trackRef.participant;
|
|
170
172
|
const room = useRoomContext();
|
|
171
173
|
const me = useCurrentProfile();
|
|
@@ -217,7 +219,10 @@ const JamParticipantOverlay = ({
|
|
|
217
219
|
<View className="w-full flex-row items-start justify-between">
|
|
218
220
|
<View className="flex-row items-center gap-1">
|
|
219
221
|
{handUp ? (
|
|
220
|
-
<View
|
|
222
|
+
<View
|
|
223
|
+
style={background('background', 0.7)}
|
|
224
|
+
className="rounded-full p-2"
|
|
225
|
+
>
|
|
221
226
|
<HandIcon size={iconSize} className="text-foreground" />
|
|
222
227
|
</View>
|
|
223
228
|
) : null}
|
|
@@ -23,6 +23,7 @@ import { LeaveCloseButton } from './LeaveCloseButton';
|
|
|
23
23
|
import { type JamFooterProps } from './JamFooter';
|
|
24
24
|
import { useFooterControls } from './JamFooter';
|
|
25
25
|
import { ThemedText } from '../ui/themed-text';
|
|
26
|
+
import { useThemeOpacity } from '../../theme/useThemeOpacity';
|
|
26
27
|
|
|
27
28
|
export type JamDesktopFooterProps = JamFooterProps;
|
|
28
29
|
|
|
@@ -46,6 +47,7 @@ export const JamDesktopFooter = ({
|
|
|
46
47
|
onToggleSpeaker,
|
|
47
48
|
}: JamDesktopFooterProps) => {
|
|
48
49
|
const { t } = useTranslation();
|
|
50
|
+
const { background } = useThemeOpacity();
|
|
49
51
|
const { jamEvent } = useJamContext();
|
|
50
52
|
const {
|
|
51
53
|
isModerator,
|
|
@@ -63,7 +65,10 @@ export const JamDesktopFooter = ({
|
|
|
63
65
|
const [reactionMenuOpen, setReactionMenuOpen] = useState(false);
|
|
64
66
|
|
|
65
67
|
return (
|
|
66
|
-
<View
|
|
68
|
+
<View
|
|
69
|
+
style={background('background', 0.75)}
|
|
70
|
+
className="w-full flex-none flex-row items-center justify-between px-4 py-3"
|
|
71
|
+
>
|
|
67
72
|
<ThemedText className="truncate pr-2">
|
|
68
73
|
{truncateText(jamEvent.name, 40)}
|
|
69
74
|
</ThemedText>
|
|
@@ -24,6 +24,7 @@ import {
|
|
|
24
24
|
import { JamReactionMenu } from './JamReactionMenu';
|
|
25
25
|
import { JamToolbarButton, toneIconClass } from './JamToolbarButton';
|
|
26
26
|
import { LeaveCloseButton } from './LeaveCloseButton';
|
|
27
|
+
import { useThemeOpacity } from '../../theme/useThemeOpacity';
|
|
27
28
|
|
|
28
29
|
export interface JamFooterProps {
|
|
29
30
|
chatOpen: boolean;
|
|
@@ -171,6 +172,7 @@ export const JamFooter = ({
|
|
|
171
172
|
onToggleSpeaker,
|
|
172
173
|
}: JamFooterProps) => {
|
|
173
174
|
const { t } = useTranslation();
|
|
175
|
+
const { background } = useThemeOpacity();
|
|
174
176
|
const {
|
|
175
177
|
isModerator,
|
|
176
178
|
isRecording,
|
|
@@ -187,7 +189,10 @@ export const JamFooter = ({
|
|
|
187
189
|
const reactionTone = reactionMenuOpen ? 'active' : 'default';
|
|
188
190
|
|
|
189
191
|
return (
|
|
190
|
-
<View
|
|
192
|
+
<View
|
|
193
|
+
style={background('background', 0.75)}
|
|
194
|
+
className="relative w-full flex-row items-center justify-between gap-x-2 px-2 py-3"
|
|
195
|
+
>
|
|
191
196
|
{reactionMenuOpen ? (
|
|
192
197
|
<View className="absolute bottom-20 left-[5%] right-[5%] z-50 rounded-md p-2">
|
|
193
198
|
<JamReactionMenu
|
|
@@ -9,9 +9,11 @@ import { Input } from '../ui/input';
|
|
|
9
9
|
import { Label } from '../ui/label';
|
|
10
10
|
import { ThemedText } from '../ui/themed-text';
|
|
11
11
|
import { BASE_URL } from '../../lib/constants';
|
|
12
|
+
import { useThemeOpacity } from '../../theme/useThemeOpacity';
|
|
12
13
|
|
|
13
14
|
export const JamGuestForm = () => {
|
|
14
15
|
const { t } = useTranslation();
|
|
16
|
+
const { border } = useThemeOpacity();
|
|
15
17
|
const serverInfo = useServerInfo();
|
|
16
18
|
const { jamPost, jamEvent } = useJamContext();
|
|
17
19
|
const { openpeepsApi } = useOpenpeeps();
|
|
@@ -94,7 +96,10 @@ export const JamGuestForm = () => {
|
|
|
94
96
|
</ThemedText>
|
|
95
97
|
|
|
96
98
|
{error ? (
|
|
97
|
-
<ThemedText
|
|
99
|
+
<ThemedText
|
|
100
|
+
style={border('destructive', 0.4)}
|
|
101
|
+
className="rounded-md border p-2 text-sm text-destructive"
|
|
102
|
+
>
|
|
98
103
|
{error}
|
|
99
104
|
</ThemedText>
|
|
100
105
|
) : null}
|
|
@@ -4,6 +4,7 @@ import { useTranslation } from 'react-i18next';
|
|
|
4
4
|
import { MessageSquareIcon } from '../icons/index';
|
|
5
5
|
import { cn } from '../../lib/utils';
|
|
6
6
|
import { JamChatDrawer } from './JamChatDrawer';
|
|
7
|
+
import { useThemeOpacity } from '../../theme/useThemeOpacity';
|
|
7
8
|
|
|
8
9
|
export interface JamObserverShellProps {
|
|
9
10
|
children: ReactNode;
|
|
@@ -12,6 +13,7 @@ export interface JamObserverShellProps {
|
|
|
12
13
|
/** Observer layout wrapper with read-only persisted chat drawer. */
|
|
13
14
|
export const JamObserverShell = ({ children }: JamObserverShellProps) => {
|
|
14
15
|
const { t } = useTranslation();
|
|
16
|
+
const { background } = useThemeOpacity();
|
|
15
17
|
const [chatOpen, setChatOpen] = useState(false);
|
|
16
18
|
|
|
17
19
|
return (
|
|
@@ -22,9 +24,10 @@ export const JamObserverShell = ({ children }: JamObserverShellProps) => {
|
|
|
22
24
|
accessibilityLabel={t('jams.drawer.chatTitle')}
|
|
23
25
|
accessibilityRole="button"
|
|
24
26
|
onPress={() => setChatOpen((open) => !open)}
|
|
27
|
+
style={chatOpen ? background('primary', 0.15) : undefined}
|
|
25
28
|
className={cn(
|
|
26
29
|
'size-10 items-center justify-center rounded-full',
|
|
27
|
-
chatOpen
|
|
30
|
+
!chatOpen && 'bg-card'
|
|
28
31
|
)}
|
|
29
32
|
>
|
|
30
33
|
<MessageSquareIcon
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Regression test for the "poor connection" banner rendering as raw,
|
|
3
|
+
* transparent text over the jam video grid (issue #1814).
|
|
4
|
+
*
|
|
5
|
+
* Root cause: the banner background was the NativeWind class `bg-accent/90`.
|
|
6
|
+
* NativeWind v4 cannot apply a `/N` opacity modifier to a CSS-variable color
|
|
7
|
+
* (`--accent`), so the class produced *no* background at all. The fix applies
|
|
8
|
+
* the background through `useThemeOpacity`, which builds an inline rgba from
|
|
9
|
+
* the real theme color.
|
|
10
|
+
*
|
|
11
|
+
* Only the React Native surface (and livekit/i18n) is stubbed. The theme hook
|
|
12
|
+
* and the color math (`theme/useThemeOpacity` -> `theme/color`) run as real
|
|
13
|
+
* code, fed by the real `DEFAULT_COLORS` through a mocked
|
|
14
|
+
* `useOpenPeepsTheme`, so a regression in `hexWithOpacity` or in the accent
|
|
15
|
+
* hex values would be caught here. The expected rgba strings are pinned
|
|
16
|
+
* literals, which also pins the 6-digit-hex format the helpers require.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
const React = require('react');
|
|
20
|
+
const ReactTestRenderer = require('react-test-renderer');
|
|
21
|
+
|
|
22
|
+
const { mapColors } = require('../../theme/defaults');
|
|
23
|
+
|
|
24
|
+
const mockViewProps: Array<{ style?: unknown; className?: string }> = [];
|
|
25
|
+
let mockQuality = 1; // livekit-client ConnectionQuality.Good
|
|
26
|
+
let mockIsDark = false;
|
|
27
|
+
|
|
28
|
+
jest.mock('react-native', () => {
|
|
29
|
+
const View = (props: {
|
|
30
|
+
style?: unknown;
|
|
31
|
+
className?: string;
|
|
32
|
+
children?: unknown;
|
|
33
|
+
}) => {
|
|
34
|
+
mockViewProps.push({ style: props.style, className: props.className });
|
|
35
|
+
return React.createElement('View', null, props.children);
|
|
36
|
+
};
|
|
37
|
+
const Text = (props: { children?: unknown }) =>
|
|
38
|
+
React.createElement('Text', null, props.children);
|
|
39
|
+
const Pressable = (props: { children?: unknown }) =>
|
|
40
|
+
React.createElement('Pressable', null, props.children);
|
|
41
|
+
return { View, Text, Pressable };
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
jest.mock('@livekit/react-native', () => ({
|
|
45
|
+
useLocalParticipant: () => ({ localParticipant: {} }),
|
|
46
|
+
}));
|
|
47
|
+
|
|
48
|
+
jest.mock('livekit-client', () => ({
|
|
49
|
+
ConnectionQuality: { Good: 1, Poor: 2, Lost: 3 },
|
|
50
|
+
}));
|
|
51
|
+
|
|
52
|
+
jest.mock('react-i18next', () => ({
|
|
53
|
+
useTranslation: () => ({
|
|
54
|
+
t: (key: string, opts?: Record<string, unknown>) =>
|
|
55
|
+
key.replace(/\{\{(\w+)\}\}/g, (_m: string, n: string) =>
|
|
56
|
+
String(opts?.[n] ?? '')
|
|
57
|
+
),
|
|
58
|
+
}),
|
|
59
|
+
}));
|
|
60
|
+
|
|
61
|
+
jest.mock('@openpeepshq/react', () => ({
|
|
62
|
+
useJamRecordingState: () => ({ isRecording: false }),
|
|
63
|
+
useJamRecordingElapsed: () => null,
|
|
64
|
+
}));
|
|
65
|
+
|
|
66
|
+
jest.mock('../icons/index', () => ({
|
|
67
|
+
CircleIcon: () => React.createElement('CircleIcon'),
|
|
68
|
+
XIcon: () => React.createElement('XIcon'),
|
|
69
|
+
}));
|
|
70
|
+
|
|
71
|
+
jest.mock('../ui/themed-text', () => ({
|
|
72
|
+
ThemedText: (props: { children?: unknown; className?: string }) =>
|
|
73
|
+
React.createElement(
|
|
74
|
+
'ThemedText',
|
|
75
|
+
{ className: props.className },
|
|
76
|
+
props.children
|
|
77
|
+
),
|
|
78
|
+
}));
|
|
79
|
+
|
|
80
|
+
// Real theme defaults (nativewind-free), so the assertions below are checked
|
|
81
|
+
// against the hex values the app actually ships.
|
|
82
|
+
jest.mock('../../theme/OpenPeepsThemeProvider', () => ({
|
|
83
|
+
useOpenPeepsTheme: () => ({
|
|
84
|
+
isDark: mockIsDark,
|
|
85
|
+
colors: mapColors(mockIsDark),
|
|
86
|
+
buttonRadius: '9999px',
|
|
87
|
+
refresh: () => {},
|
|
88
|
+
}),
|
|
89
|
+
}));
|
|
90
|
+
|
|
91
|
+
jest.mock('./useParticipantConnection', () => ({
|
|
92
|
+
useConnectionQuality: () => mockQuality,
|
|
93
|
+
}));
|
|
94
|
+
|
|
95
|
+
const { JamNetworkQuality } = require('./JamRoomIndicators');
|
|
96
|
+
|
|
97
|
+
const renderQuality = (quality: number, isDark: boolean) => {
|
|
98
|
+
mockViewProps.length = 0;
|
|
99
|
+
mockQuality = quality;
|
|
100
|
+
mockIsDark = isDark;
|
|
101
|
+
let tree!: ReactTestRenderer.ReactTestRenderer;
|
|
102
|
+
ReactTestRenderer.act(() => {
|
|
103
|
+
tree = ReactTestRenderer.create(React.createElement(JamNetworkQuality));
|
|
104
|
+
});
|
|
105
|
+
return { tree, banner: mockViewProps[mockViewProps.length - 1] };
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
describe('JamNetworkQuality banner background', () => {
|
|
109
|
+
it('renders an opaque inline background (light theme) when the connection is poor', () => {
|
|
110
|
+
const { banner } = renderQuality(2, false); // ConnectionQuality.Poor
|
|
111
|
+
|
|
112
|
+
expect(banner).toBeDefined();
|
|
113
|
+
// The broken `bg-accent/90` class must be gone...
|
|
114
|
+
expect(banner!.className).not.toContain('bg-accent/90');
|
|
115
|
+
// ...and the background must be a real inline rgba value derived from the
|
|
116
|
+
// light accent color (#f4f4f5) at 0.9 opacity — not absent/transparent.
|
|
117
|
+
expect(banner!.style).toEqual({
|
|
118
|
+
backgroundColor: 'rgba(244, 244, 245, 0.9)',
|
|
119
|
+
});
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
it('renders the dark accent when the dark theme is active', () => {
|
|
123
|
+
const { banner } = renderQuality(2, true);
|
|
124
|
+
expect(banner).toBeDefined();
|
|
125
|
+
// Dark accent is #28282e (distinct from the light accent above).
|
|
126
|
+
expect((banner!.style as { backgroundColor: string }).backgroundColor).toBe(
|
|
127
|
+
'rgba(40, 40, 46, 0.9)'
|
|
128
|
+
);
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
it('also renders the opaque background when the connection is lost', () => {
|
|
132
|
+
const { banner } = renderQuality(3, false); // ConnectionQuality.Lost
|
|
133
|
+
expect(banner).toBeDefined();
|
|
134
|
+
expect((banner!.style as { backgroundColor: string }).backgroundColor).toBe(
|
|
135
|
+
'rgba(244, 244, 245, 0.9)'
|
|
136
|
+
);
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
it('renders nothing when the connection is good', () => {
|
|
140
|
+
renderQuality(1, false); // ConnectionQuality.Good
|
|
141
|
+
expect(mockViewProps).toHaveLength(0);
|
|
142
|
+
});
|
|
143
|
+
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { useState } from 'react';
|
|
2
|
-
import { Pressable, View } from 'react-native';
|
|
2
|
+
import { Pressable, Text, View } from 'react-native';
|
|
3
3
|
import { useLocalParticipant } from '@livekit/react-native';
|
|
4
4
|
import { ConnectionQuality } from 'livekit-client';
|
|
5
5
|
import { useTranslation } from 'react-i18next';
|
|
@@ -9,14 +9,13 @@ import {
|
|
|
9
9
|
} from '@openpeepshq/react';
|
|
10
10
|
import { CircleIcon, XIcon } from '../icons/index';
|
|
11
11
|
import { ThemedText } from '../ui/themed-text';
|
|
12
|
-
import {
|
|
13
|
-
import { hexWithOpacity } from '../../theme/utils';
|
|
12
|
+
import { useThemeOpacity } from '../../theme/useThemeOpacity';
|
|
14
13
|
import { useConnectionQuality } from './useParticipantConnection';
|
|
15
14
|
|
|
16
15
|
/** Red "recording" pill shown to every participant while egress is active. */
|
|
17
16
|
export const JamRecordingIndicator = () => {
|
|
18
17
|
const { t } = useTranslation();
|
|
19
|
-
const {
|
|
18
|
+
const { background } = useThemeOpacity();
|
|
20
19
|
const { isRecording } = useJamRecordingState();
|
|
21
20
|
const elapsed = useJamRecordingElapsed();
|
|
22
21
|
|
|
@@ -27,7 +26,7 @@ export const JamRecordingIndicator = () => {
|
|
|
27
26
|
return (
|
|
28
27
|
<View
|
|
29
28
|
pointerEvents="none"
|
|
30
|
-
style={
|
|
29
|
+
style={background('destructive', 0.9)}
|
|
31
30
|
className="absolute left-4 top-4 z-50 flex-row items-center gap-2 rounded-full px-3 py-1"
|
|
32
31
|
>
|
|
33
32
|
<CircleIcon
|
|
@@ -45,6 +44,7 @@ export const JamRecordingIndicator = () => {
|
|
|
45
44
|
/** Dismissable banner shown when the local connection quality degrades. */
|
|
46
45
|
export const JamNetworkQuality = () => {
|
|
47
46
|
const { t } = useTranslation();
|
|
47
|
+
const { background } = useThemeOpacity();
|
|
48
48
|
const { localParticipant } = useLocalParticipant();
|
|
49
49
|
const quality = useConnectionQuality(localParticipant);
|
|
50
50
|
const [dismissed, setDismissed] = useState(false);
|
|
@@ -55,11 +55,18 @@ export const JamNetworkQuality = () => {
|
|
|
55
55
|
if (!poor || dismissed) return null;
|
|
56
56
|
|
|
57
57
|
return (
|
|
58
|
-
|
|
58
|
+
// NativeWind v4 can't apply `/N` opacity to CSS-variable colors (e.g.
|
|
59
|
+
// `bg-accent/90`), so the banner background uses an inline rgba style.
|
|
60
|
+
<View
|
|
61
|
+
style={background('accent', 0.9)}
|
|
62
|
+
className="absolute left-4 right-4 top-4 z-50 flex-row items-center gap-3 rounded-lg px-4 py-2"
|
|
63
|
+
>
|
|
59
64
|
<ThemedText className="flex-1 text-sm text-accent-foreground">
|
|
60
|
-
|
|
65
|
+
{/* Raw `Text` (not `ThemedText`) for the bold status label: nesting
|
|
66
|
+
two themed texts would re-apply the base `text-base` defaults. */}
|
|
67
|
+
<Text className="font-medium">
|
|
61
68
|
{t('jams.network.connectionStatus')}
|
|
62
|
-
</
|
|
69
|
+
</Text>{' '}
|
|
63
70
|
{t('jams.network.connectionDetail', { quality })}
|
|
64
71
|
</ThemedText>
|
|
65
72
|
<Pressable
|
|
@@ -7,12 +7,15 @@ import {
|
|
|
7
7
|
DropdownMenuTrigger,
|
|
8
8
|
} from '../ui/dropdown-menu';
|
|
9
9
|
import { cn } from '../../lib/utils';
|
|
10
|
+
import { useThemeOpacity } from '../../theme/useThemeOpacity';
|
|
10
11
|
|
|
11
12
|
export type JamToolbarTone = 'default' | 'active' | 'danger';
|
|
12
13
|
|
|
13
14
|
const toneClasses: Record<JamToolbarTone, string> = {
|
|
14
15
|
default: 'bg-card',
|
|
15
|
-
active
|
|
16
|
+
// `active` uses an inline primary tint (see `toneStyle`); NativeWind can't
|
|
17
|
+
// apply `/N` opacity to CSS-variable colors.
|
|
18
|
+
active: '',
|
|
16
19
|
danger: 'bg-destructive',
|
|
17
20
|
};
|
|
18
21
|
|
|
@@ -46,12 +49,15 @@ export const JamToolbarButton = ({
|
|
|
46
49
|
menuChildren,
|
|
47
50
|
menuTitle,
|
|
48
51
|
}: JamToolbarButtonProps) => {
|
|
52
|
+
const { background } = useThemeOpacity();
|
|
53
|
+
const toneStyle = tone === 'active' ? background('primary', 0.15) : undefined;
|
|
49
54
|
const button = (
|
|
50
55
|
<Pressable
|
|
51
56
|
accessibilityLabel={title}
|
|
52
57
|
accessibilityRole="button"
|
|
53
58
|
disabled={disabled}
|
|
54
59
|
onPress={action}
|
|
60
|
+
style={toneStyle}
|
|
55
61
|
className={cn(
|
|
56
62
|
'relative size-10 shrink-0 items-center justify-center rounded-full p-2',
|
|
57
63
|
toneClasses[tone],
|
|
@@ -14,6 +14,7 @@ import {
|
|
|
14
14
|
type EventsCalendarQuery,
|
|
15
15
|
} from '@openpeepshq/react';
|
|
16
16
|
import { ChevronLeftIcon, ChevronRightIcon } from '../../../icons/index';
|
|
17
|
+
import { useThemeOpacity } from '../../../../theme/useThemeOpacity';
|
|
17
18
|
import { MainStackParamList } from '../../../navigation/types/index';
|
|
18
19
|
import { ThemedText } from '../../../ui/themed-text';
|
|
19
20
|
import { cn } from '../../../../lib/utils';
|
|
@@ -28,6 +29,7 @@ const postKey = (post: PublicPost) =>
|
|
|
28
29
|
|
|
29
30
|
export const EventsCalendar = ({ query, agenda }: EventsCalendarProps) => {
|
|
30
31
|
const { t } = useTranslation();
|
|
32
|
+
const { background } = useThemeOpacity();
|
|
31
33
|
const navigation =
|
|
32
34
|
useNavigation<NativeStackNavigationProp<MainStackParamList>>();
|
|
33
35
|
const {
|
|
@@ -113,10 +115,12 @@ export const EventsCalendar = ({ query, agenda }: EventsCalendarProps) => {
|
|
|
113
115
|
key={cell.key}
|
|
114
116
|
accessibilityState={{ selected: isSelected }}
|
|
115
117
|
onPress={() => setSelectedKey(cell.key)}
|
|
116
|
-
style={{
|
|
118
|
+
style={{
|
|
119
|
+
width: `${100 / 7}%`,
|
|
120
|
+
...(isSelected ? background('primary', 0.1) : {}),
|
|
121
|
+
}}
|
|
117
122
|
className={cn(
|
|
118
123
|
'bg-background min-h-14 p-1 border-[0.5px] border-border items-center',
|
|
119
|
-
isSelected && 'bg-primary/10',
|
|
120
124
|
!cell.inMonth && 'opacity-60'
|
|
121
125
|
)}
|
|
122
126
|
>
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { View } from 'react-native';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { cn } from '../../../lib/utils';
|
|
4
|
+
import { useThemeOpacity } from '../../../theme/useThemeOpacity';
|
|
4
5
|
|
|
5
6
|
interface UnreadPostIndicatorProps {
|
|
6
7
|
show: boolean;
|
|
@@ -19,16 +20,15 @@ export const UnreadPostIndicator = ({
|
|
|
19
20
|
className,
|
|
20
21
|
variant = 'dot',
|
|
21
22
|
}: UnreadPostIndicatorProps) => {
|
|
23
|
+
const { background } = useThemeOpacity();
|
|
22
24
|
if (!show) return null;
|
|
23
25
|
if (variant === 'corner') return null;
|
|
24
26
|
|
|
25
27
|
return (
|
|
26
28
|
<View
|
|
27
29
|
pointerEvents="none"
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
className
|
|
31
|
-
)}
|
|
30
|
+
style={background('muted-foreground', 0.45)}
|
|
31
|
+
className={cn('absolute left-1.5 top-6 size-1.5 rounded-full', className)}
|
|
32
32
|
/>
|
|
33
33
|
);
|
|
34
34
|
};
|
|
@@ -8,6 +8,7 @@ import { useTranslation } from 'react-i18next';
|
|
|
8
8
|
import { MediaAttachmentData } from '@openpeepshq/common';
|
|
9
9
|
import { isImageAttachment } from '../../../lib/attachmentHelpers';
|
|
10
10
|
import { AttachmentCard, attachmentId } from './AttachmentCard';
|
|
11
|
+
import { useThemeOpacity } from '../../../theme/useThemeOpacity';
|
|
11
12
|
|
|
12
13
|
interface MediaPreviewProps {
|
|
13
14
|
attachments: MediaAttachmentData[];
|
|
@@ -22,6 +23,7 @@ export const ComposeAttachments: React.FC<MediaPreviewProps> = ({
|
|
|
22
23
|
updateAttachment,
|
|
23
24
|
}) => {
|
|
24
25
|
const { t } = useTranslation();
|
|
26
|
+
const { background } = useThemeOpacity();
|
|
25
27
|
const [currentImageIndex, setCurrentImageIndex] = useState(0);
|
|
26
28
|
|
|
27
29
|
const altModalRef = useRef<BottomSheetModal>(null);
|
|
@@ -88,7 +90,8 @@ export const ComposeAttachments: React.FC<MediaPreviewProps> = ({
|
|
|
88
90
|
accessibilityLabel={t('common.labels.altText', {
|
|
89
91
|
defaultValue: 'Alt text',
|
|
90
92
|
})}
|
|
91
|
-
className="min-h-10 px-3 rounded-full
|
|
93
|
+
className="min-h-10 px-3 rounded-full border border-border items-center justify-center"
|
|
94
|
+
style={background('background', 0.9)}
|
|
92
95
|
>
|
|
93
96
|
<ThemedText className="text-xs font-semibold">ALT</ThemedText>
|
|
94
97
|
</TouchableOpacity>
|
|
@@ -99,7 +102,8 @@ export const ComposeAttachments: React.FC<MediaPreviewProps> = ({
|
|
|
99
102
|
accessibilityLabel={t('posts.attachments.deleteTitle', {
|
|
100
103
|
defaultValue: 'Delete attachment',
|
|
101
104
|
})}
|
|
102
|
-
className="w-10 h-10 rounded-full
|
|
105
|
+
className="w-10 h-10 rounded-full border border-border items-center justify-center"
|
|
106
|
+
style={background('background', 0.9)}
|
|
103
107
|
>
|
|
104
108
|
<XIcon size={18} className="text-foreground" />
|
|
105
109
|
</TouchableOpacity>
|
|
@@ -175,9 +175,9 @@ export const EventForm = ({
|
|
|
175
175
|
<SectionTitle>{t('events.form.dateAndTimeTitle')}</SectionTitle>
|
|
176
176
|
|
|
177
177
|
<PickerField
|
|
178
|
-
label={t('events.
|
|
178
|
+
label={t('events.startDate')}
|
|
179
179
|
value={formatDate(event.start, eventTimeZone)}
|
|
180
|
-
placeholder={t('events.
|
|
180
|
+
placeholder={t('events.startDate')}
|
|
181
181
|
icon={<CalendarIcon className="text-muted-foreground" size={18} />}
|
|
182
182
|
onPress={() => bottomSheetPresent(startSheetRef)}
|
|
183
183
|
/>
|
|
@@ -193,9 +193,9 @@ export const EventForm = ({
|
|
|
193
193
|
{showEndDate ? (
|
|
194
194
|
<>
|
|
195
195
|
<PickerField
|
|
196
|
-
label={t('events.
|
|
196
|
+
label={t('events.endDate')}
|
|
197
197
|
value={formatDate(event.end, eventTimeZone)}
|
|
198
|
-
placeholder={t('events.
|
|
198
|
+
placeholder={t('events.endDate')}
|
|
199
199
|
icon={
|
|
200
200
|
<CalendarIcon className="text-muted-foreground" size={18} />
|
|
201
201
|
}
|
|
@@ -224,6 +224,7 @@ jest.mock('../../../icons/index', () => ({
|
|
|
224
224
|
PencilIcon: () => null,
|
|
225
225
|
FlagIcon: () => null,
|
|
226
226
|
}));
|
|
227
|
+
|
|
227
228
|
// The components barrel (EventRsvpButton, ReplyBox, ShareMenu, useNewPostModal, ...)
|
|
228
229
|
jest.mock('../../index', () => ({
|
|
229
230
|
EventMenu: () => null,
|
|
@@ -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';
|
|
@@ -88,6 +89,7 @@ export interface FullEventProps {
|
|
|
88
89
|
|
|
89
90
|
export const FullEvent: React.FC<FullEventProps> = ({ post, occurrence }) => {
|
|
90
91
|
const { t } = useTranslation();
|
|
92
|
+
const { border } = useThemeOpacity();
|
|
91
93
|
const { currentProfile, openpeepsApi, client } = useOpenpeeps();
|
|
92
94
|
const navigation =
|
|
93
95
|
useNavigation<NativeStackNavigationProp<MainStackParamList>>();
|
|
@@ -280,7 +282,10 @@ export const FullEvent: React.FC<FullEventProps> = ({ post, occurrence }) => {
|
|
|
280
282
|
</View>
|
|
281
283
|
{times.start && (
|
|
282
284
|
<View className="mt-8 flex-row gap-x-4">
|
|
283
|
-
<View
|
|
285
|
+
<View
|
|
286
|
+
style={border('foreground', 0.2)}
|
|
287
|
+
className="border-[0.5px] rounded-md px-3 py-1"
|
|
288
|
+
>
|
|
284
289
|
<ThemedText className="text-center">
|
|
285
290
|
{new Date(times.start).toLocaleString('en-US', {
|
|
286
291
|
month: 'short',
|
|
@@ -320,7 +325,10 @@ export const FullEvent: React.FC<FullEventProps> = ({ post, occurrence }) => {
|
|
|
320
325
|
</View>
|
|
321
326
|
)}
|
|
322
327
|
<View className="mt-8 flex-row gap-x-4">
|
|
323
|
-
<View
|
|
328
|
+
<View
|
|
329
|
+
style={border('foreground', 0.2)}
|
|
330
|
+
className="border-[0.5px] flex items-center justify-center rounded-md px-4 py-1"
|
|
331
|
+
>
|
|
324
332
|
{event?.physicalLocation ? (
|
|
325
333
|
<MapPinIcon className="text-muted-foreground my-3" size={18} />
|
|
326
334
|
) : event?.jam ? (
|
|
@@ -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-
|
|
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`
|
|
@@ -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
|
-
|
|
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
|
|
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}
|
|
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>
|
package/src/pages/Welcome.tsx
CHANGED
|
@@ -26,6 +26,7 @@ import Toast from 'react-native-toast-message';
|
|
|
26
26
|
import { useTranslation } from 'react-i18next';
|
|
27
27
|
|
|
28
28
|
import { OpenpeepsMarkdown } from '../components/markdown/index';
|
|
29
|
+
import { useThemeOpacity } from '../theme/useThemeOpacity';
|
|
29
30
|
type AccountSetupChecklistItem = {
|
|
30
31
|
Icon: LucideIcon;
|
|
31
32
|
key: string;
|
|
@@ -158,6 +159,7 @@ export const ChecklistItem = ({
|
|
|
158
159
|
}: AccountSetupChecklistItem) => {
|
|
159
160
|
const navigation =
|
|
160
161
|
useNavigation<NativeStackNavigationProp<MainStackParamList>>();
|
|
162
|
+
const { background } = useThemeOpacity();
|
|
161
163
|
|
|
162
164
|
/* eslint-disable @typescript-eslint/no-shadow */
|
|
163
165
|
const { currentProfile } = useOpenpeeps();
|
|
@@ -188,7 +190,8 @@ export const ChecklistItem = ({
|
|
|
188
190
|
});
|
|
189
191
|
}
|
|
190
192
|
}}
|
|
191
|
-
|
|
193
|
+
style={background('secondary', 0.1)}
|
|
194
|
+
className="flex px-1 flex-row justify-between items-center w-full py-4 rounded-md mb-2"
|
|
192
195
|
>
|
|
193
196
|
<ThemedView className=" flex p-4 items-center justify-center rounded-full bg-background">
|
|
194
197
|
<Icon size={20} className="text-foreground p-3" />
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import React, { createContext, useContext, useEffect, useMemo } from 'react';
|
|
2
2
|
import { View, useColorScheme as useRNColorScheme } from 'react-native';
|
|
3
|
-
import { colorScheme } from 'nativewind';
|
|
4
3
|
import { useOpenpeeps } from '@openpeepshq/react';
|
|
5
4
|
import { OpenPeepsTheme } from './types';
|
|
6
5
|
import { defaultTheme } from './defaults';
|
|
@@ -62,11 +61,13 @@ export const OpenPeepsThemeProvider = ({
|
|
|
62
61
|
);
|
|
63
62
|
|
|
64
63
|
useEffect(() => {
|
|
64
|
+
// Lazy-import nativewind so the provider module does not crash Jest (node
|
|
65
|
+
// env has no Appearance module). The actual set() call runs only when the
|
|
66
|
+
// component mounts in a real runtime.
|
|
67
|
+
const { colorScheme } = require('nativewind');
|
|
65
68
|
// nativewind maps colorScheme.set('system') to Appearance.setColorScheme(null),
|
|
66
|
-
// which crashes on Android RN 0.85
|
|
67
|
-
//
|
|
68
|
-
// 'system' preference (it derives from the live systemColorScheme above),
|
|
69
|
-
// so always drive nativewind with an explicit value.
|
|
69
|
+
// which crashes on Android RN 0.85. theme.isDark already resolves the active
|
|
70
|
+
// scheme, so always drive nativewind with an explicit value.
|
|
70
71
|
colorScheme.set(theme.isDark ? 'dark' : 'light');
|
|
71
72
|
}, [theme.isDark]);
|
|
72
73
|
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure color math shared by the app and its regression tests.
|
|
3
|
+
*
|
|
4
|
+
* Kept `nativewind`-free on purpose: `theme/utils.ts` imports `vars` from
|
|
5
|
+
* `nativewind`, which cannot load in the node jest environment. Splitting the
|
|
6
|
+
* color helpers into this dependency-free module lets the tests import and
|
|
7
|
+
* exercise the *real* `hexWithOpacity` instead of a hand-rolled copy (a copy
|
|
8
|
+
* would miss e.g. the `##` -> `#` normalization below).
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/** Convert a hex color (#rrggbb) to an "R G B" channel string. */
|
|
12
|
+
export const hexToRgbChannels = (hex: string): string => {
|
|
13
|
+
const sanitized = hex.replaceAll('##', '#');
|
|
14
|
+
const m = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(sanitized);
|
|
15
|
+
if (!m) return hex;
|
|
16
|
+
const [, r, g, b] = m;
|
|
17
|
+
if (r === undefined || g === undefined || b === undefined) return hex;
|
|
18
|
+
return `${parseInt(r, 16)} ${parseInt(g, 16)} ${parseInt(b, 16)}`;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
/** Convert a hex color to an `rgba(r, g, b, a)` string. */
|
|
22
|
+
export const hexWithOpacity = (hex: string, opacity: number): string => {
|
|
23
|
+
const sanitized = hex.replaceAll('##', '#');
|
|
24
|
+
const m = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(sanitized);
|
|
25
|
+
if (!m) return hex;
|
|
26
|
+
const [, r, g, b] = m;
|
|
27
|
+
if (r === undefined || g === undefined || b === undefined) return hex;
|
|
28
|
+
return `rgba(${parseInt(r, 16)}, ${parseInt(g, 16)}, ${parseInt(b, 16)}, ${opacity})`;
|
|
29
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { useOpenPeepsTheme } from './OpenPeepsThemeProvider';
|
|
2
|
+
import { hexWithOpacity } from './color';
|
|
3
|
+
import type { ColorName } from './types';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Inline-style opacity helper for theme colors.
|
|
7
|
+
*
|
|
8
|
+
* NativeWind v4 cannot apply a `/N` opacity modifier to a CSS-variable color
|
|
9
|
+
* (`--primary` and friends), so a class like `bg-primary/10` resolves to no
|
|
10
|
+
* color at all. Every such call site must build the rgba value inline from
|
|
11
|
+
* the hex theme color instead — this hook is the single place that does it,
|
|
12
|
+
* so the workaround (and any future fix) lives in one spot.
|
|
13
|
+
*/
|
|
14
|
+
export const useThemeOpacity = () => {
|
|
15
|
+
const { colors } = useOpenPeepsTheme();
|
|
16
|
+
return {
|
|
17
|
+
/** `background` style for a token at the given opacity (0..1). */
|
|
18
|
+
background: (name: ColorName, opacity: number) => ({
|
|
19
|
+
backgroundColor: hexWithOpacity(colors[name], opacity),
|
|
20
|
+
}),
|
|
21
|
+
/** `borderColor` style for a token at the given opacity (0..1). */
|
|
22
|
+
border: (name: ColorName, opacity: number) => ({
|
|
23
|
+
borderColor: hexWithOpacity(colors[name], opacity),
|
|
24
|
+
}),
|
|
25
|
+
/** `color` style for a token at the given opacity (0..1). */
|
|
26
|
+
text: (name: ColorName, opacity: number) => ({
|
|
27
|
+
color: hexWithOpacity(colors[name], opacity),
|
|
28
|
+
}),
|
|
29
|
+
};
|
|
30
|
+
};
|
package/src/theme/utils.ts
CHANGED
|
@@ -1,34 +1,23 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { hexToRgbChannels, hexWithOpacity } from './color';
|
|
2
2
|
import { mapColors } from './defaults';
|
|
3
3
|
import type { OpenPeepsTheme } from './types';
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
export const hexToRgbChannels = (hex: string): string => {
|
|
9
|
-
const sanitized = hex.replaceAll('##', '#');
|
|
10
|
-
const m = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(sanitized);
|
|
11
|
-
if (!m) return hex;
|
|
12
|
-
const [, r, g, b] = m;
|
|
13
|
-
if (r === undefined || g === undefined || b === undefined) return hex;
|
|
14
|
-
return `${parseInt(r, 16)} ${parseInt(g, 16)} ${parseInt(b, 16)}`;
|
|
15
|
-
};
|
|
5
|
+
// The pure color math lives in `./color` (nativewind-free) so tests can
|
|
6
|
+
// import the real implementation. Re-exported here for existing importers.
|
|
7
|
+
export { hexToRgbChannels, hexWithOpacity };
|
|
16
8
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
if (r === undefined || g === undefined || b === undefined) return hex;
|
|
24
|
-
return `rgba(${parseInt(r, 16)}, ${parseInt(g, 16)}, ${parseInt(b, 16)}, ${opacity})`;
|
|
25
|
-
};
|
|
9
|
+
// `vars` is required lazily: nativewind's import chain crashes at import
|
|
10
|
+
// time in a plain node jest env (no Appearance module), and this module is
|
|
11
|
+
// reached through the provider's import graph. getThemeVars only runs in a
|
|
12
|
+
// real runtime where the provider renders.
|
|
13
|
+
const getVars = (): (typeof import('nativewind'))['vars'] =>
|
|
14
|
+
require('nativewind').vars;
|
|
26
15
|
|
|
27
16
|
export const getThemeVars = (
|
|
28
17
|
colors: OpenPeepsTheme['colors'],
|
|
29
18
|
radii?: { buttonRadius?: string; radius?: string }
|
|
30
19
|
) =>
|
|
31
|
-
|
|
20
|
+
getVars()({
|
|
32
21
|
...Object.fromEntries(
|
|
33
22
|
Object.entries(colors).map(([key, value]) => [`--${key}`, value])
|
|
34
23
|
),
|