Skip to content

Commit

Permalink
improve game settings table
Browse files Browse the repository at this point in the history
  • Loading branch information
weclaw1 committed Jan 6, 2024
1 parent e9f88b2 commit 2885a99
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 11 deletions.
8 changes: 4 additions & 4 deletions optimal-settings-frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion optimal-settings-frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"eslint-config-prettier": "^9.0.0",
"postcss": "^8",
"prettier": "3.0.3",
"tailwindcss": "^3",
"tailwindcss": "3.4.1",
"typescript": "^5"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@ type SettingsTable = {

export default function SettingsTable({ settings }: SettingsTable) {
return (
<Table striped border="border">
<Table striped border="border" tableLayout="fixed">
<TableBody>
{settings.map(([key, value]) => (
<TableRow key={key}>
<TableCell type="th">{key}</TableCell>
<TableCell>{value}</TableCell>
<TableCell type="th" border="border">
{key}
</TableCell>
<TableCell border="border">{value}</TableCell>
</TableRow>
))}
</TableBody>
Expand Down
6 changes: 5 additions & 1 deletion optimal-settings-frontend/src/components/Table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ type Table = {
pinColumns?: boolean;
striped?: boolean;
textAlignment?: "left" | "center" | "right";
tableLayout?: "auto" | "fixed";
children: React.ReactNode;
};

Expand All @@ -15,6 +16,7 @@ export default function Table({
pinColumns,
striped,
textAlignment,
tableLayout,
children,
}: Table) {
let tableClasses = "table";
Expand All @@ -38,7 +40,9 @@ export default function Table({
}
return (
<div className="overflow-x-auto">
<table className={tableClasses}>{children}</table>
<table className={tableClasses} style={{ tableLayout: tableLayout }}>
{children}
</table>
</div>
);
}
13 changes: 11 additions & 2 deletions optimal-settings-frontend/src/components/TableCell.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
type TableCell = {
type?: "th" | "td";
border?: "border" | "border-2" | "border-4" | "border-8";
children: React.ReactNode;
};

export default function TableCell({ type = "td", children }: TableCell) {
export default function TableCell({
type = "td",
border,
children,
}: TableCell) {
const Cell = type;
return <Cell>{children}</Cell>;
let cellClasses = "";
if (border) {
cellClasses += ` ${border} border-base-300`;
}
return <Cell className={cellClasses}>{children}</Cell>;
}

0 comments on commit 2885a99

Please sign in to comment.