@openpeepshq/rn-components 0.14.1 → 0.15.0
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 +3 -3
- package/src/components/buttonOverflow.test.tsx +8 -0
- package/src/components/conversations/ConversationParticipantsModal.tsx +1 -6
- package/src/components/jams/JamChatDrawer.test.tsx +263 -0
- package/src/components/jams/JamChatDrawer.tsx +117 -52
- package/src/components/jams/JamConference.tsx +5 -0
- package/src/components/jams/JamParticipantConference.tsx +7 -4
- package/src/components/jams/JamPeopleDrawer.test.tsx +216 -0
- package/src/components/jams/JamPeopleDrawer.tsx +32 -2
- package/src/components/jams/JamRoomIndicators.test.tsx +190 -38
- package/src/components/jams/JamRoomIndicators.tsx +62 -20
- package/src/components/jams/useTrackSubscriptionBump.test.ts +294 -0
- package/src/components/jams/useTrackSubscriptionBump.ts +44 -0
- package/src/components/post/feed/events/EventsCalendar.test.tsx +33 -18
- package/src/components/post/pieces/ShareMenu.test.tsx +217 -0
- package/src/components/post/pieces/ShareMenu.tsx +107 -61
- package/src/components/post/post-form/VisibilitySheet.test.tsx +153 -0
- package/src/components/post/post-form/VisibilitySheet.tsx +6 -5
- package/src/components/profile/Avatar.test.tsx +147 -0
- package/src/components/profile/Avatar.tsx +26 -0
- package/src/components/profile/ProfileCard.test.tsx +165 -8
- package/src/components/profile/ProfileCard.tsx +63 -10
- package/src/components/profile/ProfileSelector.test.tsx +147 -5
- package/src/components/profile/ProfileSelector.tsx +64 -18
- package/src/pages/conversations/New.test.tsx +340 -0
- package/src/pages/conversations/New.tsx +35 -30
- package/src/pages/events/Index.tsx +4 -1
- package/src/pages/events/My.tsx +1 -1
- package/src/pages/groups/Show.tsx +1 -1
- package/src/theme/useThemeOpacity.test.ts +70 -0
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Regression tests for the ProfileAvatar SVG-derivation fix
|
|
3
|
+
* (issue #1666, round-2 plan step 2 / round-10 review S2).
|
|
4
|
+
*
|
|
5
|
+
* `svgCoverSrc` appends a web-only `#svgView(...)` cover fragment to the
|
|
6
|
+
* URI, so the SVG-vs-raster path must be decided from the *original*
|
|
7
|
+
* `profile.avatar` URL — never from the `svgCoverSrc` output — or an SVG
|
|
8
|
+
* avatar silently falls back to the raster `AvatarImage`, which RN `Image`
|
|
9
|
+
* cannot decode. The `isSvgUrl`/`svgCoverSrc` helpers are the real source
|
|
10
|
+
* (mapped through the repo's Jest source convention), so this suite fails
|
|
11
|
+
* if the path-selection moves to the fragment-appended URL or the deleted /
|
|
12
|
+
* no-avatar fallbacks regress.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
const React = require('react');
|
|
16
|
+
const ReactTestRenderer = require('react-test-renderer');
|
|
17
|
+
|
|
18
|
+
jest.mock('react-native', () => ({
|
|
19
|
+
View: (props: { children?: unknown; className?: string }) =>
|
|
20
|
+
React.createElement('View', { className: props.className }, props.children),
|
|
21
|
+
Text: (props: { children?: unknown; className?: string }) =>
|
|
22
|
+
React.createElement('Text', { className: props.className }, props.children),
|
|
23
|
+
}));
|
|
24
|
+
|
|
25
|
+
jest.mock('react-i18next', () => ({
|
|
26
|
+
useTranslation: () => ({ t: (key: string) => key }),
|
|
27
|
+
}));
|
|
28
|
+
|
|
29
|
+
jest.mock('@openpeepshq/common', () => ({
|
|
30
|
+
// Only the runtime helper is needed; `Profile` is a type-only import.
|
|
31
|
+
isDeletedProfile: (p: { deletedAt?: string | null }) => !!p?.deletedAt,
|
|
32
|
+
}));
|
|
33
|
+
|
|
34
|
+
jest.mock('@openpeepshq/react', () => ({
|
|
35
|
+
// Real source for the URL helpers — the regression is precisely about how
|
|
36
|
+
// they combine, so stubbing them would hide the very thing under test.
|
|
37
|
+
isSvgUrl: require('../../../../react/src/lib/svgCover').isSvgUrl,
|
|
38
|
+
svgCoverSrc: require('../../../../react/src/lib/svgCover').svgCoverSrc,
|
|
39
|
+
// Real source for the initials fallback (first + last name initial).
|
|
40
|
+
getInitials: require('../../../../react/src/lib/initialsAvatar').getInitials,
|
|
41
|
+
hueFromHandle: () => 180,
|
|
42
|
+
initialsBackground: () => 'rgb(20, 20, 20)',
|
|
43
|
+
}));
|
|
44
|
+
|
|
45
|
+
jest.mock('../../theme/OpenPeepsThemeProvider', () => ({
|
|
46
|
+
useOpenPeepsTheme: () => ({ isDark: false }),
|
|
47
|
+
}));
|
|
48
|
+
|
|
49
|
+
jest.mock('../ui/avatar', () => ({
|
|
50
|
+
Avatar: (props: { children?: unknown; className?: string }) =>
|
|
51
|
+
React.createElement(
|
|
52
|
+
'Avatar',
|
|
53
|
+
{ className: props.className },
|
|
54
|
+
props.children
|
|
55
|
+
),
|
|
56
|
+
AvatarFallback: () => null,
|
|
57
|
+
AvatarImage: (props: { source?: unknown; className?: string }) =>
|
|
58
|
+
React.createElement('AvatarImage', { source: props.source }),
|
|
59
|
+
}));
|
|
60
|
+
|
|
61
|
+
jest.mock('../ui/svg-image', () => ({
|
|
62
|
+
SvgImage: (props: { uri?: string; className?: string }) =>
|
|
63
|
+
React.createElement('SvgImage', {
|
|
64
|
+
uri: props.uri,
|
|
65
|
+
className: props.className,
|
|
66
|
+
}),
|
|
67
|
+
}));
|
|
68
|
+
|
|
69
|
+
jest.mock('../icons/index', () => ({
|
|
70
|
+
UserXIcon: (props: { className?: string }) =>
|
|
71
|
+
React.createElement('UserXIcon', { className: props.className }),
|
|
72
|
+
}));
|
|
73
|
+
|
|
74
|
+
jest.mock('../../lib/utils', () => ({
|
|
75
|
+
cn: (...parts: Array<string | undefined>) => parts.filter(Boolean).join(' '),
|
|
76
|
+
}));
|
|
77
|
+
|
|
78
|
+
import type { Profile } from '@openpeepshq/common';
|
|
79
|
+
import { ProfileAvatar } from './Avatar';
|
|
80
|
+
|
|
81
|
+
const baseProfile = {
|
|
82
|
+
id: 'p1',
|
|
83
|
+
handle: 'ada',
|
|
84
|
+
displayName: 'Ada Lovelace',
|
|
85
|
+
} as unknown as Profile;
|
|
86
|
+
|
|
87
|
+
const renderAvatar = (profile: Profile) => {
|
|
88
|
+
let tree: ReturnType<typeof ReactTestRenderer.create>;
|
|
89
|
+
ReactTestRenderer.act(() => {
|
|
90
|
+
tree = ReactTestRenderer.create(
|
|
91
|
+
React.createElement(ProfileAvatar, { profile, className: 'size-10' })
|
|
92
|
+
);
|
|
93
|
+
});
|
|
94
|
+
return tree;
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
describe('ProfileAvatar SVG path selection (issue #1666 round-2 plan step 2)', () => {
|
|
98
|
+
it('renders an SVG avatar via SvgImage with cover, not the raster AvatarImage', () => {
|
|
99
|
+
const tree = renderAvatar({
|
|
100
|
+
...baseProfile,
|
|
101
|
+
avatar: 'https://cdn.example/avatars/ada.svg',
|
|
102
|
+
});
|
|
103
|
+
const svg = tree.root.findByType('SvgImage');
|
|
104
|
+
// The URI is the cover-appended source (what web renders), while the
|
|
105
|
+
// path choice itself must not depend on that fragment.
|
|
106
|
+
expect(svg.props.uri).toBe(
|
|
107
|
+
'https://cdn.example/avatars/ada.svg#svgView(preserveAspectRatio(xMidYMid slice))'
|
|
108
|
+
);
|
|
109
|
+
expect(svg.props.className).toContain('rounded-full');
|
|
110
|
+
expect(tree.root.findAllByType('AvatarImage')).toHaveLength(0);
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
it('renders a raster avatar via AvatarImage, not SvgImage', () => {
|
|
114
|
+
const tree = renderAvatar({
|
|
115
|
+
...baseProfile,
|
|
116
|
+
avatar: 'https://cdn.example/avatars/ada.png',
|
|
117
|
+
});
|
|
118
|
+
const image = tree.root.findByType('AvatarImage');
|
|
119
|
+
expect(image.props.source).toEqual({
|
|
120
|
+
uri: 'https://cdn.example/avatars/ada.png',
|
|
121
|
+
});
|
|
122
|
+
expect(tree.root.findAllByType('SvgImage')).toHaveLength(0);
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
it('falls back to the deleted icon for a deleted profile that still has an avatar URL', () => {
|
|
126
|
+
const tree = renderAvatar({
|
|
127
|
+
...baseProfile,
|
|
128
|
+
avatar: 'https://cdn.example/avatars/ada.svg',
|
|
129
|
+
deletedAt: '2026-01-01T00:00:00Z',
|
|
130
|
+
});
|
|
131
|
+
expect(tree.root.findAllByType('SvgImage')).toHaveLength(0);
|
|
132
|
+
expect(tree.root.findAllByType('AvatarImage')).toHaveLength(0);
|
|
133
|
+
expect(tree.root.findByType('UserXIcon')).toBeDefined();
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
it('falls back to the initials tile when the profile has no avatar', () => {
|
|
137
|
+
const tree = renderAvatar(baseProfile);
|
|
138
|
+
expect(tree.root.findAllByType('SvgImage')).toHaveLength(0);
|
|
139
|
+
expect(tree.root.findAllByType('AvatarImage')).toHaveLength(0);
|
|
140
|
+
expect(tree.root.findAllByType('UserXIcon')).toHaveLength(0);
|
|
141
|
+
const initials = tree.root
|
|
142
|
+
.findAllByType('Text')
|
|
143
|
+
.map((node: { props: { children?: unknown } }) => node.props.children)
|
|
144
|
+
.find((child) => typeof child === 'string');
|
|
145
|
+
expect(initials).toBe('AL');
|
|
146
|
+
});
|
|
147
|
+
});
|
|
@@ -6,10 +6,12 @@ import {
|
|
|
6
6
|
getInitials,
|
|
7
7
|
hueFromHandle,
|
|
8
8
|
initialsBackground,
|
|
9
|
+
isSvgUrl,
|
|
9
10
|
svgCoverSrc,
|
|
10
11
|
} from '@openpeepshq/react';
|
|
11
12
|
import { useOpenPeepsTheme } from '../../theme/OpenPeepsThemeProvider';
|
|
12
13
|
import { Avatar, AvatarImage } from '../ui/avatar';
|
|
14
|
+
import { SvgImage } from '../ui/svg-image';
|
|
13
15
|
import { UserXIcon } from '../icons/index';
|
|
14
16
|
import { cn } from '../../lib/utils';
|
|
15
17
|
|
|
@@ -43,6 +45,12 @@ export const ProfileAvatar = ({
|
|
|
43
45
|
const roundedClass = 'rounded-full';
|
|
44
46
|
const deleted = isDeletedProfile(profile);
|
|
45
47
|
|
|
48
|
+
// SVG-ness must come from the original URL: svgCoverSrc appends the
|
|
49
|
+
// web-only #svgView cover fragment, which the RN media cache does not
|
|
50
|
+
// strip — if the fragment leaked into the cache lookup the URL would miss
|
|
51
|
+
// the isSvgUrl test and the SVG would silently fall back to the raster
|
|
52
|
+
// path (issue #1666).
|
|
53
|
+
const isSvg = !deleted && !!profile?.avatar && isSvgUrl(profile.avatar);
|
|
46
54
|
const avatarSource =
|
|
47
55
|
!deleted && profile?.avatar ? { uri: svgCoverSrc(profile.avatar) } : null;
|
|
48
56
|
|
|
@@ -82,6 +90,24 @@ export const ProfileAvatar = ({
|
|
|
82
90
|
);
|
|
83
91
|
}
|
|
84
92
|
|
|
93
|
+
// RN Image cannot decode SVG: render via SvgImage, which ignores the
|
|
94
|
+
// #svgView fragment and applies cover natively via preserveAspectRatio.
|
|
95
|
+
if (isSvg) {
|
|
96
|
+
return (
|
|
97
|
+
<Avatar
|
|
98
|
+
alt={t('profile.header.avatarAlt')}
|
|
99
|
+
className={rootClassName}
|
|
100
|
+
style={{ width: px, height: px }}
|
|
101
|
+
>
|
|
102
|
+
<SvgImage
|
|
103
|
+
uri={avatarSource.uri}
|
|
104
|
+
className={cn('h-full w-full', roundedClass)}
|
|
105
|
+
resizeMode="cover"
|
|
106
|
+
/>
|
|
107
|
+
</Avatar>
|
|
108
|
+
);
|
|
109
|
+
}
|
|
110
|
+
|
|
85
111
|
return (
|
|
86
112
|
<Avatar
|
|
87
113
|
alt={t('profile.header.avatarAlt')}
|
|
@@ -13,8 +13,8 @@ const React = require('react');
|
|
|
13
13
|
const ReactTestRenderer = require('react-test-renderer');
|
|
14
14
|
|
|
15
15
|
jest.mock('react-native', () => ({
|
|
16
|
-
View: (props:
|
|
17
|
-
React.createElement('View',
|
|
16
|
+
View: (props: Record<string, unknown>) =>
|
|
17
|
+
React.createElement('View', props, props.children),
|
|
18
18
|
Pressable: (props: {
|
|
19
19
|
children?: unknown;
|
|
20
20
|
onPress?: () => void;
|
|
@@ -25,8 +25,25 @@ jest.mock('react-native', () => ({
|
|
|
25
25
|
{ onPress: props.onPress, disabled: props.disabled },
|
|
26
26
|
props.children
|
|
27
27
|
),
|
|
28
|
-
TouchableWithoutFeedback: (props: {
|
|
29
|
-
|
|
28
|
+
TouchableWithoutFeedback: (props: {
|
|
29
|
+
children?: unknown;
|
|
30
|
+
accessible?: boolean;
|
|
31
|
+
onPress?: () => void;
|
|
32
|
+
accessibilityRole?: string;
|
|
33
|
+
accessibilityLabel?: string;
|
|
34
|
+
accessibilityState?: { selected?: boolean };
|
|
35
|
+
}) =>
|
|
36
|
+
React.createElement(
|
|
37
|
+
'TouchableWithoutFeedback',
|
|
38
|
+
{
|
|
39
|
+
accessible: props.accessible,
|
|
40
|
+
onPress: props.onPress,
|
|
41
|
+
accessibilityRole: props.accessibilityRole,
|
|
42
|
+
accessibilityLabel: props.accessibilityLabel,
|
|
43
|
+
accessibilityState: props.accessibilityState,
|
|
44
|
+
},
|
|
45
|
+
props.children
|
|
46
|
+
),
|
|
30
47
|
}));
|
|
31
48
|
|
|
32
49
|
jest.mock('react-i18next', () => ({
|
|
@@ -70,7 +87,7 @@ jest.mock('../../lib/utils', () => ({
|
|
|
70
87
|
}));
|
|
71
88
|
|
|
72
89
|
import type { ProfileCardProps } from './ProfileCard';
|
|
73
|
-
import { ProfileCard } from './ProfileCard';
|
|
90
|
+
import { MiniProfileCard, ProfileCard } from './ProfileCard';
|
|
74
91
|
|
|
75
92
|
const longBio =
|
|
76
93
|
'Lorem ipsum dolor sit amet, consectetur adipiscing elit. '.repeat(6) +
|
|
@@ -83,15 +100,16 @@ const profile = {
|
|
|
83
100
|
bio: longBio,
|
|
84
101
|
} as unknown as ProfileCardProps['profile'];
|
|
85
102
|
|
|
86
|
-
const renderCard = (
|
|
103
|
+
const renderCard = (
|
|
104
|
+
props: Partial<ProfileCardProps> = { actionType: 'link' as const }
|
|
105
|
+
) => {
|
|
87
106
|
let tree: ReturnType<typeof ReactTestRenderer.create>;
|
|
88
107
|
ReactTestRenderer.act(() => {
|
|
89
108
|
tree = ReactTestRenderer.create(
|
|
90
109
|
React.createElement(ProfileCard, {
|
|
91
110
|
profile,
|
|
92
|
-
actionType: 'link' as const,
|
|
93
111
|
...props,
|
|
94
|
-
})
|
|
112
|
+
} as ProfileCardProps)
|
|
95
113
|
);
|
|
96
114
|
});
|
|
97
115
|
return tree;
|
|
@@ -156,3 +174,142 @@ describe('ProfileCard layout guards (issue #2111)', () => {
|
|
|
156
174
|
expect(unspacedRow).toBeDefined();
|
|
157
175
|
});
|
|
158
176
|
});
|
|
177
|
+
|
|
178
|
+
describe('ProfileCard select-mode row (issue #1666)', () => {
|
|
179
|
+
it('renders a single-line text-base row without the bio in select mode', () => {
|
|
180
|
+
const tree = renderCard({ actionType: 'select' });
|
|
181
|
+
const name = tree.root
|
|
182
|
+
.findAllByType('ThemedText')
|
|
183
|
+
.find(
|
|
184
|
+
(node: { props: { children?: unknown } }) =>
|
|
185
|
+
node.props.children === 'Ada Lovelace'
|
|
186
|
+
);
|
|
187
|
+
expect(name).toBeDefined();
|
|
188
|
+
expect(name.props.className).toBe('text-base font-semibold truncate');
|
|
189
|
+
expect(name.props.numberOfLines).toBe(1);
|
|
190
|
+
// Bio has no business in a picker row — it shifts the avatar center.
|
|
191
|
+
const bioText = tree.root
|
|
192
|
+
.findAllByType('ThemedText')
|
|
193
|
+
.find((node: { props: { children?: unknown } }) =>
|
|
194
|
+
String(node.props.children).startsWith('Lorem ipsum')
|
|
195
|
+
);
|
|
196
|
+
expect(bioText).toBeUndefined();
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
it('keeps the 40dp avatar and the compact row padding in select mode', () => {
|
|
200
|
+
const tree = renderCard({ actionType: 'select' });
|
|
201
|
+
expect(
|
|
202
|
+
tree.root.findByProps({
|
|
203
|
+
className:
|
|
204
|
+
'w-full flex-row items-center justify-between px-4 mb-1 py-1.5',
|
|
205
|
+
})
|
|
206
|
+
).toBeDefined();
|
|
207
|
+
const avatar = tree.root.findByType('ProfileAvatar');
|
|
208
|
+
expect(avatar.props.className).toBe('size-10');
|
|
209
|
+
});
|
|
210
|
+
|
|
211
|
+
it('defers the inner touchable a11y when the caller provides no a11y props (issue #1666 review S2)', () => {
|
|
212
|
+
// A wrapped caller (ProfileSelector) carries the a11y on its own
|
|
213
|
+
// `Pressable` and passes nothing to the card; the inner touchable must
|
|
214
|
+
// defer (accessible=false) so screen readers see one element per row.
|
|
215
|
+
const selectTree = renderCard({ actionType: 'select' });
|
|
216
|
+
expect(
|
|
217
|
+
selectTree.root.findByType('TouchableWithoutFeedback').props.accessible
|
|
218
|
+
).toBe(false);
|
|
219
|
+
// Non-select cards keep the default (accessible) touchable.
|
|
220
|
+
const linkTree = renderCard({ actionType: 'link' });
|
|
221
|
+
expect(
|
|
222
|
+
linkTree.root.findByType('TouchableWithoutFeedback').props.accessible
|
|
223
|
+
).toBeUndefined();
|
|
224
|
+
});
|
|
225
|
+
|
|
226
|
+
it('carries the a11y on the row itself when the caller passes a11y props (issue #1666 round-10 S1)', () => {
|
|
227
|
+
// A bare caller (the DM candidate list) wraps the row in no accessible
|
|
228
|
+
// element, so it passes the a11y straight to the card; the inner
|
|
229
|
+
// touchable must then BE the accessible element, or the whole picker
|
|
230
|
+
// would be invisible to screen readers.
|
|
231
|
+
const tree = renderCard({
|
|
232
|
+
actionType: 'select',
|
|
233
|
+
accessibilityRole: 'button',
|
|
234
|
+
accessibilityLabel: 'Ada (selected)',
|
|
235
|
+
accessibilityState: { selected: true },
|
|
236
|
+
});
|
|
237
|
+
const touchable = tree.root.findByType('TouchableWithoutFeedback');
|
|
238
|
+
expect(touchable.props.accessible).toBe(true);
|
|
239
|
+
expect(touchable.props.accessibilityRole).toBe('button');
|
|
240
|
+
expect(touchable.props.accessibilityLabel).toBe('Ada (selected)');
|
|
241
|
+
expect(touchable.props.accessibilityState).toEqual({ selected: true });
|
|
242
|
+
});
|
|
243
|
+
|
|
244
|
+
it('keeps the large card geometry (bio included) outside select mode', () => {
|
|
245
|
+
const tree = renderCard({ actionType: 'link' });
|
|
246
|
+
const name = tree.root
|
|
247
|
+
.findAllByType('ThemedText')
|
|
248
|
+
.find(
|
|
249
|
+
(node: { props: { children?: unknown } }) =>
|
|
250
|
+
node.props.children === 'Ada Lovelace'
|
|
251
|
+
);
|
|
252
|
+
expect(name.props.className).toBe('text-lg font-semibold truncate');
|
|
253
|
+
const bioText = tree.root
|
|
254
|
+
.findAllByType('ThemedText')
|
|
255
|
+
.find((node: { props: { children?: unknown } }) =>
|
|
256
|
+
String(node.props.children).startsWith('Lorem ipsum')
|
|
257
|
+
);
|
|
258
|
+
expect(bioText).toBeDefined();
|
|
259
|
+
// The non-select geometry contract (issue #1666 review S6): the large
|
|
260
|
+
// card keeps its `size-16` avatar and `mb-8` row padding — symmetric to
|
|
261
|
+
// the select-mode pinning above.
|
|
262
|
+
expect(tree.root.findByType('ProfileAvatar').props.className).toBe(
|
|
263
|
+
'size-16'
|
|
264
|
+
);
|
|
265
|
+
expect(
|
|
266
|
+
tree.root.findByProps({
|
|
267
|
+
className: 'w-full flex-row items-center justify-between px-4 mb-8',
|
|
268
|
+
})
|
|
269
|
+
).toBeDefined();
|
|
270
|
+
});
|
|
271
|
+
});
|
|
272
|
+
|
|
273
|
+
describe('MiniProfileCard compact chip (issue #1666 round-11 S2)', () => {
|
|
274
|
+
const renderChip = (props: Partial<{ showAction: boolean }> = {}) => {
|
|
275
|
+
let tree: ReturnType<typeof ReactTestRenderer.create>;
|
|
276
|
+
ReactTestRenderer.act(() => {
|
|
277
|
+
tree = ReactTestRenderer.create(
|
|
278
|
+
React.createElement(MiniProfileCard, { profile, ...props })
|
|
279
|
+
);
|
|
280
|
+
});
|
|
281
|
+
return tree;
|
|
282
|
+
};
|
|
283
|
+
|
|
284
|
+
it('keeps the size-3 avatar, text-xs label and py-1.5 padding (web ProfileBadge parity)', () => {
|
|
285
|
+
// The round-8/S4 change shrank the chip to match the web `ProfileBadge`
|
|
286
|
+
// (12dp avatar, 12sp label, tight padding). Pin that geometry so it does
|
|
287
|
+
// not silently regress to the old larger chip (`size-8` avatar, default
|
|
288
|
+
// text size, `py-2`).
|
|
289
|
+
const tree = renderChip();
|
|
290
|
+
expect(tree.root.findByType('ProfileAvatar').props.className).toBe(
|
|
291
|
+
'size-3'
|
|
292
|
+
);
|
|
293
|
+
const label = tree.root
|
|
294
|
+
.findAllByType('ThemedText')
|
|
295
|
+
.find((node: { props: { children?: unknown } }) =>
|
|
296
|
+
String(node.props.children).startsWith('Ada')
|
|
297
|
+
);
|
|
298
|
+
expect(label).toBeDefined();
|
|
299
|
+
expect(label.props.className).toBe('text-xs');
|
|
300
|
+
expect(
|
|
301
|
+
tree.root.findByProps({
|
|
302
|
+
className:
|
|
303
|
+
'flex flex-row items-center gap-x-2 rounded-md border border-border px-2 py-1.5',
|
|
304
|
+
})
|
|
305
|
+
).toBeDefined();
|
|
306
|
+
});
|
|
307
|
+
|
|
308
|
+
it('omits the remove button when showAction is false', () => {
|
|
309
|
+
const withAction = renderChip();
|
|
310
|
+
expect(withAction.root.findByType('Pressable')).toBeDefined();
|
|
311
|
+
|
|
312
|
+
const noAction = renderChip({ showAction: false });
|
|
313
|
+
expect(noAction.root.findAllByType('Pressable')).toHaveLength(0);
|
|
314
|
+
});
|
|
315
|
+
});
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
View,
|
|
4
|
+
TouchableWithoutFeedback,
|
|
5
|
+
Pressable,
|
|
6
|
+
type AccessibilityRole,
|
|
7
|
+
type AccessibilityState,
|
|
8
|
+
} from 'react-native';
|
|
3
9
|
import type { PublicProfile, Profile } from '@openpeepshq/common/types';
|
|
4
10
|
import { markdownPlainText } from '@openpeepshq/common/lib';
|
|
5
11
|
import { XIcon } from '../icons/index';
|
|
@@ -18,7 +24,6 @@ export interface ProfileCardProps {
|
|
|
18
24
|
showAction?: boolean;
|
|
19
25
|
/** Custom action node rendered on the right of the card. */
|
|
20
26
|
action?: React.ReactNode;
|
|
21
|
-
hasAction?: boolean;
|
|
22
27
|
actionType?: 'follow' | 'message' | 'unfollow' | 'link' | 'select';
|
|
23
28
|
handleSelectProfile?: () => void;
|
|
24
29
|
rightComponent?: React.ReactNode;
|
|
@@ -28,6 +33,16 @@ export interface ProfileCardProps {
|
|
|
28
33
|
* tight card-to-border spacing.
|
|
29
34
|
*/
|
|
30
35
|
unspaced?: boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Screen-reader identity for select (picker) rows, forwarded to the row's
|
|
38
|
+
* touchable. Picker rows are sometimes rendered bare — no accessible
|
|
39
|
+
* wrapper (the DM candidate list) — so the select-mode a11y travels with
|
|
40
|
+
* the row instead of assuming a `ProfileSelector`-style wrapper
|
|
41
|
+
* (issue #1666 round-10 review S1).
|
|
42
|
+
*/
|
|
43
|
+
accessibilityRole?: AccessibilityRole;
|
|
44
|
+
accessibilityLabel?: string;
|
|
45
|
+
accessibilityState?: AccessibilityState;
|
|
31
46
|
}
|
|
32
47
|
|
|
33
48
|
export const ProfileCard = ({
|
|
@@ -39,6 +54,9 @@ export const ProfileCard = ({
|
|
|
39
54
|
handleSelectProfile,
|
|
40
55
|
rightComponent,
|
|
41
56
|
unspaced = false,
|
|
57
|
+
accessibilityRole,
|
|
58
|
+
accessibilityLabel,
|
|
59
|
+
accessibilityState,
|
|
42
60
|
}: ProfileCardProps) => {
|
|
43
61
|
const navigation =
|
|
44
62
|
useNavigation<NativeStackNavigationProp<MainStackParamList>>();
|
|
@@ -64,25 +82,58 @@ export const ProfileCard = ({
|
|
|
64
82
|
|
|
65
83
|
const bio = markdownPlainText(profile.bio);
|
|
66
84
|
|
|
85
|
+
// Picker rows (actionType="select") are a fixed single-line row —
|
|
86
|
+
// `px-4 mb-1 py-1.5`, name + handle, no bio — so the avatar stays
|
|
87
|
+
// vertically centered regardless of long-name content (issue #1666).
|
|
88
|
+
const selectRow = actionType === 'select';
|
|
89
|
+
|
|
90
|
+
// Select rows render two ways: wrapped in an accessible `Pressable`
|
|
91
|
+
// (ProfileSelector — the wrapper carries the a11y, the inner touchable
|
|
92
|
+
// must defer so screen readers see one element per row, issue #1666
|
|
93
|
+
// review S2) or bare (the DM candidate list — the row must carry the
|
|
94
|
+
// a11y itself, issue #1666 round-10 review S1). The caller's a11y props
|
|
95
|
+
// pick the mode: present → the touchable is the accessible element;
|
|
96
|
+
// absent → it defers to the wrapper.
|
|
97
|
+
const hasRowA11y =
|
|
98
|
+
accessibilityRole !== undefined ||
|
|
99
|
+
accessibilityLabel !== undefined ||
|
|
100
|
+
accessibilityState !== undefined;
|
|
101
|
+
|
|
67
102
|
return (
|
|
68
103
|
<View
|
|
69
104
|
className={
|
|
70
105
|
unspaced
|
|
71
106
|
? 'w-full flex-row items-center justify-between'
|
|
72
107
|
: `w-full flex-row items-center justify-between px-4 ${
|
|
73
|
-
|
|
108
|
+
selectRow ? 'mb-1 py-1.5' : 'mb-8'
|
|
74
109
|
}`
|
|
75
110
|
}
|
|
76
111
|
>
|
|
77
|
-
<TouchableWithoutFeedback
|
|
112
|
+
<TouchableWithoutFeedback
|
|
113
|
+
accessible={selectRow ? hasRowA11y : undefined}
|
|
114
|
+
accessibilityRole={
|
|
115
|
+
selectRow && hasRowA11y ? accessibilityRole : undefined
|
|
116
|
+
}
|
|
117
|
+
accessibilityLabel={
|
|
118
|
+
selectRow && hasRowA11y ? accessibilityLabel : undefined
|
|
119
|
+
}
|
|
120
|
+
accessibilityState={
|
|
121
|
+
selectRow && hasRowA11y ? accessibilityState : undefined
|
|
122
|
+
}
|
|
123
|
+
onPress={onPress}
|
|
124
|
+
>
|
|
78
125
|
<View className="flex flex-row items-center gap-x-2 min-w-0 flex-1">
|
|
79
126
|
<ProfileAvatar
|
|
80
127
|
profile={profile}
|
|
81
|
-
className={
|
|
128
|
+
className={selectRow ? 'size-10' : 'size-16'}
|
|
82
129
|
/>
|
|
83
130
|
<View className="min-w-0 flex-1">
|
|
84
131
|
<ThemedText
|
|
85
|
-
className=
|
|
132
|
+
className={
|
|
133
|
+
selectRow
|
|
134
|
+
? 'text-base font-semibold truncate'
|
|
135
|
+
: 'text-lg font-semibold truncate'
|
|
136
|
+
}
|
|
86
137
|
numberOfLines={1}
|
|
87
138
|
>
|
|
88
139
|
{truncateText(profile.displayName, 18) || profile.handle}
|
|
@@ -90,7 +141,7 @@ export const ProfileCard = ({
|
|
|
90
141
|
<ThemedText className="truncate" numberOfLines={1}>
|
|
91
142
|
@{profile.handle}
|
|
92
143
|
</ThemedText>
|
|
93
|
-
{bio ? (
|
|
144
|
+
{bio && !selectRow ? (
|
|
94
145
|
<ThemedText
|
|
95
146
|
className="text-muted-foreground mt-1 text-sm"
|
|
96
147
|
numberOfLines={2}
|
|
@@ -126,9 +177,11 @@ export const MiniProfileCard = ({
|
|
|
126
177
|
showAction = true,
|
|
127
178
|
}: MiniProfileCardProps) => {
|
|
128
179
|
return (
|
|
129
|
-
<View className="flex flex-row items-center gap-x-2 rounded-md border border-border px-2 py-
|
|
130
|
-
<ProfileAvatar profile={profile} className="size-
|
|
131
|
-
|
|
180
|
+
<View className="flex flex-row items-center gap-x-2 rounded-md border border-border px-2 py-1.5">
|
|
181
|
+
<ProfileAvatar profile={profile} className="size-3" />
|
|
182
|
+
{/* text-xs: matches the web ProfileBadge label (issue #1666 review S4);
|
|
183
|
+
an unstyled ThemedText here would render larger than the 12dp avatar. */}
|
|
184
|
+
<ThemedText className="text-xs">
|
|
132
185
|
{truncateText(profile.displayName, 10) || `@${profile.handle}`}
|
|
133
186
|
</ThemedText>
|
|
134
187
|
{showAction && (
|