refactor: improve resizing of column

This commit is contained in:
Carlos Valente
2024-10-02 22:19:34 +02:00
committed by Carlos Valente
parent e2cbe43a2b
commit eb7a30fcf3
2 changed files with 11 additions and 20 deletions
@@ -50,9 +50,15 @@ $table-header-font-size: calc(1rem - 3px);
font-size: $table-header-font-size; font-size: $table-header-font-size;
color: $gray-700; color: $gray-700;
}
th { th {
background-color: $gray-1300; background-color: $gray-1300;
&:hover {
.resizer {
width: 0.5rem;
}
} }
} }
@@ -126,30 +132,19 @@ $table-header-font-size: calc(1rem - 3px);
.resizer { .resizer {
cursor: col-resize; cursor: col-resize;
opacity: 0; opacity: $opacity-disabled;
display: inline-block; display: inline-block;
width: 3px; width: 0;
height: 100%; height: 100%;
position: absolute; position: absolute;
right: 0; right: 0;
top: 0; top: 0;
transform: translateX(50%);
background-color: $action-blue; background-color: $action-blue;
user-select: none; user-select: none;
touch-action: none; touch-action: none;
transition-duration: $transition-time-action;
transition-property: width, background-color;
&:hover { &:hover {
opacity: $opacity-disabled;
width: 6px;
}
&.isResizing {
opacity: 1; opacity: 1;
width: 6px;
background-color: $action-blue;
} }
} }
@@ -4,8 +4,6 @@ import { CSS } from '@dnd-kit/utilities';
import { Header } from '@tanstack/react-table'; import { Header } from '@tanstack/react-table';
import { OntimeRundownEntry } from 'ontime-types'; import { OntimeRundownEntry } from 'ontime-types';
import { cx } from '../../../common/utils/styleUtils';
import styles from '../Cuesheet.module.scss'; import styles from '../Cuesheet.module.scss';
interface SortableCellProps { interface SortableCellProps {
@@ -29,8 +27,6 @@ export function SortableCell({ header, style, children }: SortableCellProps) {
transition, transition,
}; };
const resizerClasses = cx([styles.resizer, header.column.getIsResizing() ? styles.isResizing : null]);
return ( return (
<th ref={setNodeRef} style={dragStyle} colSpan={colSpan}> <th ref={setNodeRef} style={dragStyle} colSpan={colSpan}>
<div {...attributes} {...listeners}> <div {...attributes} {...listeners}>
@@ -41,7 +37,7 @@ export function SortableCell({ header, style, children }: SortableCellProps) {
onMouseDown: header.getResizeHandler(), onMouseDown: header.getResizeHandler(),
onTouchStart: header.getResizeHandler(), onTouchStart: header.getResizeHandler(),
}} }}
className={resizerClasses} className={styles.resizer}
/> />
</th> </th>
); );