Skip to content

Commit

Permalink
Sort order: Use unicode characters instead of svg icons (#56833)
Browse files Browse the repository at this point in the history
Co-authored-by: Andrew Hayward <[email protected]>
  • Loading branch information
jameskoster and Andrew Hayward authored Dec 15, 2023
1 parent 2ec7f37 commit d791ac8
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 8 deletions.
13 changes: 13 additions & 0 deletions packages/dataviews/src/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,19 @@
padding-bottom: $grid-unit-05;
}
}

.dataviews-table-header-button {
padding: 0;
gap: $grid-unit-05;

span {
speak: none;

&:empty {
display: none;
}
}
}
}

.dataviews-grid-view {
Expand Down
19 changes: 11 additions & 8 deletions packages/dataviews/src/view-table.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
import { __ } from '@wordpress/i18n';
import { useAsyncList } from '@wordpress/compose';
import {
chevronDown,
chevronUp,
unseen,
check,
arrowUp,
Expand Down Expand Up @@ -40,7 +38,7 @@ const sortingItemsInfo = {
asc: { icon: arrowUp, label: __( 'Sort ascending' ) },
desc: { icon: arrowDown, label: __( 'Sort descending' ) },
};
const sortIcons = { asc: chevronUp, desc: chevronDown };
const sortArrows = { asc: '↑', desc: '↓' };

function HeaderMenu( { field, view, onChangeView } ) {
const isSortable = field.enableSorting !== false;
Expand Down Expand Up @@ -92,12 +90,17 @@ function HeaderMenu( { field, view, onChangeView } ) {
align="start"
trigger={
<Button
icon={ isSorted && sortIcons[ view.sort.direction ] }
iconPosition="right"
text={ field.header }
style={ { padding: 0 } }
size="compact"
/>
className="dataviews-table-header-button"
style={ { padding: 0 } }
>
{ field.header }
{ isSorted && (
<span aria-hidden="true">
{ isSorted && sortArrows[ view.sort.direction ] }
</span>
) }
</Button>
}
>
<WithSeparators>
Expand Down

1 comment on commit d791ac8

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flaky tests detected in d791ac8.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/7224531112
📝 Reported issues:

Please sign in to comment.