wip scores, components
This commit is contained in:
parent
64a61ef2b3
commit
b604c01e22
20 changed files with 250 additions and 115 deletions
7
tank-frontend/src/components/Button.css
Normal file
7
tank-frontend/src/components/Button.css
Normal file
|
@ -0,0 +1,7 @@
|
|||
.Button {
|
||||
border: solid 1px green;
|
||||
border-radius: 12px;
|
||||
|
||||
color: green;
|
||||
background: transparent;
|
||||
}
|
15
tank-frontend/src/components/Button.tsx
Normal file
15
tank-frontend/src/components/Button.tsx
Normal file
|
@ -0,0 +1,15 @@
|
|||
import './Button.css';
|
||||
import {MouseEventHandler} from "react";
|
||||
|
||||
export default function Button({text, onClick, className}: {
|
||||
text: string,
|
||||
onClick?: MouseEventHandler<HTMLButtonElement>,
|
||||
className?: string
|
||||
}) {
|
||||
return <button
|
||||
className={'Button ' + (className ?? '')}
|
||||
onClick={onClick}
|
||||
>
|
||||
{text}
|
||||
</button>
|
||||
}
|
7
tank-frontend/src/components/Column.css
Normal file
7
tank-frontend/src/components/Column.css
Normal file
|
@ -0,0 +1,7 @@
|
|||
.Column {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
flex: auto;
|
||||
max-height: 100%;
|
||||
align-items: stretch;
|
||||
}
|
13
tank-frontend/src/components/Column.tsx
Normal file
13
tank-frontend/src/components/Column.tsx
Normal file
|
@ -0,0 +1,13 @@
|
|||
import {ReactNode} from "react";
|
||||
|
||||
import './Column.css'
|
||||
|
||||
export default function Column({children, className}: {
|
||||
children: ReactNode,
|
||||
className?: string
|
||||
}) {
|
||||
return <div className={'Column ' + (className ?? '')}>
|
||||
{children}
|
||||
</div>
|
||||
}
|
||||
|
3
tank-frontend/src/components/DataTable.css
Normal file
3
tank-frontend/src/components/DataTable.css
Normal file
|
@ -0,0 +1,3 @@
|
|||
.DataTable {
|
||||
flex-grow: 1;
|
||||
}
|
52
tank-frontend/src/components/DataTable.tsx
Normal file
52
tank-frontend/src/components/DataTable.tsx
Normal file
|
@ -0,0 +1,52 @@
|
|||
import {ReactNode} from "react";
|
||||
import './DataTable.css';
|
||||
|
||||
export type DataTableColumnDefinition<T> = {
|
||||
field: string,
|
||||
label?: string,
|
||||
visualize?: (value: T) => ReactNode
|
||||
};
|
||||
|
||||
function TableHead({columns}: { columns: DataTableColumnDefinition<any>[] }) {
|
||||
return <thead className='DataTableHead'>
|
||||
<tr>
|
||||
{
|
||||
columns.map(column =>
|
||||
<th key={column.field}>
|
||||
{column.label ?? column.field}
|
||||
</th>)
|
||||
}
|
||||
</tr>
|
||||
</thead>;
|
||||
}
|
||||
|
||||
function DataTableRow({rowData, columns}: {
|
||||
rowData: any,
|
||||
columns: DataTableColumnDefinition<any>[]
|
||||
}) {
|
||||
return <tr>
|
||||
{
|
||||
columns.map(column => {
|
||||
return <td key={column.field}>
|
||||
{
|
||||
column.visualize
|
||||
? column.visualize(rowData)
|
||||
: rowData[column.field]
|
||||
}
|
||||
</td>;
|
||||
})
|
||||
}
|
||||
</tr>;
|
||||
}
|
||||
|
||||
export default function DataTable<T>({data, columns}: {
|
||||
data: T[],
|
||||
columns: DataTableColumnDefinition<any>[]
|
||||
}) {
|
||||
return <table className='DataTable'>
|
||||
<TableHead columns={columns}/>
|
||||
<tbody>
|
||||
{data.map((element, index) => <DataTableRow key={index} rowData={element} columns={columns}/>)}
|
||||
</tbody>
|
||||
</table>
|
||||
}
|
7
tank-frontend/src/components/Row.css
Normal file
7
tank-frontend/src/components/Row.css
Normal file
|
@ -0,0 +1,7 @@
|
|||
.Row {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
flex: auto;
|
||||
max-width: 100%;
|
||||
align-items: stretch;
|
||||
}
|
9
tank-frontend/src/components/Row.tsx
Normal file
9
tank-frontend/src/components/Row.tsx
Normal file
|
@ -0,0 +1,9 @@
|
|||
import {ReactNode} from "react";
|
||||
|
||||
import './Row.css';
|
||||
|
||||
export default function Row({children, className}: { children: ReactNode, className?: string }) {
|
||||
return <div className={'Row ' + (className ?? '')}>
|
||||
{children}
|
||||
</div>
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue