An open-source, self-hosted system for apps built with web technologies.
import { Spinner, Surface, type SurfaceProps } from "@phreshos/react-ui"
type LoadingProps = Omit<SurfaceProps, "material">
/**
* A complete loading surface for unresolved content. It hides what is beneath it, so it is opaque
* whatever the Appearance's opacity.
*/
export default function ({ className, style, children, ...props }: LoadingProps) {
const described = children !== undefined
return <Surface
{...props}
material="opaque"
className={`inset-0 z-10 grid ${className ?? ""}`}
style={{ ...style, position: "absolute", borderRadius: style?.borderRadius ?? "inherit" }}
>
<div className="m-auto grid justify-items-center gap-3" role={described ? "status" : undefined}>
{described ? <Spinner decorative /> : <Spinner label="Loading" />}
{described && <span data-loading-message className="text-sm opacity-60">{children}</span>}
</div>
</Surface>
}