Skip to content

Commit 53e89a1

Browse files
author
pengyu
committed
adjust the ui for magic enhance
1 parent 4c93b93 commit 53e89a1

File tree

2 files changed

+47
-11
lines changed

2 files changed

+47
-11
lines changed

frontend/src/app/globals.css

+9
Original file line numberDiff line numberDiff line change
@@ -163,3 +163,12 @@
163163
opacity: 0.85;
164164
}
165165
}
166+
167+
.button-no-border {
168+
@apply !border-none !outline-none !shadow-none;
169+
}
170+
.button-no-border:hover,
171+
.button-no-border:focus,
172+
.button-no-border:active {
173+
@apply !border-none !outline-none !shadow-none !ring-0;
174+
}

frontend/src/components/root/prompt-form.tsx

+38-11
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import { Button } from '@/components/ui/button';
3030
import { cn } from '@/lib/utils';
3131
import { useModels } from '@/hooks/useModels';
3232
import { gql, useMutation } from '@apollo/client';
33+
import { useTheme } from 'next-themes'; // 导入 useTheme
3334

3435
export interface PromptFormRef {
3536
getPromptData: () => {
@@ -69,6 +70,11 @@ export const PromptForm = forwardRef<PromptFormRef, PromptFormProps>(
6970
// State for regeneration loading
7071
const [isRegenerating, setIsRegenerating] = useState(false);
7172

73+
// 使用 useTheme 钩子获取当前主题
74+
const { theme } = useTheme();
75+
// 检查是否为暗色模式
76+
const isDarkMode = theme === 'dark';
77+
7278
const {
7379
selectedModel,
7480
setSelectedModel,
@@ -176,7 +182,7 @@ export const PromptForm = forwardRef<PromptFormRef, PromptFormProps>(
176182
.pauseFor(10)
177183
.deleteAll()
178184
.start();
179-
}
185+
};
180186

181187
return (
182188
<div className="relative w-full max-w-2xl mx-auto">
@@ -282,25 +288,46 @@ export const PromptForm = forwardRef<PromptFormRef, PromptFormProps>(
282288
<TooltipProvider>
283289
<Tooltip>
284290
<TooltipTrigger asChild>
285-
<Button
286-
variant="ghost"
287-
size="icon"
291+
<div
292+
onClick={
293+
!isLoading && !isRegenerating
294+
? handleMagicEnhance
295+
: undefined
296+
}
288297
className={cn(
289-
'rounded-full p-6 transition-all',
298+
'flex items-center justify-center w-12 h-12 rounded-full p-2 cursor-pointer transition-all',
299+
'focus:outline-none focus:ring-0 focus:border-0',
300+
'active:outline-none active:ring-0 active:border-0',
290301
isEnhanced
291-
? 'bg-amber-500/20 text-amber-500 hover:bg-amber-500/30 hover:text-amber-600'
292-
: 'text-gray-500 hover:text-amber-500',
302+
? isDarkMode
303+
? 'text-blue-700 hover:text-blue-700'
304+
: 'text-yellow-300 hover:text-yellow-300'
305+
: 'text-gray-500 hover:text-gray-500',
293306
(isLoading || isRegenerating) &&
294307
'opacity-50 cursor-not-allowed'
295308
)}
296-
onClick={handleMagicEnhance}
297-
disabled={isLoading || isRegenerating}
309+
style={{
310+
border: 'none',
311+
outline: 'none',
312+
boxShadow: 'none',
313+
WebkitTapHighlightColor: 'transparent',
314+
WebkitAppearance: 'none',
315+
MozAppearance: 'none',
316+
WebkitUserSelect: 'none',
317+
userSelect: 'none',
318+
}}
319+
tabIndex={-1}
320+
onMouseDown={(e) => e.preventDefault()}
321+
onMouseUp={(e) => e.preventDefault()}
298322
>
299323
<Sparkles
300324
size={36}
301-
className={cn("!w-6 !h-6", isRegenerating && 'animate-spin')}
325+
className={cn(
326+
'w-6 h-6',
327+
isRegenerating && 'animate-spin'
328+
)}
302329
/>
303-
</Button>
330+
</div>
304331
</TooltipTrigger>
305332
<TooltipContent side="bottom">
306333
<p>

0 commit comments

Comments
 (0)