Skip to content

Commit 2885a99

Browse files
committed
improve game settings table
1 parent e9f88b2 commit 2885a99

File tree

5 files changed

+26
-11
lines changed

5 files changed

+26
-11
lines changed

optimal-settings-frontend/package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

optimal-settings-frontend/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
"eslint-config-prettier": "^9.0.0",
3737
"postcss": "^8",
3838
"prettier": "3.0.3",
39-
"tailwindcss": "^3",
39+
"tailwindcss": "3.4.1",
4040
"typescript": "^5"
4141
}
4242
}

optimal-settings-frontend/src/app/games/[slug]/components/SettingsTable.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,14 @@ type SettingsTable = {
99

1010
export default function SettingsTable({ settings }: SettingsTable) {
1111
return (
12-
<Table striped border="border">
12+
<Table striped border="border" tableLayout="fixed">
1313
<TableBody>
1414
{settings.map(([key, value]) => (
1515
<TableRow key={key}>
16-
<TableCell type="th">{key}</TableCell>
17-
<TableCell>{value}</TableCell>
16+
<TableCell type="th" border="border">
17+
{key}
18+
</TableCell>
19+
<TableCell border="border">{value}</TableCell>
1820
</TableRow>
1921
))}
2022
</TableBody>

optimal-settings-frontend/src/components/Table.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ type Table = {
55
pinColumns?: boolean;
66
striped?: boolean;
77
textAlignment?: "left" | "center" | "right";
8+
tableLayout?: "auto" | "fixed";
89
children: React.ReactNode;
910
};
1011

@@ -15,6 +16,7 @@ export default function Table({
1516
pinColumns,
1617
striped,
1718
textAlignment,
19+
tableLayout,
1820
children,
1921
}: Table) {
2022
let tableClasses = "table";
@@ -38,7 +40,9 @@ export default function Table({
3840
}
3941
return (
4042
<div className="overflow-x-auto">
41-
<table className={tableClasses}>{children}</table>
43+
<table className={tableClasses} style={{ tableLayout: tableLayout }}>
44+
{children}
45+
</table>
4246
</div>
4347
);
4448
}
Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,18 @@
11
type TableCell = {
22
type?: "th" | "td";
3+
border?: "border" | "border-2" | "border-4" | "border-8";
34
children: React.ReactNode;
45
};
56

6-
export default function TableCell({ type = "td", children }: TableCell) {
7+
export default function TableCell({
8+
type = "td",
9+
border,
10+
children,
11+
}: TableCell) {
712
const Cell = type;
8-
return <Cell>{children}</Cell>;
13+
let cellClasses = "";
14+
if (border) {
15+
cellClasses += ` ${border} border-base-300`;
16+
}
17+
return <Cell className={cellClasses}>{children}</Cell>;
918
}

0 commit comments

Comments
 (0)