Skip to content

Commit

Permalink
Header errors corrected
Browse files Browse the repository at this point in the history
  • Loading branch information
nz970 committed Jul 8, 2024
1 parent 7eab3b0 commit 52ad4ae
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 61 deletions.
Original file line number Diff line number Diff line change
@@ -1,71 +1,13 @@
import React, { useEffect, useRef, useState } from 'react';

export default props => {
const [ascSort, setAscSort] = useState('inactive');
const [descSort, setDescSort] = useState('inactive');
const [noSort, setNoSort] = useState('inactive');
const refButton = useRef(null);
const refLabel = useRef(null);

const onMenuClicked = () => {
props.showColumnMenu(refButton.current);
};

const onSortChanged = () => {
setAscSort(props.column.isSortAscending() ? 'active' : 'inactive');
setDescSort(props.column.isSortDescending() ? 'active' : 'inactive');
setNoSort(
!props.column.isSortAscending() && !props.column.isSortDescending()
? 'active'
: 'inactive',
);
};

const onSortRequested = (order, event) => {
props.setSort(order, event.shiftKey);
};

useEffect(() => {
props.column.addEventListener('sortChanged', onSortChanged);
onSortChanged();
}, []);

let sort = null;

if (props.enableSorting) {
sort = (
<>
<div
onClick={event => onSortRequested('asc', event)}
onTouchEnd={event => onSortRequested('asc', event)}
className={`customSortDownLabel ${ascSort}`}
role="button"
tabIndex="0"
>
<i className="fa fa-long-arrow-alt-down" />
</div>
<div
onClick={event => onSortRequested('desc', event)}
onTouchEnd={event => onSortRequested('desc', event)}
className={`customSortUpLabel ${descSort}`}
role="button"
tabIndex="0"
>
<i className="fa fa-long-arrow-alt-up" />
</div>
<div
onClick={event => onSortRequested('', event)}
onTouchEnd={event => onSortRequested('', event)}
className={`customSortRemoveLabel ${noSort}`}
role="button"
tabIndex="0"
>
<i className="fa fa-times" />
</div>
</>
);
}

return (
<div className="headerWrapper">
<div
Expand All @@ -75,12 +17,11 @@ export default props => {
role="button"
tabIndex="0"
>
<i className={`fa ${props.menuIcon}`} />
<i className="fa fa-bars" />
</div>
<div ref={refLabel} className="customHeaderLabel">
{props.displayName}
</div>
{sort}
</div>
);
};
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.headerWrapper {
display: flex;
overflow: hidden;
gap: 0.5rem;
gap: 0.7rem;
}

.customHeaderLabel {
Expand Down

0 comments on commit 52ad4ae

Please sign in to comment.