From 848d72962e3c8a529a6269b4a69fb4e8706f56e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Ra=C4=8D=C3=A1k?= Date: Mon, 6 Jan 2025 16:10:41 +0100 Subject: [PATCH] Remove Tablepress It should not be used anywhere. --- site/Tablepress.tsx | 88 --------------------------------------- site/css/content.scss | 21 ---------- site/renderTablePress.tsx | 6 --- 3 files changed, 115 deletions(-) delete mode 100644 site/Tablepress.tsx delete mode 100644 site/renderTablePress.tsx diff --git a/site/Tablepress.tsx b/site/Tablepress.tsx deleted file mode 100644 index 9fa71544f08..00000000000 --- a/site/Tablepress.tsx +++ /dev/null @@ -1,88 +0,0 @@ -interface Cell { - data: string - colspan: number - rowspan: number -} - -function cell(data?: string) { - return { - data: data || "", - colspan: 1, - rowspan: 1, - } -} - -const ROWSPAN_TOKEN = "#rowspan#" -const COLSPAN_TOKEN = "#colspan#" - -function parseTable(table: string[][]): Cell[][] { - const resultTable: Cell[][] = [] - table.forEach((row, r) => { - const resultRow: Cell[] = [] - row.forEach((data, c) => { - if (data === ROWSPAN_TOKEN) { - let i = r - 1 - while (i >= 0 && table[i][c] === ROWSPAN_TOKEN) { - i-- - } - if (i >= 0) { - resultTable[i][c].rowspan++ - } else { - resultRow.push(cell()) - } - } else if (data === COLSPAN_TOKEN) { - let j = c - 1 - while (j >= 0 && row[j] === COLSPAN_TOKEN) { - j-- - } - if (j >= 0) { - resultRow[j].colspan++ - } else { - resultRow.push(cell()) - } - } else { - resultRow.push(cell(data)) - } - }) - resultTable.push(resultRow) - }) - return resultTable -} - -export default function Tablepress(props: { data: string[][] }) { - const { data } = props - const table = parseTable(data) - const [headerRow, ...body] = table - return ( - - - - {headerRow.map((cell, i) => ( - - - - {body.map((row, i) => ( - - {row.map((cell, j) => ( - - ))} - -
- ))} -
- ))} -
- ) -} diff --git a/site/css/content.scss b/site/css/content.scss index 398ab7bb90e..56c34653c04 100644 --- a/site/css/content.scss +++ b/site/css/content.scss @@ -124,27 +124,6 @@ figure[data-explorer-src] { } } -.tablepress { - margin: 1em 0; - color: #000; -} - -.tablepress th { - border-bottom: 1px solid #333; - background: $blue-20; -} - -.tablepress th, -.tablepress td { - padding: 0.4rem; - border: 1px solid #ddd; - text-align: center; -} - -.tablepress tr { - background-color: $white; -} - /* Fix for title on really small screens */ @media (max-width: 400px) { .logo { diff --git a/site/renderTablePress.tsx b/site/renderTablePress.tsx deleted file mode 100644 index 20b13648f0b..00000000000 --- a/site/renderTablePress.tsx +++ /dev/null @@ -1,6 +0,0 @@ -import { renderToStaticMarkup } from "react-dom/server" -import Tablepress from "./Tablepress.js" - -export const renderTablePress = (table: string[][]) => { - return renderToStaticMarkup() -}