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

Fix responsivity and improve display logic for the buttons on My Tasks #4722

Merged
merged 1 commit into from
Jun 8, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 21 additions & 14 deletions frontend/src/components/contributions/myTasksNav.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,21 @@ import { ProjectSearchBox } from '../projects/projectSearchBox';
import { useTaskContributionQueryParams, stringify } from '../../hooks/UseTaskContributionAPI';

const isActiveButton = (buttonName, contributionQuery) => {
const allBoolean = !contributionQuery.projectStatus && !contributionQuery.status;
if (
JSON.stringify(contributionQuery).indexOf(buttonName) !== -1 ||
(buttonName === 'All' && allBoolean)
) {
let isActive = false;
try {
if (contributionQuery.status.includes(buttonName)) {
isActive = true;
}
} catch {
if (contributionQuery.projectStatus === buttonName) {
isActive = true;
}
if (buttonName === 'All' && !contributionQuery.projectStatus && !contributionQuery.status) {
isActive = true;
}
}

if (isActive) {
return 'bg-blue-grey white fw5';
} else {
return 'bg-white blue-grey';
Expand All @@ -21,7 +31,7 @@ const isActiveButton = (buttonName, contributionQuery) => {
export const MyTasksNav = (props) => {
const [contributionsQuery, setContributionsQuery] = useTaskContributionQueryParams();

const linkCombo = 'link ph3 f6 pv2 ba b--grey-light';
const linkCombo = 'dib mh1 mb2 link ph3 f6 pv2 ba b--grey-light';
const notAnyFilter = !stringify(contributionsQuery);
return (
/* mb1 mb2-ns (removed for map, but now small gap for more-filters) */
Expand Down Expand Up @@ -58,33 +68,30 @@ export const MyTasksNav = (props) => {
</div>
</div>
<div className="mv2">
<Link to="" className={`di mh1 ${isActiveButton('All', contributionsQuery)} ${linkCombo}`}>
<Link to="" className={`${isActiveButton('All', contributionsQuery)} ${linkCombo}`}>
<FormattedMessage {...messages.all} />
</Link>
<Link
to="?status=MAPPED"
className={`di mh1 ${isActiveButton('MAPPED', contributionsQuery)} ${linkCombo}`}
className={`${isActiveButton('MAPPED', contributionsQuery)} ${linkCombo}`}
>
<FormattedMessage {...messages.mapped} />
</Link>
<Link
to="?status=VALIDATED"
className={`di mh1 ${isActiveButton(
'status=VALIDATED',
contributionsQuery,
)} ${linkCombo}`}
className={`${isActiveButton('VALIDATED', contributionsQuery)} ${linkCombo}`}
>
<FormattedMessage {...messages.validated} />
</Link>
<Link
to="?status=INVALIDATED"
className={`di mh1 ${isActiveButton('INVALIDATED', contributionsQuery)} ${linkCombo}`}
className={`${isActiveButton('INVALIDATED', contributionsQuery)} ${linkCombo}`}
>
<FormattedMessage {...messages.invalidated} />
</Link>
<Link
to="?projectStatus=ARCHIVED"
className={`di mh1 ${isActiveButton('projectStatus', contributionsQuery)} ${linkCombo}`}
className={`${isActiveButton('ARCHIVED', contributionsQuery)} ${linkCombo}`}
>
<FormattedMessage {...messages.archived} />
</Link>
Expand Down