mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-12-03 06:24:30 +00:00
style(chatbot): move send button inside input border area to match comment input design
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
import { useEffect, useRef, useState } from 'react'
|
import { useEffect, useRef, useState } from 'react'
|
||||||
import { useDroppable } from '@dnd-kit/react'
|
import { useDroppable } from '@dnd-kit/react'
|
||||||
import { useChatbotStore } from '@/ui/stores/chatbot'
|
import { useChatbotStore } from '@/ui/stores/chatbot'
|
||||||
import { Bot, Send, History, Plus, Trash2, Loader2, ArrowLeft } from 'lucide-react'
|
import { Bot, ArrowUp, History, Plus, Trash2, Loader2, ArrowLeft } from 'lucide-react'
|
||||||
import { cn } from '@/ui/lib/utils'
|
import { cn } from '@/ui/lib/utils'
|
||||||
import { m } from '@/ui/paraglide/messages.js'
|
import { m } from '@/ui/paraglide/messages.js'
|
||||||
import { ScrollArea } from '@/ui/components/ui/scroll-area'
|
import { ScrollArea } from '@/ui/components/ui/scroll-area'
|
||||||
@@ -269,51 +269,61 @@ export function ChatbotSidebar({ projectId, contextAssetId }: ChatbotSidebarProp
|
|||||||
)}
|
)}
|
||||||
</ScrollArea>
|
</ScrollArea>
|
||||||
|
|
||||||
{/* Context assets above input area */}
|
{/* Input Area (nested inside the border exactly like comment input) */}
|
||||||
<div className="p-4 border-t border-border flex-shrink-0 bg-background flex flex-col gap-2 min-h-0">
|
<div className="p-4 border-t border-border flex-shrink-0 bg-background">
|
||||||
{chatAssets.length > 0 && (
|
<div className="relative flex flex-col w-full border border-foreground/20 rounded-2xl shadow-xs transition-all duration-200 focus-within:ring-2 focus-within:ring-primary focus-within:border-transparent bg-background overflow-hidden">
|
||||||
<div className="flex flex-col gap-1.5 min-h-0 max-h-[160px] overflow-y-auto border border-border rounded-md bg-muted/10 p-2 divide-y divide-border/50">
|
{/* Context assets list at the top inside the border */}
|
||||||
{chatAssets.map((asset) => (
|
{chatAssets.length > 0 && (
|
||||||
<div
|
<div className="flex flex-col gap-1.5 min-h-0 max-h-[160px] overflow-y-auto border-b border-border bg-muted/5 p-3 divide-y divide-border/50">
|
||||||
key={asset.id}
|
{chatAssets.map((asset) => (
|
||||||
className="flex items-center justify-between py-1.5 text-xs group"
|
<div
|
||||||
>
|
key={asset.id}
|
||||||
<div className="flex items-baseline gap-1.5 min-w-0 pr-2">
|
className="flex items-center justify-between py-1.5 text-xs group"
|
||||||
<span className="truncate font-medium text-foreground">{asset.name}</span>
|
|
||||||
<span className="text-[9px] text-muted-foreground uppercase flex-shrink-0">
|
|
||||||
{asset.type}
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
<button
|
|
||||||
onClick={() => removeAsset(asset.id)}
|
|
||||||
className="text-muted-foreground hover:text-destructive transition-colors p-0.5"
|
|
||||||
title={m.remove_from_context()}
|
|
||||||
>
|
>
|
||||||
<Trash2 className="h-3.5 w-3.5" />
|
<div className="flex items-baseline gap-1.5 min-w-0 pr-2">
|
||||||
</button>
|
<span className="truncate font-medium text-foreground">{asset.name}</span>
|
||||||
</div>
|
<span className="text-[9px] text-muted-foreground uppercase flex-shrink-0">
|
||||||
))}
|
{asset.type}
|
||||||
</div>
|
</span>
|
||||||
)}
|
</div>
|
||||||
|
<button
|
||||||
|
onClick={() => removeAsset(asset.id)}
|
||||||
|
className="text-muted-foreground hover:text-destructive transition-colors p-0.5"
|
||||||
|
title={m.remove_from_context()}
|
||||||
|
>
|
||||||
|
<Trash2 className="h-3.5 w-3.5" />
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
{/* Input area */}
|
{/* Textarea inside the border */}
|
||||||
<div className="flex items-end gap-2">
|
|
||||||
<textarea
|
<textarea
|
||||||
value={inputText}
|
value={inputText}
|
||||||
onChange={(e) => setInputText(e.target.value)}
|
onChange={(e) => setInputText(e.target.value)}
|
||||||
onKeyDown={handleKeyDown}
|
onKeyDown={handleKeyDown}
|
||||||
placeholder="Type a message..."
|
placeholder="Type a message..."
|
||||||
rows={2}
|
rows={2}
|
||||||
className="flex-1 min-h-[44px] max-h-[120px] rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 resize-none"
|
className="w-full bg-transparent border-none focus:ring-0 focus:outline-hidden resize-none min-h-[44px] max-h-[120px] px-3 py-2 text-sm focus-visible:outline-hidden focus:ring-transparent focus:border-transparent focus-visible:ring-0"
|
||||||
disabled={isStreaming}
|
disabled={isStreaming}
|
||||||
/>
|
/>
|
||||||
<button
|
|
||||||
onClick={handleSend}
|
{/* Bottom row inside the border containing the send button */}
|
||||||
disabled={isStreaming || !inputText.trim()}
|
<div className="flex justify-end items-center px-3 pb-2 pt-1">
|
||||||
className="h-9 w-9 flex items-center justify-center rounded-md bg-primary text-primary-foreground hover:bg-primary/90 transition-colors disabled:opacity-50 disabled:cursor-not-allowed flex-shrink-0 shadow-sm"
|
<button
|
||||||
>
|
onClick={handleSend}
|
||||||
<Send className="h-4 w-4" />
|
disabled={isStreaming || !inputText.trim()}
|
||||||
</button>
|
className={cn(
|
||||||
|
'p-2 rounded-full transition-all duration-200 flex items-center justify-center shrink-0 shadow-sm',
|
||||||
|
inputText.trim() && !isStreaming
|
||||||
|
? 'bg-primary text-primary-foreground hover:bg-primary/95 transform hover:-translate-y-0.5'
|
||||||
|
: 'bg-muted text-muted-foreground cursor-not-allowed opacity-50',
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
<ArrowUp className="h-4 w-4" />
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
|
|||||||
Reference in New Issue
Block a user