feat(frontend): add loading animation
This commit is contained in:
parent
3e249a47b1
commit
5e5b2fda5f
@ -182,3 +182,30 @@ a.secondary {
|
|||||||
filter: invert();
|
filter: invert();
|
||||||
}
|
}
|
||||||
} */
|
} */
|
||||||
|
|
||||||
|
/* HTML: <div class="loader"></div> */
|
||||||
|
.loader {
|
||||||
|
width: 65px;
|
||||||
|
height: 30px;
|
||||||
|
position: relative;
|
||||||
|
display: none;
|
||||||
|
margin: 25px auto;
|
||||||
|
}
|
||||||
|
.loader:before {
|
||||||
|
content: "";
|
||||||
|
position: absolute;
|
||||||
|
border-radius: 50px;
|
||||||
|
box-shadow: 0 0 0 3px inset #fff;
|
||||||
|
animation: l3 0.75s infinite alternate;
|
||||||
|
}
|
||||||
|
@keyframes l3 {
|
||||||
|
0% {
|
||||||
|
inset: 0 35px 0 0;
|
||||||
|
}
|
||||||
|
50% {
|
||||||
|
inset: 0 0 0 0;
|
||||||
|
}
|
||||||
|
100% {
|
||||||
|
inset: 0 0 0 35px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -6,6 +6,7 @@ import styles from "../../page.module.css";
|
|||||||
export function SimCurrentGear() {
|
export function SimCurrentGear() {
|
||||||
const [isFetched, setIsFetched] = useState(false);
|
const [isFetched, setIsFetched] = useState(false);
|
||||||
const [fetchedData, setFetchedData] = useState("");
|
const [fetchedData, setFetchedData] = useState("");
|
||||||
|
const [isLoading, setIsLoading] = useState(false);
|
||||||
|
|
||||||
async function fetchSimResult(formData: FormData) {
|
async function fetchSimResult(formData: FormData) {
|
||||||
try {
|
try {
|
||||||
@ -35,6 +36,12 @@ export function SimCurrentGear() {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
|
<div
|
||||||
|
className={styles.loader}
|
||||||
|
style={{
|
||||||
|
display: `${isLoading && !isFetched ? "block" : "none"}`,
|
||||||
|
}}
|
||||||
|
></div>
|
||||||
<iframe
|
<iframe
|
||||||
id="renderframe"
|
id="renderframe"
|
||||||
style={{
|
style={{
|
||||||
@ -53,12 +60,16 @@ export function SimCurrentGear() {
|
|||||||
id="simcprofile"
|
id="simcprofile"
|
||||||
name="simcprofile"
|
name="simcprofile"
|
||||||
style={{
|
style={{
|
||||||
display: `${isFetched ? "none" : "block"}`,
|
display: `${isLoading ? "none" : "block"}`,
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div className={styles.ctas}>
|
<div className={styles.ctas}>
|
||||||
<button className={styles.primary} type="submit">
|
<button
|
||||||
|
className={styles.primary}
|
||||||
|
type="submit"
|
||||||
|
onClick={() => setIsLoading(true)}
|
||||||
|
>
|
||||||
Run Sim
|
Run Sim
|
||||||
</button>
|
</button>
|
||||||
<a
|
<a
|
||||||
|
Loading…
x
Reference in New Issue
Block a user