Add prettier for codestyle and re-format everything (#1294)

This commit is contained in:
Erik Michelson 2021-06-06 23:14:00 +02:00 committed by GitHub
parent 8b78154075
commit 0aae1f70d2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
319 changed files with 4809 additions and 3936 deletions

View file

@ -15,7 +15,13 @@ export interface CsvTableProps {
tableColumnClassName?: string
}
export const CsvTable: React.FC<CsvTableProps> = ({ code, delimiter, showHeader, tableRowClassName, tableColumnClassName }) => {
export const CsvTable: React.FC<CsvTableProps> = ({
code,
delimiter,
showHeader,
tableRowClassName,
tableColumnClassName
}) => {
const { rowsWithColumns, headerRow } = useMemo(() => {
const rowsWithColumns = parseCsv(code.trim(), delimiter)
let headerRow: string[] = []
@ -29,17 +35,11 @@ export const CsvTable: React.FC<CsvTableProps> = ({ code, delimiter, showHeader,
if (row !== []) {
return (
<thead>
<tr>
{
row.map((column, columnNumber) => (
<th
key={ `header-${ columnNumber }` }
>
{ column }
</th>
))
}
</tr>
<tr>
{row.map((column, columnNumber) => (
<th key={`header-${columnNumber}`}>{column}</th>
))}
</tr>
</thead>
)
}
@ -48,30 +48,23 @@ export const CsvTable: React.FC<CsvTableProps> = ({ code, delimiter, showHeader,
const renderTableBody = (rows: string[][]) => {
return (
<tbody>
{
rows.map((row, rowNumber) => (
<tr className={ tableRowClassName } key={ `row-${ rowNumber }` }>
{
row.map((column, columnIndex) => (
<td
className={ tableColumnClassName }
key={ `cell-${ rowNumber }-${ columnIndex }` }
>
{ column.replace(/^"|"$/g, '') }
</td>
))
}
{rows.map((row, rowNumber) => (
<tr className={tableRowClassName} key={`row-${rowNumber}`}>
{row.map((column, columnIndex) => (
<td className={tableColumnClassName} key={`cell-${rowNumber}-${columnIndex}`}>
{column.replace(/^"|"$/g, '')}
</td>
))}
</tr>
))
}
))}
</tbody>
)
}
return (
<table className={ 'csv-html-table table-striped' }>
{ renderTableHeader(headerRow) }
{ renderTableBody(rowsWithColumns) }
<table className={'csv-html-table table-striped'}>
{renderTableHeader(headerRow)}
{renderTableBody(rowsWithColumns)}
</table>
)
}