mirror of
https://github.com/supabase/supabase.git
synced 2026-06-14 05:06:27 +08:00
This PR migrates the whole monorepo to use Tailwind v4: - Removed `@tailwindcss/container-queries` plugin since it's included by default in v4, - Bump all instances of Tailwind to v4. Made minimal changes to the shared config to remove non-supported features (`alpha` mentions), - Migrate all apps to be compatible with v4 configs, - Fix the `typography.css` import in 3 apps, - Add missing rules which were included by default in v3, - Run `pnpm dlx @tailwindcss/upgrade` on all apps, which renames a lot of classes - Rename all misnamed classes according to https://tailwindcss.com/docs/upgrade-guide#renamed-utilities in all apps. --------- Co-authored-by: Jordi Enric <jordi.err@gmail.com>
92 lines
2.6 KiB
TypeScript
92 lines
2.6 KiB
TypeScript
import { UIMessage as VercelMessage } from '@ai-sdk/react'
|
|
import { type PropsWithChildren } from 'react'
|
|
import { cn } from 'ui'
|
|
|
|
import { useMessageInfoContext } from './Message.Context'
|
|
import { MessagePartSwitcher } from './Message.Parts'
|
|
import { MessageMarkdown } from './MessageMarkdown'
|
|
import { ProfileImage as ProfileImageDisplay } from '@/components/ui/ProfileImage'
|
|
import { useProfileNameAndPicture } from '@/lib/profile'
|
|
|
|
function MessageDisplayProfileImage() {
|
|
const { username, avatarUrl } = useProfileNameAndPicture()
|
|
return (
|
|
<ProfileImageDisplay
|
|
alt={username}
|
|
src={avatarUrl}
|
|
className="w-5 h-5 shrink-0 rounded-full translate-y-0.5"
|
|
/>
|
|
)
|
|
}
|
|
|
|
function MessageDisplayContainer({
|
|
children,
|
|
onClick,
|
|
className,
|
|
}: PropsWithChildren<{ onClick?: () => void; className?: string }>) {
|
|
return (
|
|
<div
|
|
className={cn('group text-foreground-light text-sm first:mt-0', className)}
|
|
onClick={onClick}
|
|
>
|
|
{children}
|
|
</div>
|
|
)
|
|
}
|
|
|
|
function MessageDisplayMainArea({
|
|
children,
|
|
className,
|
|
}: PropsWithChildren<{ className?: string }>) {
|
|
return <div className={cn('flex gap-4 w-auto overflow-hidden group', className)}>{children}</div>
|
|
}
|
|
|
|
function MessageDisplayContent({ message }: { message: VercelMessage }) {
|
|
const { id, isLoading, readOnly } = useMessageInfoContext()
|
|
|
|
const messageParts = message.parts
|
|
const content =
|
|
('content' in message && typeof message.content === 'string' && message.content.trim()) ||
|
|
undefined
|
|
|
|
return (
|
|
<div className="flex-1 min-w-0">
|
|
{messageParts?.length > 0
|
|
? messageParts.map((part: NonNullable<VercelMessage['parts'][number]>, idx) => {
|
|
const isLastPart = idx === messageParts.length - 1
|
|
return <MessagePartSwitcher key={idx} part={part} isLastPart={isLastPart} />
|
|
})
|
|
: content && (
|
|
<MessageDisplayTextMessage id={id} isLoading={isLoading} readOnly={readOnly}>
|
|
{content}
|
|
</MessageDisplayTextMessage>
|
|
)}
|
|
</div>
|
|
)
|
|
}
|
|
|
|
function MessageDisplayTextMessage({
|
|
id,
|
|
isLoading,
|
|
readOnly,
|
|
children,
|
|
}: PropsWithChildren<{ id: string; isLoading: boolean; readOnly?: boolean }>) {
|
|
return (
|
|
<MessageMarkdown
|
|
id={id}
|
|
isLoading={isLoading}
|
|
readOnly={readOnly}
|
|
className="prose prose-sm max-w-none wrap-break-word prose-h2:font-medium"
|
|
>
|
|
{children}
|
|
</MessageMarkdown>
|
|
)
|
|
}
|
|
|
|
export const MessageDisplay = {
|
|
Container: MessageDisplayContainer,
|
|
Content: MessageDisplayContent,
|
|
MainArea: MessageDisplayMainArea,
|
|
ProfileImage: MessageDisplayProfileImage,
|
|
}
|