-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Switch dropdown component to choices.js (#176)
Solves #134 <img width="1277" alt="Screenshot 2024-02-10 at 2 56 57 PM" src="https://github.com/ParkingReformNetwork/parking-lot-map/assets/101603561/1fa4c2c9-74e3-42c8-8c2f-c1610beb3946"> <img width="531" alt="Screenshot 2024-02-10 at 2 57 49 PM" src="https://github.com/ParkingReformNetwork/parking-lot-map/assets/101603561/51e4418d-3841-4eda-afe7-6ee1c47beefa"> <img width="531" alt="Screenshot 2024-02-10 at 2 57 56 PM" src="https://github.com/ParkingReformNetwork/parking-lot-map/assets/101603561/c9aef449-50d9-4ebc-b22d-9066973e282f"> <img width="531" alt="Screenshot 2024-02-10 at 2 58 04 PM" src="https://github.com/ParkingReformNetwork/parking-lot-map/assets/101603561/a4f43822-8501-4205-b7fd-010346bd1b10"> <img width="531" alt="Screenshot 2024-02-10 at 2 58 12 PM" src="https://github.com/ParkingReformNetwork/parking-lot-map/assets/101603561/889927c8-1aa0-44a5-8ad4-ad8d2bbaed88">
- Loading branch information
1 parent
f16f448
commit fed1448
Showing
7 changed files
with
131 additions
and
41 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,24 @@ | ||
import Choices from "choices.js"; | ||
import "choices.js/public/assets/styles/choices.css"; | ||
import scoreCardsData from "../../data/score-cards.json"; | ||
|
||
export const DROPDOWN = new Choices("#city-choice", { | ||
allowHTML: false, | ||
itemSelectText: "Select", | ||
searchEnabled: true, | ||
}); | ||
|
||
const setUpDropdown = (initialCityId, fallBackCityId) => { | ||
const cities = Object.entries(scoreCardsData).map(([id, { Name }]) => ({ | ||
value: id, | ||
label: Name, | ||
})); | ||
DROPDOWN.setChoices(cities); | ||
if (Object.keys(scoreCardsData).includes(initialCityId)) { | ||
DROPDOWN.setChoiceByValue(initialCityId); | ||
} else { | ||
DROPDOWN.setChoiceByValue(fallBackCityId); | ||
} | ||
}; | ||
|
||
export default setUpDropdown; |
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