From a79f04ccb6653088ad373f6c18f585fa759846e8 Mon Sep 17 00:00:00 2001 From: Vincent de Graaf Date: Tue, 12 Dec 2023 08:26:51 +0100 Subject: [PATCH] Relate chevron to sorting option (#2782) --- .../components/SortIcon/SortIcon.test.tsx | 4 +-- .../components/SortIcon/SortIcon.tsx | 26 +++---------------- .../components/SortIcon/styled.tsx | 2 +- 3 files changed, 7 insertions(+), 25 deletions(-) diff --git a/src/signals/incident-management/containers/IncidentOverviewPage/components/SortIcon/SortIcon.test.tsx b/src/signals/incident-management/containers/IncidentOverviewPage/components/SortIcon/SortIcon.test.tsx index 6ff171275e..a0a51b728d 100644 --- a/src/signals/incident-management/containers/IncidentOverviewPage/components/SortIcon/SortIcon.test.tsx +++ b/src/signals/incident-management/containers/IncidentOverviewPage/components/SortIcon/SortIcon.test.tsx @@ -60,7 +60,7 @@ describe('SortIcon', () => { /> ) - expect(screen.getByTestId('chevron-up')).toBeInTheDocument() + expect(screen.getByTestId('chevron-down')).toBeInTheDocument() }) it('should render a sort icon for address desc when its asc', () => { @@ -71,7 +71,7 @@ describe('SortIcon', () => { /> ) - expect(screen.getByTestId('chevron-down')).toBeInTheDocument() + expect(screen.getByTestId('chevron-up')).toBeInTheDocument() }) it('should return null when there is no match between sortOption and selectedSortOption', () => { diff --git a/src/signals/incident-management/containers/IncidentOverviewPage/components/SortIcon/SortIcon.tsx b/src/signals/incident-management/containers/IncidentOverviewPage/components/SortIcon/SortIcon.tsx index 5c487c9a2b..eb0a737631 100644 --- a/src/signals/incident-management/containers/IncidentOverviewPage/components/SortIcon/SortIcon.tsx +++ b/src/signals/incident-management/containers/IncidentOverviewPage/components/SortIcon/SortIcon.tsx @@ -1,17 +1,9 @@ // SPDX-License-Identifier: MPL-2.0 // Copyright (C) 2023 Gemeente Amsterdam -import { StyledChevronUp } from './styled' -import { SortOptions } from '../../contants' +import { Chevron } from './styled' +import type { SortOptions } from '../../contants' import compareSortOptions from '../../utils' -const sortException = (sortOption: SortOptions) => { - return ( - sortOption === SortOptions.CREATED_AT_ASC || - sortOption === SortOptions.CREATED_AT_DESC || - sortOption === SortOptions.ID_DESC || - sortOption === SortOptions.ID_ASC - ) -} export default function SortIcon({ selectedSortOption, sortOption, @@ -31,19 +23,9 @@ export default function SortIcon({ ) return null - if (sortException(sortOption)) { - const rotateException = selectedSortOption?.startsWith('-') - return ( - - ) - } - - const rotate = !selectedSortOption?.startsWith('-') + const rotate = selectedSortOption?.startsWith('-') return ( - diff --git a/src/signals/incident-management/containers/IncidentOverviewPage/components/SortIcon/styled.tsx b/src/signals/incident-management/containers/IncidentOverviewPage/components/SortIcon/styled.tsx index 15d07c3d1b..078d6bf424 100644 --- a/src/signals/incident-management/containers/IncidentOverviewPage/components/SortIcon/styled.tsx +++ b/src/signals/incident-management/containers/IncidentOverviewPage/components/SortIcon/styled.tsx @@ -1,7 +1,7 @@ import { ChevronUp } from '@amsterdam/asc-assets' import styled, { css } from 'styled-components' -export const StyledChevronUp = styled(ChevronUp)<{ $rotated: boolean }>` +export const Chevron = styled(ChevronUp)<{ $rotated: boolean }>` transition: transform 0.25s; ${({ $rotated }) => $rotated &&