Skip to content

Commit

Permalink
[Table] Add isActive prop to TableRow (#472)
Browse files Browse the repository at this point in the history
  • Loading branch information
pjhampton authored Sep 9, 2024
1 parent ddd0405 commit b999ad4
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 3 deletions.
18 changes: 18 additions & 0 deletions src/components/Table/Table.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,24 @@ const rows = [
{ label: "Mexico" },
],
},
{
id: "row-3",
isActive: true,
items: [
{ label: "Alfreds Futterkiste" },
{ label: "Maria Anders" },
{ label: "Germany" },
],
},
{
id: "row-4",
isDeleted: true,
items: [
{ label: "Centro comercial Moctezuma" },
{ label: "Francisco Chang" },
{ label: "Mexico" },
],
},
];

export default {
Expand Down
14 changes: 11 additions & 3 deletions src/components/Table/Table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -156,18 +156,23 @@ interface TableRowProps {
$isSelectable?: boolean;
$isDeleted?: boolean;
$isDisabled?: boolean;
$isActive?: boolean;
$showActions?: boolean;
$rowHeight?: string;
}

const TableRow = styled.tr<TableRowProps>`
overflow: hidden;
${({ theme, $isDeleted, $isDisabled, $rowHeight }) => `
${({ theme, $isDeleted, $isDisabled, $isActive, $rowHeight }) => `
${$rowHeight ? `height: ${$rowHeight};` : ""}
background-color: ${theme.click.table.row.color.background.default};
border-bottom: ${theme.click.table.cell.stroke} solid ${
theme.click.table.row.color.stroke.default
};
theme.click.table.row.color.stroke.default
};
${$isActive &&
`background-color: ${theme.click.table.row.color.background.active};`}
&:active {
background-color: ${theme.click.table.row.color.background.active};
}
Expand Down Expand Up @@ -366,6 +371,7 @@ export interface TableRowType
items: Array<TableCellType>;
isDisabled?: boolean;
isDeleted?: boolean;
isActive?: boolean;
}

interface CommonTableProps
Expand Down Expand Up @@ -422,6 +428,7 @@ const TableBodyRow = ({
onDelete,
onEdit,
isDeleted,
isActive,
isDisabled,
size,
actionsList,
Expand All @@ -435,6 +442,7 @@ const TableBodyRow = ({
$isSelectable={isSelectable}
$isDeleted={isDeleted}
$isDisabled={isDisabled}
$isActive={isActive}
$showActions={isDeletable || isEditable}
$rowHeight={rowHeight}
{...rowProps}
Expand Down

0 comments on commit b999ad4

Please sign in to comment.