MCPcopy Create free account
hub / github.com/triggerdotdev/jsonhero-web / PreviewString

Function PreviewString

app/components/Preview/Types/PreviewString.tsx:16–79  ·  view source on GitHub ↗
({ info }: { info: JSONStringType })

Source from the content-addressed store, hash-verified

14import { PreviewVideoUri } from "./PreviewVideoUri";
15
16export function PreviewString({ info }: { info: JSONStringType }) {
17 if (info.format == null) {
18 return <></>;
19 }
20
21 switch (info.format.name) {
22 case "uri":
23 if (
24 info.format.contentType === "image/png" ||
25 info.format.contentType === "image/jpeg" ||
26 info.format.contentType === "image/gif" ||
27 info.format.contentType === "image/svg+xml" ||
28 info.format.contentType === "image/webp"
29 ) {
30 const url = new URL(info.value);
31
32 if (url.protocol === "ipfs:") {
33 return <PreviewIPFSImage src={url} />;
34 } else {
35 return (
36 <PreviewImageUri
37 src={info.value}
38 contentType={info.format.contentType}
39 />
40 );
41 }
42 } else if (
43 info.format.contentType === "video/mp4" ||
44 info.format.contentType === "video/webm" ||
45 info.format.contentType === "video/ogg"
46 ) {
47 return (
48 <PreviewVideoUri
49 src={info.value}
50 contentType={info.format.contentType}
51 />
52 );
53 } else if (
54 info.format.contentType === "audio/mpeg" ||
55 info.format.contentType === "audio/ogg" ||
56 info.format.contentType === "audio/wav"
57 ) {
58 return (
59 <PreviewAudioUri
60 src={info.value}
61 contentType={info.format.contentType}
62 />
63 );
64 } else {
65 return <PreviewUri value={info.value} type={info} />;
66 }
67 case "datetime":
68 if (info.format.parts === "date" || info.format.parts === "datetime") {
69 return <PreviewDate value={info.value} format={info.format} />;
70 }
71 return <></>;
72 case "color":
73 return <PreviewColor value={info.value} format={info.format} />;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected