Skip to content

Commit

Permalink
feat: fixed table width
Browse files Browse the repository at this point in the history
  • Loading branch information
shiftpsh committed Oct 6, 2024
1 parent 9cfa3ab commit 5b878e9
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
15 changes: 14 additions & 1 deletion src/common/ui/award/award-table.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
import { Table } from "@ui/table/table";
import { AwardBadge, TAwardBadgeVariant } from "@ui/award-badge/award-badge";
import { CSSProperties } from "react";

const columnStyle = (headerContent: string): CSSProperties | undefined => {
if (headerContent === "#") {
return { width: "6em" };
}
if (headerContent === "=") {
return { width: "6em" };
}
return undefined;
};

export const AwardTable = ({
columns,
Expand All @@ -16,7 +27,9 @@ export const AwardTable = ({
<Table.Header>
<Table.Row>
{columns.map((h, i) => (
<Table.Head key={i}>{h}</Table.Head>
<Table.Head key={i} style={columnStyle(h)}>
{h}
</Table.Head>
))}
</Table.Row>
</Table.Header>
Expand Down
3 changes: 2 additions & 1 deletion src/common/ui/table/table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ const _TableCell = ({
export const TableCell = styled(_TableCell)`
padding: 8px;
text-align: center;
vertical-align: top;
vertical-align: baseline;
border: 1px solid #ddd;
`;
Expand Down Expand Up @@ -103,6 +103,7 @@ export const Table = styled(_Table)`
width: 100%;
border-collapse: collapse;
border-spacing: 0;
table-layout: fixed;
` as unknown as typeof _Table & {
Wrapper: typeof TableWrapper;
Header: typeof TableHeader;
Expand Down

0 comments on commit 5b878e9

Please sign in to comment.