mirror of
https://github.com/stackblitz-labs/bolt.diy
synced 2025-02-02 19:14:54 +00:00
Merge pull request #565 from oTToDev-CE/ui/model-dropdown
ui: Update the model collapse button
This commit is contained in:
commit
95e38e020c
@ -369,21 +369,6 @@ export const BaseChat = React.forwardRef<HTMLDivElement, BaseChatProps>(
|
|||||||
<rect className={classNames(styles.PromptShine)} x="48" y="24" width="70" height="1"></rect>
|
<rect className={classNames(styles.PromptShine)} x="48" y="24" width="70" height="1"></rect>
|
||||||
</svg>
|
</svg>
|
||||||
<div>
|
<div>
|
||||||
<div className="flex justify-between items-center mb-2">
|
|
||||||
<button
|
|
||||||
onClick={() => setIsModelSettingsCollapsed(!isModelSettingsCollapsed)}
|
|
||||||
className={classNames('flex items-center gap-2 p-2 rounded-lg transition-all', {
|
|
||||||
'bg-bolt-elements-item-backgroundAccent text-bolt-elements-item-contentAccent':
|
|
||||||
isModelSettingsCollapsed,
|
|
||||||
'bg-bolt-elements-item-backgroundDefault text-bolt-elements-item-contentDefault':
|
|
||||||
!isModelSettingsCollapsed,
|
|
||||||
})}
|
|
||||||
>
|
|
||||||
<div className={`i-ph:caret-${isModelSettingsCollapsed ? 'right' : 'down'} text-lg`} />
|
|
||||||
<span>Model Settings</span>
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className={isModelSettingsCollapsed ? 'hidden' : ''}>
|
<div className={isModelSettingsCollapsed ? 'hidden' : ''}>
|
||||||
<ModelSelector
|
<ModelSelector
|
||||||
key={provider?.name + ':' + modelList.length}
|
key={provider?.name + ':' + modelList.length}
|
||||||
@ -491,6 +476,7 @@ export const BaseChat = React.forwardRef<HTMLDivElement, BaseChatProps>(
|
|||||||
<SendButton
|
<SendButton
|
||||||
show={input.length > 0 || isStreaming || uploadedFiles.length > 0}
|
show={input.length > 0 || isStreaming || uploadedFiles.length > 0}
|
||||||
isStreaming={isStreaming}
|
isStreaming={isStreaming}
|
||||||
|
disabled={enabledProviders.length === 0}
|
||||||
onClick={(event) => {
|
onClick={(event) => {
|
||||||
if (isStreaming) {
|
if (isStreaming) {
|
||||||
handleStop?.();
|
handleStop?.();
|
||||||
@ -541,6 +527,20 @@ export const BaseChat = React.forwardRef<HTMLDivElement, BaseChatProps>(
|
|||||||
disabled={isStreaming}
|
disabled={isStreaming}
|
||||||
/>
|
/>
|
||||||
{chatStarted && <ClientOnly>{() => <ExportChatButton exportChat={exportChat} />}</ClientOnly>}
|
{chatStarted && <ClientOnly>{() => <ExportChatButton exportChat={exportChat} />}</ClientOnly>}
|
||||||
|
<IconButton
|
||||||
|
title="Model Settings"
|
||||||
|
className={classNames('transition-all flex items-center gap-1', {
|
||||||
|
'bg-bolt-elements-item-backgroundAccent text-bolt-elements-item-contentAccent':
|
||||||
|
isModelSettingsCollapsed,
|
||||||
|
'bg-bolt-elements-item-backgroundDefault text-bolt-elements-item-contentDefault':
|
||||||
|
!isModelSettingsCollapsed,
|
||||||
|
})}
|
||||||
|
onClick={() => setIsModelSettingsCollapsed(!isModelSettingsCollapsed)}
|
||||||
|
disabled={enabledProviders.length === 0}
|
||||||
|
>
|
||||||
|
<div className={`i-ph:caret-${isModelSettingsCollapsed ? 'right' : 'down'} text-lg`} />
|
||||||
|
{isModelSettingsCollapsed ? <span className="text-xs">{model}</span> : <span />}
|
||||||
|
</IconButton>
|
||||||
</div>
|
</div>
|
||||||
{input.length > 3 ? (
|
{input.length > 3 ? (
|
||||||
<div className="text-xs text-bolt-elements-textTertiary">
|
<div className="text-xs text-bolt-elements-textTertiary">
|
||||||
|
@ -3,25 +3,29 @@ import { AnimatePresence, cubicBezier, motion } from 'framer-motion';
|
|||||||
interface SendButtonProps {
|
interface SendButtonProps {
|
||||||
show: boolean;
|
show: boolean;
|
||||||
isStreaming?: boolean;
|
isStreaming?: boolean;
|
||||||
|
disabled?: boolean;
|
||||||
onClick?: (event: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void;
|
onClick?: (event: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void;
|
||||||
onImagesSelected?: (images: File[]) => void;
|
onImagesSelected?: (images: File[]) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
const customEasingFn = cubicBezier(0.4, 0, 0.2, 1);
|
const customEasingFn = cubicBezier(0.4, 0, 0.2, 1);
|
||||||
|
|
||||||
export const SendButton = ({ show, isStreaming, onClick }: SendButtonProps) => {
|
export const SendButton = ({ show, isStreaming, disabled, onClick }: SendButtonProps) => {
|
||||||
return (
|
return (
|
||||||
<AnimatePresence>
|
<AnimatePresence>
|
||||||
{show ? (
|
{show ? (
|
||||||
<motion.button
|
<motion.button
|
||||||
className="absolute flex justify-center items-center top-[18px] right-[22px] p-1 bg-accent-500 hover:brightness-94 color-white rounded-md w-[34px] h-[34px] transition-theme"
|
className="absolute flex justify-center items-center top-[18px] right-[22px] p-1 bg-accent-500 hover:brightness-94 color-white rounded-md w-[34px] h-[34px] transition-theme disabled:opacity-50 disabled:cursor-not-allowed"
|
||||||
transition={{ ease: customEasingFn, duration: 0.17 }}
|
transition={{ ease: customEasingFn, duration: 0.17 }}
|
||||||
initial={{ opacity: 0, y: 10 }}
|
initial={{ opacity: 0, y: 10 }}
|
||||||
animate={{ opacity: 1, y: 0 }}
|
animate={{ opacity: 1, y: 0 }}
|
||||||
exit={{ opacity: 0, y: 10 }}
|
exit={{ opacity: 0, y: 10 }}
|
||||||
|
disabled={disabled}
|
||||||
onClick={(event) => {
|
onClick={(event) => {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
onClick?.(event);
|
if (!disabled) {
|
||||||
|
onClick?.(event);
|
||||||
|
}
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<div className="text-lg">
|
<div className="text-lg">
|
||||||
|
Loading…
Reference in New Issue
Block a user