ommit
Continuous Integration / build_web (push) Failing after 0s
Continuous Integration / build (macos-latest) (push) Skipped
Continuous Integration / build (ubuntu-22.04) (push) Skipped
Continuous Integration / build (windows-11-arm) (push) Skipped
Continuous Integration / build (windows-latest) (push) Skipped
Continuous Integration / nightly_release (push) Skipped
Continuous Integration / build_web (push) Failing after 0s
Continuous Integration / build (macos-latest) (push) Skipped
Continuous Integration / build (ubuntu-22.04) (push) Skipped
Continuous Integration / build (windows-11-arm) (push) Skipped
Continuous Integration / build (windows-latest) (push) Skipped
Continuous Integration / nightly_release (push) Skipped
This commit is contained in:
1 parent
cbb750a413
commit
497b9a2fc5
42 files changed
+945
-354
No files matched your search
@@ -0,0 +1,77 @@
|
||||
import { Tooltip } from "@mui/material";
|
||||
import { useLocation } from "@tanstack/react-router";
|
||||
import { AnimatePresence, motion } from "motion/react";
|
||||
import React from "react";
|
||||
import { shouldShowTitlebar } from "@/components/appTitlebar/routeVisibility";
|
||||
import {
|
||||
type AppStatusPhase,
|
||||
useAppStatusStore,
|
||||
} from "@/utils/store/appStatus";
|
||||
|
||||
import "./appStatus.scss";
|
||||
|
||||
const ICONS: Record<Exclude<AppStatusPhase, "idle" | "loading">, string> = {
|
||||
success: "check",
|
||||
warning: "warning",
|
||||
error: "warning",
|
||||
info: "info",
|
||||
};
|
||||
|
||||
export const AppStatusIndicator = ({
|
||||
floating = false,
|
||||
}: {
|
||||
floating?: boolean;
|
||||
}) => {
|
||||
const phase = useAppStatusStore((state) => state.phase);
|
||||
const message = useAppStatusStore((state) => state.message);
|
||||
|
||||
if (phase === "idle") {
|
||||
return floating ? null : (
|
||||
<span className="app-status app-status--idle" aria-hidden="true" />
|
||||
);
|
||||
}
|
||||
|
||||
const body = (
|
||||
<span
|
||||
className={`app-status app-status--${phase}${
|
||||
floating ? " app-status--floating" : ""
|
||||
}`}
|
||||
role="status"
|
||||
aria-live="polite"
|
||||
aria-label={message}
|
||||
>
|
||||
<AnimatePresence mode="wait" initial={false}>
|
||||
<motion.span
|
||||
key={phase}
|
||||
className="app-status__icon"
|
||||
initial={{ opacity: 0, scale: 0.55, rotate: -18 }}
|
||||
animate={{ opacity: 1, scale: 1, rotate: 0 }}
|
||||
exit={{ opacity: 0, scale: 0.55, rotate: 18 }}
|
||||
transition={{ type: "spring", stiffness: 520, damping: 30 }}
|
||||
>
|
||||
{phase === "loading" ? (
|
||||
<span className="app-status__spinner" />
|
||||
) : (
|
||||
<span className="material-symbols-rounded">{ICONS[phase]}</span>
|
||||
)}
|
||||
</motion.span>
|
||||
</AnimatePresence>
|
||||
</span>
|
||||
);
|
||||
|
||||
return (
|
||||
<Tooltip title={message} placement="bottom" arrow>
|
||||
{body}
|
||||
</Tooltip>
|
||||
);
|
||||
};
|
||||
|
||||
/** Shows the indicator over players/auth screens where the titlebar is hidden. */
|
||||
export const AppStatusOverlay = () => {
|
||||
const { pathname } = useLocation();
|
||||
if (shouldShowTitlebar(pathname)) return null;
|
||||
// The video player renders the indicator inside its own OSD action pill,
|
||||
// next to share / SyncPlay / settings, so no floating copy is needed.
|
||||
if (pathname === "/player") return null;
|
||||
return <AppStatusIndicator floating />;
|
||||
};
|
||||
Reference in new issue
Block a user