Refine add transaction button

The add transaction button is too large initially. This commit changes the button to display fully for 3 seconds, then transition to a smaller "+" icon button.
This commit is contained in:
gpt-engineer-app[bot]
2025-03-22 06:41:04 +00:00
parent c57d56820f
commit e0d4cf61c7

View File

@@ -1,5 +1,5 @@
import React, { useState } from 'react'; import React, { useState, useEffect } from 'react';
import { PlusIcon } from 'lucide-react'; import { PlusIcon } from 'lucide-react';
import { Dialog, DialogContent, DialogHeader, DialogTitle } from './ui/dialog'; import { Dialog, DialogContent, DialogHeader, DialogTitle } from './ui/dialog';
import { toast } from '@/hooks/useToast.wrapper'; // 래퍼 사용 import { toast } from '@/hooks/useToast.wrapper'; // 래퍼 사용
@@ -14,9 +14,19 @@ import useNotifications from '@/hooks/useNotifications';
const AddTransactionButton = () => { const AddTransactionButton = () => {
const [showExpenseDialog, setShowExpenseDialog] = useState(false); const [showExpenseDialog, setShowExpenseDialog] = useState(false);
const [isSubmitting, setIsSubmitting] = useState(false); const [isSubmitting, setIsSubmitting] = useState(false);
const [showText, setShowText] = useState(true);
const { addTransaction } = useBudget(); const { addTransaction } = useBudget();
const { addNotification } = useNotifications(); const { addNotification } = useNotifications();
// 3초 후에 텍스트 숨기기
useEffect(() => {
const timer = setTimeout(() => {
setShowText(false);
}, 3000);
return () => clearTimeout(timer);
}, []);
// Format number with commas // Format number with commas
const formatWithCommas = (value: string): string => { const formatWithCommas = (value: string): string => {
// Remove commas first to avoid duplicates when typing // Remove commas first to avoid duplicates when typing
@@ -128,13 +138,15 @@ const AddTransactionButton = () => {
<> <>
<div className="fixed bottom-24 right-6 z-20"> <div className="fixed bottom-24 right-6 z-20">
<button <button
className="flex items-center gap-2 px-4 py-3 rounded-full transition-all duration-300 bg-neuro-income shadow-neuro-flat hover:shadow-neuro-convex text-white animate-pulse-subtle" className={`transition-all duration-300 bg-neuro-income shadow-neuro-flat hover:shadow-neuro-convex text-white animate-pulse-subtle ${
showText ? 'flex items-center gap-2 px-4 py-3 rounded-full' : 'p-4 rounded-full'
}`}
onClick={() => setShowExpenseDialog(true)} onClick={() => setShowExpenseDialog(true)}
aria-label="지출 추가" aria-label="지출 추가"
disabled={isSubmitting} disabled={isSubmitting}
> >
<PlusIcon size={20} /> <PlusIcon size={showText ? 20 : 24} />
<span className="mr-1"> </span> {showText && <span className="mr-1"> </span>}
</button> </button>
</div> </div>