Skip to content

armgit / Piik

Public Imported from GitHub
0

Free, open-source screen sharing for private live streams with friends. Watch together in a browser or self-host Piik. 免费开源的私密屏幕共享,支持游戏直播、一起看电影与自部署。

1.2 KB
Raw Blame
import { useRef } from "react";
import { locales } from "../../locales";
import { useCopy, type CopyKey } from "../../ui/copy";
import { useRotatingText } from "../../ui/use-text-rotation";
import { BrandLoader } from "./BrandMark";

const NO_CAPTIONS: readonly string[] = [];

/** Decoration beside a literal status; it never describes operation progress. */
export function WaitingCaption({ still = false }: { still?: boolean }) {
  const { lang, vis } = useCopy();
  const captionRef = useRef<HTMLSpanElement>(null);
  const line = useRotatingText(vis ? NO_CAPTIONS : locales[lang].playful.waiting,
    lang, { element: captionRef, still });
  if (!line) return null;
  return <span className="lr-waiting-caption" ref={captionRef} aria-hidden="true">
    <span key={line}>{line}</span>
  </span>;
}

export function LoadingStatus({ label, still = false, waitingCaption = false }: {
  label: CopyKey; still?: boolean; waitingCaption?: boolean;
}) {
  const { t, vis } = useCopy();
  return <div className="lr-loading" role="status" aria-label={t(label)}>
    <BrandLoader still={still} />
    {vis ? null : <span>{t(label)}</span>}
    {waitingCaption && <WaitingCaption still={still} />}
  </div>;
}