Skip to content

Commit bb54674

Browse files
authored
Merge pull request #507 from buildo/table_config_even_rows_background
Allow config of background color for Table's even rows
2 parents 2f716ea + 3edc70f commit bb54674

File tree

4 files changed

+5
-9
lines changed

4 files changed

+5
-9
lines changed

packages/bento-design-system/src/Table/Config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,5 @@ export type TableConfig = {
1010
headerForegroundColor: BentoSprinkles["color"];
1111
hintPlacement: TooltipPlacement;
1212
cellTooltipPlacement: TooltipPlacement;
13+
evenRowsBackgroundColor: BentoSprinkles["background"];
1314
};

packages/bento-design-system/src/Table/Table.css.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,6 @@ export const cellContainerRecipe = strictRecipe({
5656
justifyContent: "center",
5757
}),
5858
variants: {
59-
even: {
60-
true: bentoSprinkles({ background: "backgroundSecondary" }),
61-
false: bentoSprinkles({ background: "backgroundPrimary" }),
62-
},
6359
firstColumn: {
6460
true: bentoSprinkles({ paddingLeft: 8 }),
6561
},

packages/bento-design-system/src/Table/Table.tsx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -487,14 +487,12 @@ function CellContainer({
487487
first: boolean;
488488
last: boolean;
489489
} & TableCellProps) {
490+
const tableConfig = useBentoConfig().table;
490491
return (
491492
<Box className={lastLeftSticky && lastLeftStickyColumn} style={style}>
492493
<Box
493-
className={cellContainerRecipe({
494-
even: index % 2 === 0,
495-
firstColumn: first,
496-
lastColumn: last,
497-
})}
494+
background={index % 2 === 0 ? tableConfig.evenRowsBackgroundColor : "backgroundPrimary"}
495+
className={cellContainerRecipe({ firstColumn: first, lastColumn: last })}
498496
{...props}
499497
>
500498
{children}

packages/bento-design-system/src/util/defaultConfigs.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,7 @@ export const table: TableConfig = {
464464
headerForegroundColor: undefined,
465465
hintPlacement: "top",
466466
cellTooltipPlacement: "bottom",
467+
evenRowsBackgroundColor: "backgroundSecondary",
467468
};
468469

469470
export const toast: ToastConfig = {

0 commit comments

Comments
 (0)