From 8ad6536f0fe2839928a00000eed0992928e74fe3 Mon Sep 17 00:00:00 2001 From: Liliana Sanfilippo <liliana.sanfilippo@uni-bielefeld.de> Date: Thu, 26 Sep 2024 09:12:58 +0200 Subject: [PATCH] Tables --- src/components/Table.tsx | 40 +++++++++++++++++++++++++++++++++++ src/data/parts.ts | 45 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 85 insertions(+) create mode 100644 src/components/Table.tsx create mode 100644 src/data/parts.ts diff --git a/src/components/Table.tsx b/src/components/Table.tsx new file mode 100644 index 00000000..49521758 --- /dev/null +++ b/src/components/Table.tsx @@ -0,0 +1,40 @@ +import { Part } from "../data/parts"; + +export function PartTable(data: Array<Part>, cols: Array<string>){ + let list = []; + for (let index = 0; index < data.length; index++) { + list.push( + <tr> + <td>{data[index].partname}</td> + <td><a href={data[index].url}>{data[index].registrycode}</a></td> + <td>{data[index].description}</td> + <td>{data[index].length}</td> + <td>{data[index].type}</td> + </tr> + ) + } + let heads = []; + for (let index = 0; index < cols.length; index++) { + heads.push(<td>cols[index]</td>) + } + return( + <div className="flex flex-col"> + <div className="overflow-x-auto sm:-mx-6 lg:-mx-8"> + <div className="inline-block min-w-full py-4 sm:px-6 lg:px-8"> + <div className="overflow-hidden p-2"> + <table className="min-w-full text-center"> + <thead className="border-b bg-gray-50"> + <tr> + {heads} + </tr> + </thead> + <tbody> + {list} + </tbody> + </table> + </div> + </div> + </div> + </div> + ) +} \ No newline at end of file diff --git a/src/data/parts.ts b/src/data/parts.ts new file mode 100644 index 00000000..464d9f13 --- /dev/null +++ b/src/data/parts.ts @@ -0,0 +1,45 @@ +export interface Part{ + partname: string, + registrycode: number, + description: string, + length: number, + type: PartType, + url: string +} +type PartType = "DNA" | "Protein"; + +/* +Vorlage: + +{ + partname: "", + registrycode: , + description: "", + length: , + type: "", + url: "" + }, + +*/ + +export const BasicParts: Array<Part> = [ + { + partname: "Beispiel", + registrycode: 0, + description: "Beispiel Description", + length: 0, + type: "DNA", + url: "....." + }, +] + +export const CompositeParts: Array<Part> = [ + { + partname: "Beispiel", + registrycode: 0, + description: "Beispiel Description", + length: 0, + type: "DNA", + url: "....." + }, +] \ No newline at end of file -- GitLab