Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

WIP messages UI

Tim Wilsondae7abd7ec74
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/messages/[partnerId]/page-client.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/messages/[partnerId]/page-client.tsx
index 3c3d13cc24..c7ded1a22c 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/messages/[partnerId]/page-client.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/messages/[partnerId]/page-client.tsx
@@ -75,7 +75,7 @@ export function ProgramMessagesPartnerPageClient() {
}}
>
<div className="flex h-full min-h-0 flex-col">
- <div className="border-border-subtle flex h-12 items-center justify-between gap-4 border-b px-4 sm:h-16 sm:px-6">
+ <div className="border-border-subtle flex h-12 shrink-0 items-center justify-between gap-4 border-b px-4 sm:h-16 sm:px-6">
<div className="flex min-w-0 items-center gap-2">
<button
type="button"
@@ -138,13 +138,13 @@ export function ProgramMessagesPartnerPageClient() {
{/* Right panel - Profile */}
<div
className={cn(
- "absolute right-0 top-0 h-full w-0 overflow-hidden bg-white shadow-lg transition-[width]",
+ "absolute right-0 top-0 h-full min-h-0 w-0 overflow-hidden bg-white shadow-lg transition-[width]",
"@[960px]/page:shadow-none @[960px]/page:relative",
isRightPanelOpen && "w-full sm:w-[340px]",
)}
>
- <div className="border-border-subtle size-full w-full border-l sm:w-[340px]">
- <div className="border-border-subtle flex h-12 items-center justify-between gap-4 border-b px-4 sm:h-16 sm:px-6">
+ <div className="border-border-subtle flex size-full min-h-0 w-full flex-col border-l sm:w-[340px]">
+ <div className="border-border-subtle flex h-12 shrink-0 items-center justify-between gap-4 border-b px-4 sm:h-16 sm:px-6">
<h2 className="text-content-emphasis text-lg font-semibold leading-7">
Profile
</h2>
@@ -169,7 +169,7 @@ export function ProgramMessagesPartnerPageClient() {
</button>
</div>
</div>
- <div className="bg-bg-muted flex size-full flex-col gap-4 p-6">
+ <div className="bg-bg-muted scrollbar-hide flex grow flex-col gap-4 overflow-y-scroll p-6">
{partner ? (
<>
<PartnerInfoSection partner={partner} />
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/messages/layout.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/messages/layout.tsx
index 36d9b796b5..0cefb95553 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/messages/layout.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/messages/layout.tsx
@@ -66,7 +66,7 @@ export default function MessagesLayout({ children }: { children: ReactNode }) {
>
{/* Left panel - 800px/messages list */}
<div className="@[800px]/page:w-[280px] @[960px]/page:w-[340px] flex w-full flex-col overflow-hidden">
- <div className="border-border-subtle flex h-12 items-center justify-between gap-4 border-b px-4 sm:h-16 sm:px-6">
+ <div className="border-border-subtle flex h-12 shrink-0 items-center justify-between gap-4 border-b px-4 sm:h-16 sm:px-6">
<div className="flex min-w-0 items-center gap-4">
<NavButton />
<h1 className="text-content-emphasis text-lg font-semibold leading-7">
@@ -80,7 +80,7 @@ export default function MessagesLayout({ children }: { children: ReactNode }) {
onClick={() => toast.info("WIP")}
/>
</div>
- <div className="grow">
+ <div className="scrollbar-hide grow overflow-y-auto">
{partnersWithMessages?.length || isLoading ? (
<MessagesList
groupedMessages={partnersWithMessages.map((p) => ({
diff --git a/apps/web/ui/messages/messages-panel.tsx b/apps/web/ui/messages/messages-panel.tsx
index d2370818be..e5054b9aa3 100644
--- a/apps/web/ui/messages/messages-panel.tsx
+++ b/apps/web/ui/messages/messages-panel.tsx
@@ -1,4 +1,4 @@
-import { ArrowTurnLeft, Button } from "@dub/ui";
+import { ArrowTurnLeft, Button, Tooltip } from "@dub/ui";
import { OG_AVATAR_URL, cn, formatDate } from "@dub/utils";
import { Fragment, useRef, useState } from "react";
import ReactTextareaAutosize from "react-textarea-autosize";
@@ -42,8 +42,20 @@ export function MessagesPanel({
return (
<div className="flex size-full flex-col">
<div className="scrollbar-hide flex grow flex-col-reverse overflow-y-auto">
- <div className="flex flex-col items-stretch gap-6 p-6">
+ <div className="flex flex-col items-stretch gap-5 p-6">
{messages?.map((message, idx) => {
+ const isNewDate =
+ idx === 0 ||
+ messages[idx - 1].createdAt.toDateString() !==
+ message.createdAt.toDateString();
+
+ // If it's been more than 5 minutes since the last message
+ const isNewTime =
+ isNewDate ||
+ message.createdAt.getTime() -
+ messages[idx - 1].createdAt.getTime() >
+ 5 * 1000 * 60;
+
const isCurrentUser =
message.sender.type === currentUserType &&
message.sender.id === currentUserId;
@@ -54,9 +66,7 @@ export function MessagesPanel({
return (
<Fragment key={message.id}>
- {(idx === 0 ||
- messages[idx - 1].createdAt.toDateString() !==
- message.createdAt.toDateString()) && (
+ {isNewDate && (
<div
className={cn(
"text-content-default text-center text-xs font-semibold",
@@ -76,21 +86,54 @@ export function MessagesPanel({
)}
>
{/* Avatar */}
- <img
- src={
- message.sender.avatar ||
- `${OG_AVATAR_URL}${message.sender.id}`
- }
- alt={`${message.sender.name} avatar`}
- className="size-8 rounded-full"
- />
+ <Tooltip content={message.sender.name}>
+ <div className="relative shrink-0">
+ <img
+ src={
+ message.sender.avatar ||
+ `${OG_AVATAR_URL}${message.sender.id}`
+ }
+ alt={`${message.sender.name} avatar`}
+ className="size-8 rounded-full"
+ draggable={false}
+ />
+ {message.sender.groupAvatar && (
+ <img
+ src={message.sender.groupAvatar}
+ alt=""
+ className="absolute -bottom-0.5 -right-0.5 size-3.5 rounded-full border border-white"
+ />
+ )}
+ </div>
+ </Tooltip>
<div
className={cn(
- "flex flex-col",
+ "flex flex-col gap-1",
isCurrentUser && "items-end",
)}
>
+ {/* Name / timestamp */}
+ {(!isCurrentUser || isNewTime) && (
+ <div className="flex items-center gap-1.5">
+ {!isCurrentUser && (
+ <span className="text-content-default min-w-0 truncate text-xs font-medium">
+ {message.sender.name}
+ </span>
+ )}
+ {isNewTime && (
+ <span className="text-content-subtle text-xs font-medium">
+ {new Date(message.createdAt).toLocaleTimeString(
+ "en-US",
+ {
+ hour: "numeric",
+ minute: "numeric",
+ },
+ )}
+ </span>
+ )}
+ </div>
+ )}
{/* Message box */}
<div
className={cn(
diff --git a/apps/web/ui/partners/partner-info-stats.tsx b/apps/web/ui/partners/partner-info-stats.tsx
index 840f9b8771..69765d731b 100644
--- a/apps/web/ui/partners/partner-info-stats.tsx
+++ b/apps/web/ui/partners/partner-info-stats.tsx
@@ -11,7 +11,7 @@ export function PartnerInfoStats({
return (
<div
className={cn(
- "xs:grid-cols-3 grid grid-cols-2 gap-px overflow-hidden rounded-lg border border-neutral-200 bg-neutral-200",
+ "xs:grid-cols-3 grid shrink-0 grid-cols-2 gap-px overflow-hidden rounded-lg border border-neutral-200 bg-neutral-200",
className,
)}
>