Skip to content

Commit 62067b6

Browse files
committed
Fix sort color for column.
1 parent 80365db commit 62067b6

File tree

6 files changed

+28
-7
lines changed

6 files changed

+28
-7
lines changed

src/components/tableV2/core/base-table.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ Table.SortingHeadCell = forwardRef(
184184
styles = {},
185185
headStyles = {},
186186
tooltipText,
187+
coloredSortedColumn,
187188
...props
188189
},
189190
ref
@@ -213,7 +214,7 @@ Table.SortingHeadCell = forwardRef(
213214
headStyles={headStyles}
214215
{...props}
215216
filter={filter}
216-
{...(!!sortDirection && { background: "successBackground" })}
217+
{...(coloredSortedColumn && !!sortDirection && { background: "successBackground" })}
217218
>
218219
<Box
219220
onMouseEnter={onMouseEnter}
@@ -229,7 +230,7 @@ Table.SortingHeadCell = forwardRef(
229230
gap={1}
230231
>
231232
{children}
232-
<Box position="absolute" top={1} right={-12}>
233+
<Box position="absolute" top={1} right="-16px">
233234
<Icon
234235
height="16px"
235236
width="16px"

src/components/tableV2/core/fullTable.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ const FullTable = ({
2020
width,
2121
scrollParentRef,
2222
virtualizeOptions = {},
23+
coloredSortedColumn,
2324
...rest
2425
}) => {
2526
return (
@@ -40,6 +41,7 @@ const FullTable = ({
4041
pinnedStyles={pinnedStyles}
4142
table={table}
4243
testPrefix={testPrefix}
44+
coloredSortedColumn={coloredSortedColumn}
4345
/>
4446
</Table.HeadRow>
4547
</Table.Head>
@@ -54,6 +56,7 @@ const FullTable = ({
5456
table={table}
5557
testPrefix={testPrefix}
5658
testPrefixCallback={testPrefixCallback}
59+
coloredSortedColumn={coloredSortedColumn}
5760
{...virtualizeOptions}
5861
/>
5962
</Table.Body>

src/components/tableV2/core/headCell.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,15 @@ const availableFilters = {
3737
default: SearchFilter,
3838
}
3939

40-
const HeadCell = ({ enableResize, enableSorting, headers, pinnedStyles = {}, table, testPrefix }) =>
40+
const HeadCell = ({
41+
enableResize,
42+
enableSorting,
43+
headers,
44+
pinnedStyles = {},
45+
table,
46+
testPrefix,
47+
...rest
48+
}) =>
4149
headers.map(({ id, colSpan, getContext, isPlaceholder, column, getResizeHandler, getSize }) => {
4250
const { getCanSort, columnDef, getCanResize, getIsResizing } = column
4351
const { meta } = columnDef
@@ -87,6 +95,7 @@ const HeadCell = ({ enableResize, enableSorting, headers, pinnedStyles = {}, tab
8795
tooltipText={tooltipText}
8896
width={headWidth}
8997
{...resizeFuntions}
98+
{...rest}
9099
>
91100
{isPlaceholder ? null : flexRender(column.columnDef.header, getContext())}{" "}
92101
</Table.SortingHeadCell>
@@ -110,6 +119,7 @@ const HeadCell = ({ enableResize, enableSorting, headers, pinnedStyles = {}, tab
110119
tooltipText={tooltipText}
111120
width={headWidth}
112121
{...resizeFuntions}
122+
{...rest}
113123
>
114124
{isPlaceholder ? null : flexRender(column.columnDef.header, getContext())}
115125
</Table.HeadCell>

src/components/tableV2/core/rows.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ const Rows = ({
1818
hasNextPage,
1919
loading,
2020
loadMore,
21+
coloredSortedColumn,
2122
}) => {
2223
const { onHover, hoveredRow, hoveredColumn } = useTableContext()
2324

@@ -81,10 +82,11 @@ const Rows = ({
8182
onMouseEnter={() => onHover({ row: row.id, column: cell.column.id })}
8283
onMouseLeave={() => onHover()}
8384
{...cell.column.columnDef.meta}
84-
{...(!!cell.column.getIsSorted() && {
85-
background: "successBackground",
86-
backgroundOpacity: 0.3,
87-
})}
85+
{...(coloredSortedColumn &&
86+
!!cell.column.getIsSorted() && {
87+
background: "successBackground",
88+
backgroundOpacity: 0.3,
89+
})}
8890
index={virtualRow.index}
8991
isRowHovering={row.id === hoveredRow}
9092
isColumnHovering={cell.column.id === hoveredColumn}

src/components/tableV2/features/columnPinning.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ const ColumnPinning = ({
1414
testPrefix,
1515
testPrefixCallback,
1616
scrollParentRef,
17+
...rest
1718
}) => {
1819
const getThemeColor = useColor()
1920
const headers = table.getLeftFlatHeaders()
@@ -42,6 +43,7 @@ const ColumnPinning = ({
4243
testPrefix={`pin${testPrefix}`}
4344
testPrefixCallback={testPrefixCallback}
4445
width={enableResize ? `${table.getLeftTotalSize()}px` : "100%"}
46+
{...rest}
4547
/>
4648
</Box>
4749
)

src/components/tableV2/netdataTable.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ const NetdataTable = ({
5757
testPrefix = "",
5858
testPrefixCallback,
5959
virtualizeOptions = {},
60+
coloredSortedColumn = true,
6061
...rest
6162
}) => {
6263
const [columnVisibility, setColumnVisibility] = useState(defaultColumnVisibility)
@@ -196,6 +197,7 @@ const NetdataTable = ({
196197
dataGa={dataGa}
197198
scrollParentRef={scrollParentRef}
198199
virtualizeOptions={virtualizeOptions}
200+
coloredSortedColumn={coloredSortedColumn}
199201
/>
200202
)}
201203
<MainTable
@@ -211,6 +213,7 @@ const NetdataTable = ({
211213
tableRef={tableRef}
212214
testPrefix={testPrefix}
213215
virtualizeOptions={virtualizeOptions}
216+
coloredSortedColumn={coloredSortedColumn}
214217
{...rest}
215218
/>
216219
</Flex>

0 commit comments

Comments
 (0)