-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
120 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import React from 'react'; | ||
|
||
type Props = { | ||
selectedPairs: string[]; | ||
onPairClick: (pair: string) => void; | ||
removePair: (pair: string) => void; | ||
}; | ||
|
||
// Show a pill shaped button for each selected pair with a gap of 4px between each pair, | ||
// and a close button to remove the pair. | ||
const HistoricalSelectedPairs = ({ | ||
selectedPairs, | ||
onPairClick, | ||
removePair, | ||
}: Props) => { | ||
return ( | ||
<div className="grid grid-cols-3 md:grid-cols-2 gap-4"> | ||
{selectedPairs.map((pair) => ( | ||
<div | ||
key={pair} | ||
className="bg-gray-200 rounded-full px-4 py-1 text-xs cursor-pointer flex justify-between items-center" | ||
onClick={() => onPairClick(pair)} | ||
> | ||
<span className="flex-grow text-left">{pair}</span> | ||
<button | ||
onClick={(event) => { | ||
event.stopPropagation(); // Prevent onPairClick from being triggered | ||
removePair(pair); | ||
}} | ||
className="text-gray-600 hover:text-red-500" | ||
aria-label={`Remove ${pair}`} | ||
> | ||
✕ | ||
</button> | ||
</div> | ||
))} | ||
</div> | ||
); | ||
}; | ||
|
||
export default HistoricalSelectedPairs; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
// filter(Boolean) did not work with typescript, so had to use filter(nonNullable) to remove nulls from an array | ||
export function nonNullable<T>(value: T): value is NonNullable<T> { | ||
return value !== null && value !== undefined; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters