Skip to content

Commit

Permalink
feat: use different icon for unsorted column
Browse files Browse the repository at this point in the history
  • Loading branch information
amje committed Jan 19, 2024
1 parent f385233 commit 174a5f2
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';

import {ArrowDown, ArrowUp} from '@gravity-ui/icons';
import {ArrowDown, ArrowUp, ArrowUpArrowDown} from '@gravity-ui/icons';

import {Icon} from '../../../../Icon';
import {block} from '../../../../utils/cn';
Expand All @@ -13,10 +13,22 @@ export interface SortIndicatorProps {

const b = block('sort-indicator');

export function SortIndicator({order = 'asc'}: SortIndicatorProps) {
export function SortIndicator({order}: SortIndicatorProps) {
let icon;
switch (order) {
case 'asc':
icon = ArrowUp;
break;
case 'desc':
icon = ArrowDown;
break;
default:
icon = ArrowUpArrowDown;
}

return (
<div className={b()}>
<Icon data={order === 'asc' ? ArrowUp : ArrowDown} size={14} className={b('icon')} />
<Icon data={icon} size={14} className={b('icon')} />
</div>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,7 @@ export function withTableSorting<I extends TableDataItem, E extends {} = {}>(
</div>,
<div key="spacer" className={b('sort-spacer')} />,
<div key="indicator" className={b('sort-indicator')}>
<SortIndicator
order={sortOrder || this.getColumnDefaultSortOrder(column)}
/>
<SortIndicator order={sortOrder} />
</div>,
];

Expand Down

0 comments on commit 174a5f2

Please sign in to comment.