Skip to content

Commit

Permalink
Merge pull request #1341 from opentripplanner/support-sort-icon-override
Browse files Browse the repository at this point in the history
Support Sort Icon Override
  • Loading branch information
miles-grant-ibigroup authored Jan 27, 2025
2 parents 44d769e + f8634f3 commit 12e76dd
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions lib/components/narrative/narrative-itineraries-header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ import { FormattedMessage, useIntl } from 'react-intl'
import { Itinerary } from '@opentripplanner/types'
import { SortAmountDown } from '@styled-icons/fa-solid/SortAmountDown'
import { SortAmountUp } from '@styled-icons/fa-solid/SortAmountUp'
import React, { useCallback } from 'react'
import React, { useContext } from 'react'
import styled from 'styled-components'

import { ComponentContext } from '../../util/contexts'
import { IconWithText, StyledIconWrapper } from '../util/styledIcon'
import { ItinerarySortOption } from '../../util/config-types'
import { sortOptions } from '../util/sortOptions'
Expand Down Expand Up @@ -77,6 +78,12 @@ export default function NarrativeItinerariesHeader({
}): JSX.Element {
const intl = useIntl()

// Use customized sort icons or fall back to the defaults
// @ts-expect-error Context not typed
const { SortIconDown, SortIconUp } = useContext(ComponentContext)
const SortUp = SortIconUp || SortAmountUp
const SortDown = SortIconDown || SortAmountDown

const itinerariesFound = intl.formatMessage(
{
id: 'components.NarrativeItinerariesHeader.itinerariesFound'
Expand Down Expand Up @@ -198,9 +205,9 @@ export default function NarrativeItinerariesHeader({
className={`${customBatchUiBackground && 'base-color-bg'}`}
>
{sort.direction.toLowerCase() === 'asc' ? (
<SortAmountUp />
<SortUp />
) : (
<SortAmountDown />
<SortDown />
)}
</StyledIconWrapper>
</button>
Expand Down

0 comments on commit 12e76dd

Please sign in to comment.