This lab is based on the book Atlas of Remote Islands: Fifty Islands I Have Never Set Foot On and Never Will by Judith Schalansky. The book describes 50 remote islands from around the world; data about those islands has been collected into the src/atlas-of-remote-islands.js
file. Your goal is to represent the islands as options on a travel-like site.
NOTE: A geographic map and a
.map()
method are two different things, and the meanings can get a little muddled if you aren't careful. The reason the.map()
method is named how it is - each item in the new array corresponds to (maps to) an item in the original array. For our purposes, we're going to be careful to use the phrase.map()
when we mean the method, and Map when we mean the geographic representation.
- Clone this repository using
git clone
cd
into the project foldernpm install
npm start
-
Note that
App.js
is importing thedata
fromatlas-of-remote-islands.js
, and there is aconsole.log(data)
as part ofApp.js
. Open the Developer Tools in your browser and explore thedata
object. -
One card has already been componentized for you. Use
.map()
to updateApp.js
so that it generates a card for each entry indata.islands
.
It's ok if the cards don't yet have any data in them, but there should be a total of 50 cards.
-
Update your
.map()
function to pass data about each island to each card as props. You canconsole.log(props)
inCard.js
to check that props are being passed. -
From
Card.js
, pass props to the<CardInfo />
component for the island name, description, latitude, longitude, and Wikipedia link. -
Display the island name, description, latitude, and longitude in the card. Then pass the Wikipedia link as a prop to the
<WikiButton />
component, and set thehref
for the<a>
tag around the button. Clicking on each button should open that island's Wikipedia page in a new tab. -
Pass the
image
URL to<CardImage />
component, and check thatCardImage.js
is receiving it. -
Use inline styling to set the
backgroundImage
of the<div>
withclassName=card-image
as theimage
passed to<CardImage />
via props.
- Add a new component to each card that renders a Google Map of each island (see above). There are several ways to do this!
Hint: you can use the latitude and longitude along with Google Maps'
<embed>
code; also, set the width of the embed to100%
to fill the container.
Depending on how you've accomplished this, consider commenting out this component while you work on the remaining tasks so you're not re-rendering the maps each time.
- Update the interface to group cards by their
region
: Arctic Ocean, Atlantic Ocean, Indian Ocean, Pacific Ocean, Antarctic Ocean. How might you pre-process thedata
in order to get a list of all unique regions?
Hint: consider how you might use the
.filter()
method to populate cards in each section.
- Add an option that sorts islands (a) alphabetically by name (A to Z), or (b) by page number (lowest to highest). Store the choice in state and apply the sort to each region.