v2.9.0: Улучшения экрана списка задач - оптимизация загрузки, toast уведомления, исправление центрирования
Some checks failed
Build and Push Docker Image / build-and-push (push) Failing after 44s
Some checks failed
Build and Push Docker Image / build-and-push (push) Failing after 44s
This commit is contained in:
30
play-life-web/src/components/Toast.jsx
Normal file
30
play-life-web/src/components/Toast.jsx
Normal file
@@ -0,0 +1,30 @@
|
||||
import React, { useEffect, useState } from 'react'
|
||||
import './Toast.css'
|
||||
|
||||
function Toast({ message, onClose, duration = 3000 }) {
|
||||
const [isVisible, setIsVisible] = useState(true)
|
||||
|
||||
useEffect(() => {
|
||||
const timer = setTimeout(() => {
|
||||
setIsVisible(false)
|
||||
setTimeout(() => {
|
||||
onClose?.()
|
||||
}, 300) // Ждем завершения анимации
|
||||
}, duration)
|
||||
|
||||
return () => clearTimeout(timer)
|
||||
}, [duration, onClose])
|
||||
|
||||
if (!isVisible) return null
|
||||
|
||||
return (
|
||||
<div className={`toast ${isVisible ? 'toast-visible' : ''}`}>
|
||||
<div className="toast-content">
|
||||
<span className="toast-message">{message}</span>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default Toast
|
||||
|
||||
Reference in New Issue
Block a user