Skip to content

Commit

Permalink
allow passing style to cellRenderer
Browse files Browse the repository at this point in the history
  • Loading branch information
Liooo committed Oct 20, 2024
1 parent 07c7374 commit a0aa632
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
11 changes: 10 additions & 1 deletion src/Cell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ function Cell<R, SR>(
onContextMenu,
onRowChange,
selectCell,
style,
...props
}: CellRendererProps<R, SR>,
ref: React.Ref<HTMLDivElement>
Expand Down Expand Up @@ -93,6 +94,14 @@ function Cell<R, SR>(
onRowChange(column, newRow);
}

const cellStyle = getCellStyle(column, colSpan);
if (style) {
let key: keyof React.CSSProperties;
for (key in style) {
(cellStyle as any)[key] = style[key];
}
}

return (
<div
role="gridcell"
Expand All @@ -103,7 +112,7 @@ function Cell<R, SR>(
ref={ref}
tabIndex={tabIndex}
className={className}
style={getCellStyle(column, colSpan)}
style={cellStyle}
onClick={handleClick}
onDoubleClick={handleDoubleClick}
onContextMenu={handleContextMenu}
Expand Down
2 changes: 1 addition & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ export interface CellRendererProps<TRow, TSummaryRow>
extends Pick<RenderRowProps<TRow, TSummaryRow>, 'row' | 'rowIdx' | 'selectCell'>,
Omit<
React.HTMLAttributes<HTMLDivElement>,
'style' | 'children' | 'onClick' | 'onDoubleClick' | 'onContextMenu'
'children' | 'onClick' | 'onDoubleClick' | 'onContextMenu'
> {
column: CalculatedColumn<TRow, TSummaryRow>;
colSpan: number | undefined;
Expand Down

0 comments on commit a0aa632

Please sign in to comment.