parent
0cf93e7aa0
commit
ee7a948a78
@ -0,0 +1,23 @@
|
||||
/*
|
||||
* UnitCommitment.jl: Optimization Package for Security-Constrained Unit Commitment
|
||||
* Copyright (C) 2020-2025, UChicago Argonne, LLC. All rights reserved.
|
||||
* Released under the modified BSD license. See COPYING.md for more details.
|
||||
*/
|
||||
|
||||
.Toast {
|
||||
width: 600px;
|
||||
border-radius: var(--border-radius);
|
||||
box-shadow: 4px 4px 16px -2px rgba(0, 0, 0, 0.5);
|
||||
margin: 0 auto;
|
||||
background-color: #424242;
|
||||
color: white;
|
||||
padding: 0 16px;
|
||||
position: fixed;
|
||||
top: 48px;
|
||||
left: 50%;
|
||||
transform: translate(-50%, 0);
|
||||
transition: opacity 0.5s ease;
|
||||
cursor: default;
|
||||
font-size: 15px;
|
||||
line-height: 48px;
|
||||
}
|
@ -0,0 +1,35 @@
|
||||
/*
|
||||
* UnitCommitment.jl: Optimization Package for Security-Constrained Unit Commitment
|
||||
* Copyright (C) 2020-2025, UChicago Argonne, LLC. All rights reserved.
|
||||
* Released under the modified BSD license. See COPYING.md for more details.
|
||||
*/
|
||||
|
||||
import styles from "./Toast.module.css";
|
||||
import { useEffect, useState } from "react";
|
||||
|
||||
interface ToastProps {
|
||||
message: string;
|
||||
}
|
||||
|
||||
const Toast = (props: ToastProps) => {
|
||||
const [isVisible, setVisible] = useState(true);
|
||||
|
||||
useEffect(() => {
|
||||
if (props.message.length === 0) return;
|
||||
setVisible(true);
|
||||
const timer = setTimeout(() => {
|
||||
setVisible(false);
|
||||
}, 5000);
|
||||
return () => clearTimeout(timer);
|
||||
}, [props.message]);
|
||||
|
||||
return (
|
||||
<div>
|
||||
<div className={styles.Toast} style={{ opacity: isVisible ? 1 : 0 }}>
|
||||
{props.message}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default Toast;
|
Loading…
Reference in new issue