Skip to content

Commit cfb7131

Browse files
committed
create mechanism to inject icons
1 parent d8faa31 commit cfb7131

File tree

2 files changed

+19
-7
lines changed

2 files changed

+19
-7
lines changed

src/components/Table/Icons.tsx

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import React from "react";
2+
3+
export type SortingArrowIcon = React.FC<{
4+
className?: string;
5+
}>;
6+
7+
export let ArrowUp: SortingArrowIcon = () => <></>;
8+
export let ArrowDown: SortingArrowIcon = () => <></>;
9+
10+
export function injectSortingArrowIcons(icons: {
11+
ArrowUp: SortingArrowIcon;
12+
ArrowDown: SortingArrowIcon;
13+
}) {
14+
ArrowUp = icons.ArrowUp;
15+
ArrowDown = icons.ArrowDown;
16+
}

src/components/Table/Sorting.tsx

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
import React from "react";
2-
import { Header, RowData /*, SortDirection*/ } from "@tanstack/react-table";
3-
// TODO FIXME: importing directly not allowed?
4-
// import ArrowUp from "../../assets/icons/arrow-up.svg";
5-
// import ArrowDown from "../../assets/icons/arrow-down.svg";
2+
import { Header, RowData, SortDirection } from "@tanstack/react-table";
63
import { PropsWithChildren } from "react";
4+
import { ArrowUp, ArrowDown } from "./Icons";
75

8-
/*
96
type Props = {
107
direction: SortDirection | false;
118
};
@@ -17,7 +14,6 @@ function SortingArrow({ direction }: Props) {
1714

1815
return <Comp className="h-4 w-4 shrink-0" />;
1916
}
20-
*/
2117

2218
interface HeaderProps<TData extends RowData> {
2319
header: Header<TData, unknown>;
@@ -35,7 +31,7 @@ export function SortableHeader<TData extends RowData>({
3531
onClick={header.column.getToggleSortingHandler()}
3632
>
3733
<span>{children}</span>
38-
{/* <SortingArrow direction={header.column.getIsSorted()} /> */}
34+
<SortingArrow direction={header.column.getIsSorted()} />
3935
</button>
4036
);
4137
}

0 commit comments

Comments
 (0)