Skip to content

Commit

Permalink
init commit - update table2beta. (#852)
Browse files Browse the repository at this point in the history
  • Loading branch information
MatthewwTN authored Nov 18, 2024
1 parent f5b65b1 commit 45d063a
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "clever-components",
"version": "2.224.0",
"version": "2.225.0",
"description": "A library of helpful React components and less styles",
"repository": {
"type": "git",
Expand Down
2 changes: 2 additions & 0 deletions src/Table2Beta/Column.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export interface Props {
};
noWrap?: boolean;
sortable?: boolean;
tooltip?: React.ReactNode;
sortValueFn?: Function;
width?: string; // Not included in propTypes but appears to work and is commonly used.
}
Expand All @@ -32,6 +33,7 @@ Column.propTypes = {
}),
noWrap: PropTypes.bool,
sortable: PropTypes.bool,
tooltip: PropTypes.node,
sortValueFn: PropTypes.func,
};

Expand Down
1 change: 1 addition & 0 deletions src/Table2Beta/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export default function Header({
key={column.id}
onSortChange={() => onSortChange(column.id)}
sortable={column.sortable && !disableSort}
tooltip={column.tooltip ? column.tooltip : null}
width={column.width}
>
{column.header && column.header.content}
Expand Down
5 changes: 5 additions & 0 deletions src/Table2Beta/HeaderCell.less
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,8 @@
fill: @neutral_black;
}
}

.Table--header--cell--tooltip {
margin-left: 0.625rem;
cursor: pointer;
}
4 changes: 4 additions & 0 deletions src/Table2Beta/HeaderCell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export interface Props {
children?: React.ReactNode;
onSortChange?: Function;
sortable?: boolean;
tooltip?: React.ReactNode;
activeSortDirection?: "asc" | "desc";
width?: string;
}
Expand All @@ -24,13 +25,15 @@ export const cssClass = {
LABEL: "Table--header--cell--label",
SORTABLE: "Table--header--cell--sortable",
SORT: "Table--header--cell--sort_icons",
TOOLTIP: "Table--header--cell--tooltip",
};

export default function HeaderCell({
children,
className,
onSortChange,
sortable,
tooltip,
activeSortDirection,
width,
}: Props) {
Expand Down Expand Up @@ -59,6 +62,7 @@ export default function HeaderCell({
<SortIcons direction={activeSortDirection} className={cssClass.SORT} />
</div>
)}
{tooltip && <div className={cssClass.TOOLTIP}>{tooltip}</div>}
</FlexBox>
</Cell>
);
Expand Down

0 comments on commit 45d063a

Please sign in to comment.