Skip to content

Commit 41573a1

Browse files
committed
add custom classnames
1 parent aa5a073 commit 41573a1

File tree

5 files changed

+24
-4
lines changed

5 files changed

+24
-4
lines changed

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
# CHANGELOG
22

3+
## 0.6.0
4+
5+
_2024-06-74_
6+
7+
### Features
8+
9+
- **BREAKING:** `clearSizeCache` signature has changed. The second argument is now an optional object that takes a `forceUpdate` boolean and a `timeout`. Both are optional.
10+
- For columns, added `headerCellClassname` and `contentCellClassname`
11+
- when `headerHeight` is set, the header's height will actually be that height
12+
- _DOCS:_ removed `styled-components` and `semantic`
13+
314
## 0.5.7
415

516
_2024-06-14_

index.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ export type ColumnProps<T> = {
143143
* The name of the header column, or a component to return a customized header cell.
144144
*/
145145
header?: string | ((props: HeaderProps) => JSX.Element);
146+
headerCellClassname?: string;
146147
/**
147148
* The width of a column in pixels. If this is set, the column will not resize.
148149
*/
@@ -175,6 +176,7 @@ export type ColumnProps<T> = {
175176
* things inside of the react-fluid-table cell container.
176177
*/
177178
content?: string | number | ((props: CellProps<T>) => ReactNode | JSX.Element);
179+
contentCellClassname?: string | ((props: { row: T; index: number }) => string);
178180
/**
179181
* An advanced feature, this is used to render an entire cell, including the cell container.
180182
* The `content` prop is ignored if this property is enabled.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-fluid-table",
3-
"version": "0.5.8",
3+
"version": "0.6.0",
44
"description": "A React table inspired by react-window",
55
"author": "Mckervin Ceme <mckervinc@live.com>",
66
"license": "MIT",

src/Header.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ const HeaderCell = React.memo(function <T>({ column, width, prevWidth }: HeaderC
6363
<div
6464
style={style}
6565
onClick={onClick}
66-
className={cx("rft-header-cell", column.frozen && "frozen")}
66+
className={cx("rft-header-cell", column.frozen && "frozen", column.headerCellClassname)}
6767
>
6868
{column.header ? <div className="rft-header-cell-text">{column.header}</div> : null}
6969
{column.key !== col ? null : (

src/Row.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,13 +96,20 @@ const TableCell = memo(function <T>({
9696
left: column.frozen ? prevWidth : undefined
9797
};
9898

99+
// cell classname
100+
const cellClass = column.contentCellClassname
101+
? typeof column.contentCellClassname === "string"
102+
? column.contentCellClassname
103+
: column.contentCellClassname({ row, index })
104+
: null;
105+
99106
// expander
100107
if (column.expander) {
101108
if (typeof column.expander === "boolean") {
102109
const Logo = isExpanded ? Minus : Plus;
103110

104111
return (
105-
<div className={cx("rft-cell", column.frozen && "frozen")} style={style}>
112+
<div className={cx("rft-cell", column.frozen && "frozen", cellClass)} style={style}>
106113
<Logo className="rft-expander" onClick={e => onExpanderClick(e, !isExpanded)} />
107114
</div>
108115
);
@@ -132,7 +139,7 @@ const TableCell = memo(function <T>({
132139
}
133140

134141
return (
135-
<div className={cx("rft-cell", column.frozen && "frozen")} style={style}>
142+
<div className={cx("rft-cell", column.frozen && "frozen", cellClass)} style={style}>
136143
{content}
137144
</div>
138145
);

0 commit comments

Comments
 (0)