1
Fork 0
mirror of https://github.com/Steffo99/festa.git synced 2024-10-16 15:07:27 +00:00
festa/components/generic/loading/renderers.tsx

62 lines
No EOL
1.6 KiB
TypeScript

import { faAsterisk } from "@fortawesome/free-solid-svg-icons";
import classNames from "classnames";
import { memo } from "react";
import { FestaIcon } from "../renderers/fontawesome";
import style from "./renderers.module.css"
/**
* Props for "loading" renderers, such as {@link LoadingInline} and {@link LoadingMain}.
*/
export type LoadingProps = {
text?: string
}
/**
* Inline component displaying an animated loading icon with an optional message displayed on the right.
*
* @see {@link ErrorInline}
*/
export const LoadingInline = memo(({ text }: LoadingProps) => {
return (
<span className={classNames(style.loading, style.loadingInline)}>
<FestaIcon
icon={faAsterisk}
spin
className={style.loadingIcon}
/>
{!!text && <>
&nbsp;
<span className={style.loadingText}>
{text}
</span>
</>}
</span>
)
})
LoadingInline.displayName = "LoadingInline"
/**
* Block component displaying a big loading icon with an optional message displayed below.
*
* @see {@link ErrorMain}
*/
export const LoadingMain = memo(({ text }: LoadingProps) => {
return (
<div className={classNames(style.loading, style.loadingMain)}>
<FestaIcon
icon={faAsterisk}
spin
className={style.loadingIcon}
/>
{!!text &&
<p className={style.loadingText}>
{text}
</p>
}
</div>
)
})
LoadingMain.displayName = "LoadingMain"