-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add sorting function for transaction history table
- Loading branch information
1 parent
7a8f30b
commit 4692228
Showing
7 changed files
with
110 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
dapp/src/components/TransactionHistory/Table/utils/sorting.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { SortASC, SortDESC } from "#/static/icons" | ||
import { SortDirection } from "@tanstack/react-table" | ||
import { Icon } from "@chakra-ui/react" | ||
|
||
const BOX_SIZE = 1.5 | ||
|
||
const getSortIconColor = ( | ||
isSorted: false | SortDirection, | ||
direction: SortDirection, | ||
) => { | ||
if (isSorted === direction) return "brand.400" | ||
|
||
return undefined | ||
} | ||
|
||
export const SORT_ICONS: { | ||
key: SortDirection | ||
icon: typeof Icon | ||
boxSize: number | ||
getColor: (isSorted: false | SortDirection) => string | undefined | ||
}[] = [ | ||
{ | ||
key: "asc", | ||
icon: SortASC, | ||
boxSize: BOX_SIZE, | ||
getColor: (isSorted) => getSortIconColor(isSorted, "asc"), | ||
}, | ||
{ | ||
key: "desc", | ||
icon: SortDESC, | ||
boxSize: BOX_SIZE, | ||
getColor: (isSorted) => getSortIconColor(isSorted, "desc"), | ||
}, | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import React from "react" | ||
import { createIcon } from "@chakra-ui/react" | ||
|
||
export const SortASC = createIcon({ | ||
displayName: "SortASC", | ||
viewBox: "0 0 7 7", | ||
path: <path d="M3.51671 0.5L7 6.3H0L3.51671 0.5Z" fill="currentColor" />, | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import React from "react" | ||
import { createIcon } from "@chakra-ui/react" | ||
|
||
export const SortDESC = createIcon({ | ||
displayName: "SortDESC", | ||
viewBox: "0 0 7 7", | ||
path: <path d="M3.51671 6.5L7 0.7H0L3.51671 6.5Z" fill="currentColor" />, | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters