File tree Expand file tree Collapse file tree 2 files changed +28
-0
lines changed Expand file tree Collapse file tree 2 files changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ import { CellExtended, CellProps } from './Cell';
4
4
import NativeSortIcon from '../icons/NativeSortIcon' ;
5
5
import { equalizeId } from './util' ;
6
6
import { TableColumn , SortAction , SortOrder } from './types' ;
7
+ import NativeReorderIcon from '../icons/NativeReorderIcon' ;
7
8
8
9
interface ColumnStyleProps extends CellProps {
9
10
isDragging ?: boolean ;
@@ -175,6 +176,8 @@ function TableCol<T>({
175
176
< span className = { [ sortDirection , '__rdt_custom_sort_icon__' ] . join ( ' ' ) } > { sortIcon } </ span >
176
177
) ;
177
178
179
+ const renderNativeReorderIcon = ( ) => < NativeReorderIcon /> ;
180
+
178
181
const sortActive = ! ! ( column . sortable && equalizeId ( selectedColumn . id , column . id ) ) ;
179
182
const disableSort = ! column . sortable || disabled ;
180
183
const nativeSortIconLeft = column . sortable && ! sortIcon && ! column . right ;
@@ -217,6 +220,7 @@ function TableCol<T>({
217
220
sortActive = { ! disableSort && sortActive }
218
221
disabled = { disableSort }
219
222
>
223
+ { column . reorder && renderNativeReorderIcon ( ) }
220
224
{ ! disableSort && customSortIconRight && renderCustomSortIcon ( ) }
221
225
{ ! disableSort && nativeSortIconRight && renderNativeSortIcon ( sortActive ) }
222
226
Original file line number Diff line number Diff line change
1
+ import React from 'react' ;
2
+ import styled from 'styled-components' ;
3
+
4
+ const Icon = styled . span `
5
+ padding: 0px;
6
+ color: inherit;
7
+ flex-grow: 0;
8
+ flex-shrink: 0;
9
+ opacity: 0;
10
+ &:hover {
11
+ opacity: 1;
12
+ }
13
+ ` ;
14
+
15
+ // SVG taken from https://fontawesome.com/icons/grip-vertical?f=classic&s=solid
16
+ const NativeReorderIcon : React . FC = ( { } ) => (
17
+ < Icon >
18
+ < svg width = "10px" height = "10px" xmlns = "http://www.w3.org/2000/svg" viewBox = "0 0 320 512" >
19
+ < path d = "M40 352l48 0c22.1 0 40 17.9 40 40l0 48c0 22.1-17.9 40-40 40l-48 0c-22.1 0-40-17.9-40-40l0-48c0-22.1 17.9-40 40-40zm192 0l48 0c22.1 0 40 17.9 40 40l0 48c0 22.1-17.9 40-40 40l-48 0c-22.1 0-40-17.9-40-40l0-48c0-22.1 17.9-40 40-40zM40 320c-22.1 0-40-17.9-40-40l0-48c0-22.1 17.9-40 40-40l48 0c22.1 0 40 17.9 40 40l0 48c0 22.1-17.9 40-40 40l-48 0zM232 192l48 0c22.1 0 40 17.9 40 40l0 48c0 22.1-17.9 40-40 40l-48 0c-22.1 0-40-17.9-40-40l0-48c0-22.1 17.9-40 40-40zM40 160c-22.1 0-40-17.9-40-40L0 72C0 49.9 17.9 32 40 32l48 0c22.1 0 40 17.9 40 40l0 48c0 22.1-17.9 40-40 40l-48 0zM232 32l48 0c22.1 0 40 17.9 40 40l0 48c0 22.1-17.9 40-40 40l-48 0c-22.1 0-40-17.9-40-40l0-48c0-22.1 17.9-40 40-40z" />
20
+ </ svg >
21
+ </ Icon >
22
+ ) ;
23
+
24
+ export default NativeReorderIcon ;
You can’t perform that action at this time.
0 commit comments