Add table sorting

Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
This commit is contained in:
Alex Andreev committed 2021-05-14 11:53:39 +03:00
1 parent 38343af2ef
commit f9fda30045
4 files changed
+134 -5

No files matched your search

@@ -100,7 +100,7 @@ export function InstalledExtensions({ extensions, uninstall }: Props) {
disabled={isUninstalling}
onClick={() => extension.isEnabled = true}
>
<Icon material="published"/>
<Icon material="check_circle"/>
<span className="title">Enable</span>
</MenuItem>
)}
@@ -108,7 +108,7 @@ export function InstalledExtensions({ extensions, uninstall }: Props) {
disabled={isUninstalling}
onClick={() => uninstall(extension)}
>
<Icon material="remove"/>
<Icon material="delete"/>
<span className="title">Uninstall</span>
</MenuItem>
</MenuActions>
@@ -7,11 +7,11 @@
@apply overflow-hidden font-bold;
border-bottom: thin solid var(--hrColor);
color: var(--textColorAccent);
padding-top: 6px;
height: 33px;
}
.tr:last-child {
border-bottom: thin solid var(--hrColor);
.tr {
}
.th {
+10 -1
View File
@@ -3,6 +3,7 @@ import React from "react";
import { useCallback, useMemo } from "react";
import { useFlexLayout, useSortBy, useTable, UseTableOptions } from "react-table";
import { FixedSizeList } from "react-window";
import { Icon } from "../icon";
import { cssNames } from "../../utils";
interface Props extends UseTableOptions<any> {
@@ -69,8 +70,16 @@ export function Table({ columns, data, virtual, headless }: Props) {
{headerGroups.map(headerGroup => (
<div {...headerGroup.getHeaderGroupProps()} key={headerGroup.getHeaderGroupProps().key} className={styles.tr}>
{headerGroup.headers.map(column => (
<div key={column.getHeaderProps().key} className={styles.tr}>
<div {...column.getHeaderProps(column.getSortByToggleProps())} key={column.getHeaderProps().key} className={styles.tr}>
{column.render("Header")}
{/* Sort direction indicator */}
<span>
{column.isSorted
? column.isSortedDesc
? <Icon material="arrow_drop_down" small/>
: <Icon material="arrow_drop_up" small/>
: !column.disableSortBy && <Icon material="arrow_drop_down" small className={styles.disabledArrow}/>}
</span>
</div>
))}
</div>