Skip to content

Commit def3a63

Browse files
Column resizing UX (#2486)
* Update table column resizing styles * Minor fix
1 parent 9032d90 commit def3a63

File tree

2 files changed

+36
-8
lines changed

2 files changed

+36
-8
lines changed

src/components/Table/components/HeaderCell/ResizableHeaderCell.jsx

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1-
import React from "react";
1+
import React, { useState } from "react";
22

3+
import classnames from "classnames";
34
import { Resizable } from "react-resizable";
45

56
import CellContent from "./CellContent";
67

78
const ResizableHeaderCell = props => {
8-
const { onResize, width, onResizeStop, ...restProps } = props;
9+
const { onResize, width, onResizeStop, onResizeStart, ...restProps } = props;
10+
const [isResizing, setIsResizing] = useState(false);
911

1012
if (!width) {
1113
return <CellContent {...restProps} />;
@@ -18,12 +20,22 @@ const ResizableHeaderCell = props => {
1820
height={0}
1921
handle={
2022
<span
21-
className="react-resizable-handle"
23+
className={classnames("react-resizable-handle", {
24+
"react-resizable-handle--resizing": isResizing,
25+
})}
2226
onClick={e => e.stopPropagation()}
23-
/>
27+
>
28+
<span className="neeto-ui-table-react-resizable-handle__inner" />
29+
</span>
2430
}
25-
onResizeStart={e => {
31+
onResizeStart={(e, data) => {
2632
e.preventDefault();
33+
setIsResizing(true);
34+
onResizeStart?.(e, data);
35+
}}
36+
onResizeStop={(e, data) => {
37+
setIsResizing(false);
38+
onResizeStop?.(e, data);
2739
}}
2840
>
2941
<CellContent {...restProps} />

src/styles/components/_table-overrides.scss

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
--neeto-ui-table-header-font-weight: 600;
66
--neeto-ui-table-header-text-transform: uppercase;
77
--neeto-ui-table-header-border-bottom-width: 1px;
8-
--neeto-ui-table-resize-handle-width: 10px;
8+
--neeto-ui-table-resize-handle-width: 6px;
99
--neeto-ui-table-resize-handle-hover-bg-color: rgb(var(--neeto-ui-gray-300));
1010
}
1111

@@ -93,15 +93,31 @@
9393
width: var(--neeto-ui-table-resize-handle-width);
9494
height: 100%;
9595
bottom: 0;
96-
right: -5px;
96+
right: 0;
9797
cursor: col-resize;
9898
z-index: 1;
99+
padding-right: 1px;
100+
padding-left: 1px;
101+
}
102+
103+
.neeto-ui-table-react-resizable-handle__inner {
104+
position: relative;
105+
height: 90%;
106+
top: 5%;
107+
width: 100%;
108+
border-radius: 4px;
109+
display: block;
110+
transition: all 0.3s;
99111
}
100112

101-
.react-resizable-handle:hover {
113+
.react-resizable-handle:hover .neeto-ui-table-react-resizable-handle__inner {
102114
background-color: var(--neeto-ui-table-resize-handle-hover-bg-color);
103115
}
104116

117+
.react-resizable-handle--resizing .neeto-ui-table-react-resizable-handle__inner{
118+
background-color: rgb(var(--neeto-ui-primary-500)) !important;
119+
}
120+
105121
.neetix-table {
106122
--neeto-ui-table-header-font-size: var(--neeto-ui-text-sm);
107123
--neeto-ui-table-header-text-transform: capitalize;

0 commit comments

Comments
 (0)