add: final changes with memory modal

This commit is contained in:
Mahesh Sanikommmu 2026-01-03 14:46:33 -08:00
parent 300a5504e9
commit 1608380077
7 changed files with 124 additions and 19 deletions

View file

@ -13,16 +13,29 @@ import {
import { cn } from "@lib/utils"
import { dmSansClassName } from "@/utils/fonts"
export function TweetPreview({ data }: { data: Tweet }) {
export function TweetPreview({
data,
noBgColor,
}: {
data: Tweet
noBgColor?: boolean
}) {
const parsedTweet = typeof data === "string" ? JSON.parse(data) : data
const tweet = enrichTweet(parsedTweet)
return (
<div className="p-3 rounded-[18px] !bg-[#0B1017] sm-tweet-theme w-full min-w-0">
<div
className={cn(
"p-3 sm-tweet-theme w-full min-w-0",
noBgColor
? "bg-transparent rounded-none"
: "bg-[#0B1017]! rounded-[18px]",
)}
>
<Suspense fallback={<TweetSkeleton />}>
<TweetContainer
className={cn(
"!pb-0 !my-0 !bg-transparent !border-none !w-full !min-w-0",
"pb-0! my-0! bg-transparent! border-none! w-full! min-w-0!",
dmSansClassName(),
)}
>

View file

@ -0,0 +1,37 @@
"use client"
import type { Tweet } from "react-tweet/api"
import { TweetPreview } from "@/components/new/document-cards/tweet-preview"
import { ExternalLinkIcon } from "lucide-react"
interface TweetContentProps {
url?: string | null
tweetMetadata?: unknown
}
export function TweetContent({ url, tweetMetadata }: TweetContentProps) {
if (tweetMetadata) {
return (
<div className="flex-1 flex items-center justify-center w-full p-4 overflow-auto">
<TweetPreview data={tweetMetadata as Tweet} noBgColor />
</div>
)
}
return (
<div className="flex-1 flex flex-col items-center justify-center gap-3 text-gray-400">
<p>Tweet preview unavailable</p>
{url && (
<a
href={url}
target="_blank"
rel="noopener noreferrer"
className="flex items-center gap-1.5 text-sm text-blue-400 hover:underline"
>
View on X
<ExternalLinkIcon className="w-3.5 h-3.5" />
</a>
)}
</div>
)
}

View file

@ -113,6 +113,26 @@ const PDFIcon = ({ className }: { className: string }) => {
)
}
const YouTubeIcon = ({ className }: { className: string }) => {
return (
<svg
width="20"
height="14"
viewBox="0 0 20 14"
fill="none"
xmlns="http://www.w3.org/2000/svg"
className={className}
>
<title>YouTube Icon</title>
<path
d="M8 10L13.19 7L8 4V10ZM19.56 2.17C19.69 2.64 19.78 3.27 19.84 4.07C19.91 4.87 19.94 5.56 19.94 6.16L20 7C20 9.19 19.84 10.8 19.56 11.83C19.31 12.73 18.73 13.31 17.83 13.56C17.36 13.69 16.5 13.78 15.18 13.84C13.88 13.91 12.69 13.94 11.59 13.94L10 14C5.81 14 3.2 13.84 2.17 13.56C1.27 13.31 0.69 12.73 0.44 11.83C0.31 11.36 0.22 10.73 0.16 9.93C0.0900001 9.13 0.0599999 8.44 0.0599999 7.84L0 7C0 4.81 0.16 3.2 0.44 2.17C0.69 1.27 1.27 0.69 2.17 0.44C2.64 0.31 3.5 0.22 4.82 0.16C6.12 0.0899998 7.31 0.0599999 8.41 0.0599999L10 0C14.19 0 16.8 0.16 17.83 0.44C18.73 0.69 19.31 1.27 19.56 2.17Z"
fill="#FF0034"
/>
<path d="M8 10L13.19 7L8 4V10Z" fill="white" />
</svg>
)
}
const TextDocumentIcon = ({ className }: { className: string }) => {
return (
<svg
@ -186,6 +206,10 @@ export const getDocumentIcon = (
return <MCPIcon {...iconProps} />
}
if (url?.includes("youtube.com") || url?.includes("youtu.be")) {
return <YouTubeIcon className={className} />
}
if (
type === "webpage" ||
type === "url" ||
@ -201,6 +225,8 @@ export const getDocumentIcon = (
}
switch (type) {
case "tweet":
return <span className={className}>𝕏</span>
case "google_doc":
return <GoogleDocs {...iconProps} />
case "google_sheet":
@ -228,6 +254,9 @@ export const getDocumentIcon = (
return <OneDrive {...iconProps} />
case "pdf":
return <PDFIcon className={className} />
case "youtube":
case "video":
return <YouTubeIcon className={className} />
default:
return <TextDocumentIcon className={className} />
}

View file

@ -183,7 +183,7 @@ export function GraphListMemories({
<TabsTrigger
value="graph"
className={cn(
"rounded-full data-[state=active]:bg-[#00173C]! dark:data-[state=active]:border-[#2261CA33]! px-4 py-4",
"group rounded-full data-[state=active]:bg-[#00173C]! dark:data-[state=active]:border-[#2261CA33]! px-4 py-4",
)}
>
<svg
@ -207,16 +207,16 @@ export function GraphListMemories({
<g mask="url(#mask0_891_45456)">
<path
d="M7.00057 12.8334C6.51446 12.8334 6.10126 12.6632 5.76099 12.3229C5.42071 11.9827 5.25057 11.5695 5.25057 11.0834C5.25057 11.0347 5.253 10.9813 5.25786 10.9229C5.26272 10.8646 5.27001 10.8111 5.27974 10.7625L4.06932 10.0771C3.91376 10.2132 3.73876 10.3177 3.54432 10.3906C3.34988 10.4636 3.14085 10.5 2.91724 10.5C2.43113 10.5 2.01793 10.3299 1.67765 9.9896C1.33738 9.64933 1.16724 9.23613 1.16724 8.75002C1.16724 8.26391 1.33738 7.85071 1.67765 7.51044C2.01793 7.17016 2.43113 7.00002 2.91724 7.00002C3.15057 7.00002 3.36932 7.04377 3.57349 7.13127C3.77765 7.21877 3.96238 7.3403 4.12765 7.49585L5.86307 6.62085C5.8339 6.39724 5.84606 6.17849 5.89953 5.9646C5.953 5.75071 6.04779 5.55141 6.1839 5.36669L5.68807 4.60835C5.62001 4.6278 5.54953 4.64238 5.47661 4.6521C5.40369 4.66183 5.32835 4.66669 5.25057 4.66669C4.76446 4.66669 4.35126 4.49655 4.01099 4.15627C3.67071 3.81599 3.50057 3.4028 3.50057 2.91669C3.50057 2.43058 3.67071 2.01738 4.01099 1.6771C4.35126 1.33683 4.76446 1.16669 5.25057 1.16669C5.73668 1.16669 6.14988 1.33683 6.49015 1.6771C6.83043 2.01738 7.00057 2.43058 7.00057 2.91669C7.00057 3.11113 6.96897 3.29828 6.90578 3.47815C6.84258 3.65801 6.75751 3.82085 6.65057 3.96669L7.16099 4.72502C7.23876 4.70558 7.31168 4.69099 7.37974 4.68127C7.44779 4.67155 7.52071 4.66669 7.59849 4.66669C7.76376 4.66669 7.91932 4.68613 8.06515 4.72502C8.21099 4.76391 8.35196 4.82224 8.48807 4.90002L9.45057 4.11252C9.41168 4.0153 9.38251 3.91565 9.36307 3.81356C9.34363 3.71148 9.3339 3.60696 9.3339 3.50002C9.3339 3.01391 9.50404 2.60071 9.84432 2.26044C10.1846 1.92016 10.5978 1.75002 11.0839 1.75002C11.57 1.75002 11.9832 1.92016 12.3235 2.26044C12.6638 2.60071 12.8339 3.01391 12.8339 3.50002C12.8339 3.98613 12.6638 4.39933 12.3235 4.7396C11.9832 5.07988 11.57 5.25002 11.0839 5.25002C10.9186 5.25002 10.7631 5.22815 10.6172 5.1844C10.4714 5.14065 10.3304 5.07988 10.1943 5.0021L9.23182 5.80419C9.27071 5.90141 9.29988 6.00106 9.31932 6.10315C9.33876 6.20523 9.34849 6.30974 9.34849 6.41669C9.34849 6.9028 9.17835 7.31599 8.83807 7.65627C8.49779 7.99655 8.0846 8.16669 7.59849 8.16669C7.36515 8.16669 7.14397 8.12294 6.93494 8.03544C6.72592 7.94794 6.53876 7.82641 6.37349 7.67085L4.65265 8.53127C4.6721 8.61877 4.67939 8.70627 4.67453 8.79377C4.66967 8.88127 4.65751 8.96877 4.63807 9.05627L5.86307 9.75627C6.01863 9.62016 6.19119 9.51565 6.38078 9.44273C6.57036 9.36981 6.77696 9.33335 7.00057 9.33335C7.48668 9.33335 7.89988 9.50349 8.24015 9.84377C8.58043 10.184 8.75057 10.5972 8.75057 11.0834C8.75057 11.5695 8.58043 11.9827 8.24015 12.3229C7.89988 12.6632 7.48668 12.8334 7.00057 12.8334ZM2.91724 9.33335C3.08251 9.33335 3.22106 9.27745 3.33286 9.16565C3.44467 9.05384 3.50057 8.9153 3.50057 8.75002C3.50057 8.58474 3.44467 8.4462 3.33286 8.3344C3.22106 8.22259 3.08251 8.16669 2.91724 8.16669C2.75196 8.16669 2.61342 8.22259 2.50161 8.3344C2.38981 8.4462 2.3339 8.58474 2.3339 8.75002C2.3339 8.9153 2.38981 9.05384 2.50161 9.16565C2.61342 9.27745 2.75196 9.33335 2.91724 9.33335ZM5.25057 3.50002C5.41585 3.50002 5.55439 3.44412 5.66619 3.33231C5.778 3.22051 5.8339 3.08196 5.8339 2.91669C5.8339 2.75141 5.778 2.61287 5.66619 2.50106C5.55439 2.38926 5.41585 2.33335 5.25057 2.33335C5.08529 2.33335 4.94675 2.38926 4.83494 2.50106C4.72314 2.61287 4.66724 2.75141 4.66724 2.91669C4.66724 3.08196 4.72314 3.22051 4.83494 3.33231C4.94675 3.44412 5.08529 3.50002 5.25057 3.50002ZM7.00057 11.6667C7.16585 11.6667 7.30439 11.6108 7.41619 11.499C7.528 11.3872 7.5839 11.2486 7.5839 11.0834C7.5839 10.9181 7.528 10.7795 7.41619 10.6677C7.30439 10.5559 7.16585 10.5 7.00057 10.5C6.83529 10.5 6.69675 10.5559 6.58494 10.6677C6.47314 10.7795 6.41724 10.9181 6.41724 11.0834C6.41724 11.2486 6.47314 11.3872 6.58494 11.499C6.69675 11.6108 6.83529 11.6667 7.00057 11.6667ZM7.5839 7.00002C7.74918 7.00002 7.88772 6.94412 7.99953 6.83231C8.11133 6.72051 8.16724 6.58196 8.16724 6.41669C8.16724 6.25141 8.11133 6.11287 7.99953 6.00106C7.88772 5.88926 7.74918 5.83335 7.5839 5.83335C7.41862 5.83335 7.28008 5.88926 7.16828 6.00106C7.05647 6.11287 7.00057 6.25141 7.00057 6.41669C7.00057 6.58196 7.05647 6.72051 7.16828 6.83231C7.28008 6.94412 7.41862 7.00002 7.5839 7.00002ZM11.0839 4.08335C11.2492 4.08335 11.3877 4.02745 11.4995 3.91565C11.6113 3.80384 11.6672 3.6653 11.6672 3.50002C11.6672 3.33474 11.6113 3.1962 11.4995 3.0844C11.3877 2.97259 11.2492 2.91669 11.0839 2.91669C10.9186 2.91669 10.7801 2.97259 10.6683 3.0844C10.5565 3.1962 10.5006 3.33474 10.5006 3.50002C10.5006 3.6653 10.5565 3.80384 10.6683 3.91565C10.7801 4.02745 10.9186 4.08335 11.0839 4.08335Z"
fill="#737373"
className="fill-[#737373] group-hover:fill-white group-data-[state=active]:fill-white"
/>
</g>
</svg>
Graph
<p className="group-hover:text-white group-data-[state=active]:text-white">Graph</p>
</TabsTrigger>
<TabsTrigger
value="list"
className={cn(
"rounded-full dark:data-[state=active]:bg-[#00173C]! dark:data-[state=active]:border-[#2261CA33]! px-4 py-4",
"group rounded-full dark:data-[state=active]:bg-[#00173C]! dark:data-[state=active]:border-[#2261CA33]! px-6 py-[7px] align-middle items-center",
)}
>
<svg
@ -225,14 +225,15 @@ export function GraphListMemories({
viewBox="0 0 10 12"
fill="none"
xmlns="http://www.w3.org/2000/svg"
className="w-3.5! h-3.5!"
>
<title>List</title>
<path
d="M0.00153996 1.78136H0.0032201C0.00332596 1.86499 0.0363955 1.94522 0.095258 2.00463C0.15412 2.06404 0.23403 2.09786 0.31766 2.09874L8.76792 2.09902C8.85189 2.09861 8.93229 2.06485 8.99154 2.00536C9.0508 1.94586 9.08411 1.86533 9.08418 1.78136H9.08558V0.3171C9.08539 0.23296 9.05185 0.152327 8.9923 0.0928833C8.93275 0.0334395 8.85206 3.68622e-05 8.76792 0H0.31766C0.233423 3.71008e-05 0.152646 0.0335166 0.0930814 0.0930814C0.0335167 0.152646 3.71008e-05 0.233423 0 0.31766C0 0.32312 0.00139988 0.3283 0.00167988 0.33376L0.00153996 1.78136ZM8.76778 4.49314H0.31766C0.233423 4.49318 0.152646 4.52666 0.0930814 4.58622C0.0335167 4.64579 3.71008e-05 4.72656 0 4.8108C0 4.81626 0.00139988 4.82144 0.00167988 4.8269V6.2745H0.00336002C0.00346588 6.35813 0.0365354 6.43836 0.0953979 6.49777C0.15426 6.55718 0.234171 6.591 0.3178 6.59188L8.76806 6.59216C8.85203 6.59175 8.93243 6.55799 8.99168 6.4985C9.05094 6.439 9.08425 6.35847 9.08432 6.2745H9.08572V4.81024C9.08553 4.72605 9.05195 4.64538 8.99234 4.58592C8.93273 4.52647 8.85197 4.4931 8.76778 4.49314ZM8.76778 8.98614H0.31766C0.233423 8.98618 0.152646 9.01966 0.0930814 9.07922C0.0335167 9.13879 3.71008e-05 9.21956 0 9.3038C0 9.30926 0.00139988 9.31444 0.00167988 9.3199V10.7675H0.00336002C0.00346588 10.8511 0.0365354 10.9314 0.0953979 10.9908C0.15426 11.0502 0.234171 11.084 0.3178 11.0849L8.76806 11.0852C8.85205 11.0848 8.93247 11.051 8.99173 10.9914C9.051 10.9319 9.08428 10.8514 9.08432 10.7674H9.08572V9.3031C9.0855 9.21894 9.0519 9.1383 8.99229 9.07887C8.93269 9.01945 8.85194 8.9861 8.76778 8.98614Z"
fill="#FAFAFA"
className="fill-[#737373] group-hover:fill-white group-data-[state=active]:fill-white"
/>
</svg>
List
<p className="group-hover:text-white group-data-[state=active]:text-white">List</p>
</TabsTrigger>
</TabsList>
</Tabs>

View file

@ -12,6 +12,8 @@ import { dmSansClassName } from "@/utils/fonts"
import { GraphListMemories, type MemoryEntry } from "./graph-list-memories"
import { PdfViewer } from "./content/pdf"
import { YoutubeVideo } from "./content/yt-video"
import { TweetContent } from "./content/tweet"
import { isTwitterUrl } from "@/utils/url-helpers"
type DocumentsResponse = z.infer<typeof DocumentsWithMemoriesResponseSchema>
type DocumentWithMemories = DocumentsResponse["documents"][0]
@ -32,7 +34,7 @@ export function DocumentModal({
<Dialog open={isOpen} onOpenChange={(open) => !open && onClose()}>
<DialogContent
className={cn(
"w-[1158px]! h-[684px]! max-w-none! sm:max-w-none! p-0 border-none bg-[#1B1F24] flex flex-col px-4 pt-3 pb-4 gap-3 rounded-[22px]",
"w-[80%]! max-w-[1158px]! h-[86%]! max-h-[684px]! p-0 border-none bg-[#1B1F24] flex flex-col px-4 pt-3 pb-4 gap-3 rounded-[22px]",
dmSansClassName(),
)}
style={{
@ -45,9 +47,10 @@ export function DocumentModal({
<Title
title={_document?.title}
documentType={_document?.type ?? "text"}
url={_document?.url}
/>
<div className="flex items-center gap-2">
{_document?.type === "pdf" && _document.url && (
{_document?.url && (
<a
href={_document.url}
target="_blank"
@ -67,24 +70,39 @@ export function DocumentModal({
</DialogPrimitive.Close>
</div>
</div>
<div className="flex-1 grid grid-cols-[2fr_1fr] gap-3 overflow-hidden">
<div className="flex-1 grid grid-cols-[2fr_1fr] gap-3 overflow-hidden min-h-0">
<div
id="document-preview"
className={cn(
"bg-[#14161A] rounded-[14px] overflow-hidden flex flex-col shadow-[inset_0_2px_4px_rgba(0,0,0,0.3),inset_0_1px_2px_rgba(0,0,0,0.1)]",
)}
>
{_document?.type === "text" && (
<div className="p-4">{_document.content}</div>
{(_document?.type === "tweet" ||
(_document?.url && isTwitterUrl(_document.url))) && (
<TweetContent
url={_document?.url}
tweetMetadata={
_document?.metadata?.sm_internal_twitter_metadata
}
/>
)}
{_document?.type === "text" &&
!(_document?.url && isTwitterUrl(_document.url)) && (
<div className="p-4 overflow-y-auto flex-1">
{_document.content}
</div>
)}
{_document?.type === "pdf" && <PdfViewer url={_document.url} />}
{(_document?.url?.includes("youtube.com")) && (
{_document?.url?.includes("youtube.com") && (
<YoutubeVideo url={_document.url} />
)}
</div>
<div
id="document-memories-summary"
className={cn("gap-3 flex flex-col", dmSansClassName())}
className={cn(
"gap-3 flex flex-col overflow-hidden",
dmSansClassName(),
)}
>
{_document?.summary && (
<DocumentSummary

View file

@ -31,7 +31,7 @@ export function Summary({
return (
<div
id="document-summary"
className="bg-[#14161A] py-3 px-4 rounded-[14px] space-y-4 shadow-[inset_0_2px_4px_rgba(0,0,0,0.3),inset_0_1px_2px_rgba(0,0,0,0.1)]"
className="bg-[#14161A] p-3 rounded-[14px] space-y-4 shadow-[inset_0_2px_4px_rgba(0,0,0,0.3),inset_0_1px_2px_rgba(0,0,0,0.1)]"
>
<div className="flex items-center justify-between">
<p className="text-[16px] font-semibold text-[#FAFAFA] line-clamp-1 leading-[125%]">

View file

@ -18,9 +18,11 @@ function getFileExtension(documentType: DocumentType): string | null {
export function Title({
title,
documentType,
url,
}: {
title: string | null | undefined
documentType: DocumentType
url?: string | null
}) {
const extension = getFileExtension(documentType)
@ -31,8 +33,13 @@ export function Title({
"text-[16px] font-semibold text-[#FAFAFA] line-clamp-1 leading-[125%] flex items-center gap-3",
)}
>
<div className="pl-1 flex items-center gap-1">
{getDocumentIcon(documentType as DocumentType, "w-4 h-4 flex-shrink-0")}
<div className="pl-1 flex items-center gap-1 w-5 h-5">
{getDocumentIcon(
documentType as DocumentType,
"w-5 h-5",
undefined,
url ?? undefined,
)}
{extension && (
<p
className={cn(dmSansClassName(), "text-[12px] font-semibold")}