Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sort order: Use unicode characters instead of svg icons #56833

Merged
merged 7 commits into from Dec 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 13 additions & 0 deletions packages/dataviews/src/style.scss
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
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