Skip to content

Commit 47ad20a

Browse files
committed
feat(web,mobile): image-only messages use bubble corners, an inner edge, and one collage for several images
1 parent 587e90f commit 47ad20a

2 files changed

Lines changed: 47 additions & 11 deletions

File tree

‎apps/mobile/src/features/threads/ThreadFeed.tsx‎

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1665,7 +1665,11 @@ function renderFeedEntry(
16651665
attachmentId={attachment.uploadedAttachmentId}
16661666
name={attachment.name}
16671667
mimeType={attachment.mimeType}
1668-
className="h-[140px] w-[180px] rounded-[14px]"
1668+
className={
1669+
mediaOnly
1670+
? "h-[140px] w-[180px] rounded-[20px]"
1671+
: "h-[140px] w-[180px] rounded-[14px]"
1672+
}
16691673
onPressPreview={props.onPressPreview}
16701674
/>
16711675
) : attachment.type === "image" ? (
@@ -1684,7 +1688,7 @@ function renderFeedEntry(
16841688
>
16851689
<Image
16861690
source={{ uri: attachment.previewUri }}
1687-
style={{ width: 180, height: 140, borderRadius: 14 }}
1691+
style={{ width: 180, height: 140, borderRadius: mediaOnly ? 20 : 14 }}
16881692
/>
16891693
</Pressable>
16901694
) : (
@@ -1705,7 +1709,10 @@ function renderFeedEntry(
17051709
className={
17061710
inlineAttachmentIds.size
17071711
? "h-24 w-24 rounded-[14px] bg-user-bubble-foreground/15"
1708-
: "aspect-[1.3] w-full rounded-[14px] bg-user-bubble-foreground/15"
1712+
: mediaOnly
1713+
? // Matches the bubble's corners; native borders sit inside, so the edge adds no size.
1714+
"aspect-[1.3] w-full rounded-[20px] border border-border bg-user-bubble-foreground/15"
1715+
: "aspect-[1.3] w-full rounded-[14px] bg-user-bubble-foreground/15"
17091716
}
17101717
onPressPreview={props.onPressPreview}
17111718
/>

‎apps/web/src/components/chat/TimelineUserMessageRow.tsx‎

Lines changed: 37 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,10 @@ import {
8181
import { UserMessageContextReferenceChip } from "./UserMessageContextChips";
8282
import { resolvePreviewAnnotationImage } from "./TimelineUserMessageRow.logic";
8383

84+
// Drawn inside the media so dark screenshots keep an edge on the dark background.
85+
const MEDIA_EDGE_CLASS_NAME =
86+
"relative after:pointer-events-none after:absolute after:inset-0 after:z-10 after:rounded-[inherit] after:ring-1 after:ring-inset after:ring-black/9 dark:after:ring-white/12";
87+
8488
const BUBBLE_CHIP_CLASS_NAME =
8589
"[&_[data-slot=context-chip]]:[--context-chip-ink:var(--context-chip-message,var(--context-chip-accent))]";
8690

@@ -353,6 +357,12 @@ function UserTimelineRow({ row }: { row: Extract<TimelineRow, { kind: "message"
353357
userVideos.length === 0 &&
354358
regularImages.length === 1 &&
355359
regularImages[0]!.source?.kind !== "snap-shot";
360+
// Several images sent without words share one rounded shape, split by hairlines.
361+
const collage =
362+
mediaOnly &&
363+
userVideos.length === 0 &&
364+
regularImages.length > 1 &&
365+
regularImages.every((image) => image.source?.kind !== "snap-shot");
356366
const annotationRecordIds = resolvedContext.records
357367
.filter((record) => record.kind === "preview-annotation")
358368
.map((record) => record.contextId);
@@ -519,25 +529,43 @@ function UserTimelineRow({ row }: { row: Extract<TimelineRow, { kind: "message"
519529
{(regularImages.length > 0 || userVideos.length > 0) && (
520530
<div
521531
className={cn(
522-
"grid gap-2",
532+
"grid",
523533
!mediaOnly
524-
? "mb-2 max-w-[210px] grid-cols-2"
534+
? "mb-2 max-w-[210px] grid-cols-2 gap-2"
525535
: loneImage
526536
? "max-w-full"
527-
: "w-80 max-w-full grid-cols-2",
537+
: collage
538+
? cn(
539+
MEDIA_EDGE_CLASS_NAME,
540+
"w-80 max-w-full gap-px overflow-hidden rounded-2xl bg-black/9 dark:bg-white/12",
541+
regularImages.length === 2
542+
? "auto-rows-[12rem] grid-cols-2"
543+
: regularImages.length === 3
544+
? "auto-rows-[calc(6rem-0.5px)] grid-cols-[3fr_2fr]"
545+
: "auto-rows-[6rem] grid-cols-2",
546+
)
547+
: "w-80 max-w-full grid-cols-2 gap-2",
528548
)}
529549
>
530-
{regularImages.map((image) => (
550+
{regularImages.map((image, index) => (
531551
<div
532552
key={image.id}
533553
className={cn(
534554
"bg-background/70",
535555
image.source?.kind === "snap-shot" && image.previewUrl
536556
? cn(SNAP_SHOT_ATTACHMENT_FRAME_CLASS, "col-span-2")
537-
: cn(
538-
"overflow-hidden rounded-lg border border-border/80",
539-
!loneImage && "aspect-[4/3]",
540-
),
557+
: loneImage
558+
? cn(MEDIA_EDGE_CLASS_NAME, "overflow-hidden rounded-2xl")
559+
: collage
560+
? cn(
561+
"overflow-hidden bg-background",
562+
regularImages.length === 3 && index === 0 && "row-span-2",
563+
regularImages.length > 3 &&
564+
regularImages.length % 2 === 1 &&
565+
index === regularImages.length - 1 &&
566+
"col-span-2",
567+
)
568+
: "aspect-[4/3] overflow-hidden rounded-lg border border-border/80",
541569
)}
542570
>
543571
{image.previewUrl ? (
@@ -573,6 +601,7 @@ function UserTimelineRow({ row }: { row: Extract<TimelineRow, { kind: "message"
573601
className={cn(
574602
"flex min-h-[72px] items-center justify-center px-2 py-3 text-center text-2xs text-muted-foreground/70",
575603
loneImage && "h-48 w-64 max-w-full",
604+
collage && "h-full",
576605
)}
577606
>
578607
{image.name}

0 commit comments

Comments
 (0)