({
loadingMessage = "Loading...",
completedMessage,
isLoading = true,
}: LoadingIndicatorProps)
| 9 | } |
| 10 | |
| 11 | export function LoadingIndicator({ |
| 12 | loadingMessage = "Loading...", |
| 13 | completedMessage, |
| 14 | isLoading = true, |
| 15 | }: LoadingIndicatorProps) { |
| 16 | // Adding the `.completed-message` class will delay the fade-out for 1s to |
| 17 | // allow the user to see the updated message before it disappears. |
| 18 | const showCompletedMessage = completedMessage ? "completed-message " : ""; |
| 19 | const timeout = completedMessage ? 2000 : 1000; |
| 20 | |
| 21 | return ( |
| 22 | <CSSTransition |
| 23 | in={isLoading} |
| 24 | timeout={timeout} |
| 25 | classNames="LoadingContainer" |
| 26 | unmountOnExit |
| 27 | > |
| 28 | <div className={`${showCompletedMessage}LoadingContainer`}> |
| 29 | <div className="LoadingContainerContent"> |
| 30 | <h2> |
| 31 | {isLoading ? loadingMessage : completedMessage ?? loadingMessage} |
| 32 | </h2> |
| 33 | </div> |
| 34 | </div> |
| 35 | </CSSTransition> |
| 36 | ); |
| 37 | } |
nothing calls this directly
no outgoing calls
no test coverage detected