mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2024-11-22 01:36:29 -05:00
Extract loading screen compontent #69
This commit is contained in:
parent
f185c76c6e
commit
23cfcacd09
2 changed files with 28 additions and 16 deletions
|
@ -1,7 +1,6 @@
|
|||
import React, {Fragment, useEffect, useState} from "react";
|
||||
import {FontAwesomeIcon} from "@fortawesome/react-fontawesome";
|
||||
import "./application-loader.scss";
|
||||
import {Alert} from "react-bootstrap";
|
||||
import {LoadingScreen} from "./loading-screen";
|
||||
|
||||
interface ApplicationLoaderProps {
|
||||
initTasks: Promise<any>[]
|
||||
|
@ -28,17 +27,9 @@ export const ApplicationLoader: React.FC<ApplicationLoaderProps> = ({children, i
|
|||
})
|
||||
}, [initTasks]);
|
||||
|
||||
return (<Fragment>{
|
||||
doneTasks < initTasks.length || initTasks.length === 0 ? (
|
||||
<div className="loader middle">
|
||||
<div className="icon">
|
||||
<FontAwesomeIcon icon="file-alt" size="6x"
|
||||
className={failed ? "animation-shake" : "animation-pulse"}/>
|
||||
</div>
|
||||
{
|
||||
failed ? <Alert variant={"danger"}>An error occured while loading the application!</Alert> : null
|
||||
}
|
||||
</div>
|
||||
) : children
|
||||
}</Fragment>);
|
||||
return (
|
||||
doneTasks < initTasks.length || initTasks.length === 0 ?
|
||||
<LoadingScreen failed={failed}/> :
|
||||
<Fragment>{children}</Fragment>
|
||||
);
|
||||
}
|
21
src/components/application-loader/loading-screen.tsx
Normal file
21
src/components/application-loader/loading-screen.tsx
Normal file
|
@ -0,0 +1,21 @@
|
|||
import React from "react";
|
||||
import {FontAwesomeIcon} from "@fortawesome/react-fontawesome";
|
||||
import {Alert} from "react-bootstrap";
|
||||
|
||||
export interface LoadingScreenProps {
|
||||
failed: boolean
|
||||
}
|
||||
|
||||
export const LoadingScreen: React.FC<LoadingScreenProps> = ({failed}) => {
|
||||
return (
|
||||
<div className="loader middle">
|
||||
<div className="icon">
|
||||
<FontAwesomeIcon icon="file-alt" size="6x"
|
||||
className={failed ? "animation-shake" : "animation-pulse"}/>
|
||||
</div>
|
||||
{
|
||||
failed ? <Alert variant={"danger"}>An error occured while loading the application!</Alert> : null
|
||||
}
|
||||
</div>
|
||||
)
|
||||
}
|
Loading…
Reference in a new issue