MCPcopy Index your code
hub / github.com/atomicdata-dev/atomic-data-browser / ValueComp

Function ValueComp

data-browser/src/components/ValueComp.tsx:24–50  ·  view source on GitHub ↗

Renders a value in a fitting way, depending on its DataType

({ value, datatype, noMargin }: Props)

Source from the content-addressed store, hash-verified

22
23/** Renders a value in a fitting way, depending on its DataType */
24function ValueComp({ value, datatype, noMargin }: Props): JSX.Element {
25 try {
26 switch (datatype) {
27 case Datatype.ATOMIC_URL: {
28 const resource = valToResource(value);
29 if (typeof resource == 'string') {
30 return <ResourceInline subject={resource} />;
31 }
32 return <Nestedresource resource={resource} />;
33 }
34 case (Datatype.DATE, Datatype.TIMESTAMP):
35 return <DateTime date={valToDate(value)} />;
36 case Datatype.MARKDOWN:
37 return <Markdown text={valToString(value)} noMargin={noMargin} />;
38 case Datatype.RESOURCEARRAY:
39 return <ResourceArray subjects={valToArray(value)} />;
40 default:
41 return <div>{valToString(value)}</div>;
42 }
43 } catch (e) {
44 return (
45 <ErrMessage>
46 {e.message} original value: {value.toString()}
47 </ErrMessage>
48 );
49 }
50}
51
52export default ValueComp;

Callers

nothing calls this directly

Calls 4

valToResourceFunction · 0.90
valToDateFunction · 0.90
valToStringFunction · 0.90
valToArrayFunction · 0.90

Tested by

no test coverage detected