All files / src/components/docpane FallbackPreview.tsx

0% Statements 0/1
0% Branches 0/4
0% Functions 0/1
0% Lines 0/1

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31                                                             
import type { JSX } from "react";
import { FileQuestion, FileX } from "lucide-react";
import styles from "./DocPane.module.scss";
 
/** Props for {@link FallbackPreview}. */
export interface FallbackPreviewProps {
  /** The file URI being previewed. */
  uri: string;
  /** When true, the file was deleted (vs. an unsupported type). */
  deleted?: boolean;
}
 
/**
 * Placeholder shown when a tab's file can't be rendered inline (#1396): a binary
 * or otherwise unsupported type (rich/binary previews are deferred to #1428), or
 * a file that no longer exists. Keeps the tab open without breaking the pane.
 */
export function FallbackPreview({ uri, deleted }: FallbackPreviewProps): JSX.Element {
  return (
    <div className={styles.fallback} data-testid="doc-fallback">
      {deleted ? <FileX aria-hidden /> : <FileQuestion aria-hidden />}
      <p className={styles.fallbackMessage}>
        {deleted
          ? "This file no longer exists."
          : "No inline preview is available for this file type."}
      </p>
      <code className={styles.fallbackPath}>{uri}</code>
    </div>
  );
}