-
-
Notifications
You must be signed in to change notification settings - Fork 303
/
FileNotFound.tsx
50 lines (47 loc) · 1.43 KB
/
FileNotFound.tsx
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import React, { FC } from "react";
import { Text, TextContainer } from "@react-md/typography";
import { List, ListItem } from "@react-md/list";
import { IFiles } from "codesandbox-import-utils/lib/api/define";
import { bem } from "@react-md/theme";
import Code from "components/Code/Code";
import { Card, CardHeader, CardTitle, CardContent } from "@react-md/card";
export interface FileNotFoundProps {
fileName: string;
sandbox: IFiles | null;
offset: boolean;
onFileChange: (fileName: string) => void;
}
const block = bem("sandbox-modal");
const FileNotFound: FC<FileNotFoundProps> = ({
offset,
fileName,
onFileChange,
sandbox,
}) => {
return (
<div className={block("error", { offset })}>
<TextContainer>
<Text color="theme-error" type="headline-4">
Unable to find a file with a file name of: <Code>{fileName}</Code>
</Text>
{sandbox && (
<Card>
<CardHeader>
<CardTitle>Did you mean one of:</CardTitle>
</CardHeader>
<CardContent>
<List className={block("error-list")}>
{Object.keys(sandbox).map(name => (
<ListItem key={name} onClick={() => onFileChange(name)}>
{name}
</ListItem>
))}
</List>
</CardContent>
</Card>
)}
</TextContainer>
</div>
);
};
export default FileNotFound;