forked from Kuechlin/mantine-data-grid
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathColumnSorter.tsx
27 lines (25 loc) · 834 Bytes
/
ColumnSorter.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import { ActionIcon } from '@mantine/core';
import { IconChevronDown, IconSelector } from '@tabler/icons-react';
import { Column } from '@tanstack/react-table';
export interface ColumnSorterProps {
column: Column<any, any>;
className: string;
color: string;
}
export const DefaultColumnSorter = ({ column, className, color }: ColumnSorterProps) => {
const sorted = column.getIsSorted();
return (
<ActionIcon
size="xs"
onClick={column.getToggleSortingHandler()}
className={className}
style={{
transition: 'transform 0.25s',
transform: `rotate(${sorted === 'asc' ? '180' : '0'}deg)`,
}}
variant={sorted ? 'light' : 'transparent'}
color={sorted ? color : 'gray'}
children={sorted ? <IconChevronDown size={16} /> : <IconSelector size={16} />}
/>
);
};