We will be using HTML, CSS, JavaScript and React.
The Gnome Fetcher project has three levels of difficulty:
- starters (challenge: build the page, add specific styling elements, make responsive, only HTML and CSS)
- more advanced (challenge: build a React app, get necessary data from the API and show this in gnome cards on the screen)
- graduates (challenge: add filter and search functionality, error handling, responsiveness)
This repo provides the code for the React app, including filter. Styling is basic.
Basic functionality: we want our app to request data from the Brastlewark API and show this in an attractive way.
Additional functionality: add a loading message when the app starts; a filter function so that the user can select a specific number of gnomes, and a search function.
This is what the app will look like without added styling. Click on the images to see them enlarged (NB: you can change the text into English if you want).
Please ignore the style.css file; this is used for the next levels of this project.
- Create a new folder on your local computer with the name: project-gnome-fetcher
- Track your code with Git by using
git init
in the terminal - Create an index.html file with the general template code
- Create a style.css file and add this to your HTML file as
<link>
(check how to add CSS to an HTML file) - Make sure you have Gnome Fetcher as the title (this will show in the tab when your app runs in the browser)
- For the images, you can use whatever pictures or screenshots you like
- Build the page and improve the example:
- show only three gnome cards per row
- add a nice shadow to the cards
- put the name title of the gnome on the card in the centre above the image and add space around it
- make the name title more attractive
- put the card button in the centre under the image and add space around it
- make the buttons more attractive
- add buttons for filter and search, and add hover effect for these buttons
- If you want to challenge yourself, try to make the app responsive by adding media queries for mobile, tablet and desktop
- You can run the app in the browser with LiveServer (a VSC extension)
- Create a project folder using
npx create-react-app
- Delete all unnecessary code
- Make sure you have Gnome Fetcher App as the title in your HTML (this will show in the tab when your app runs in the browser)
- The basic CSS code has been created in the
style.css
- Use the classNames that are in the index.css file (and save yourself some time!)
- The API we use can return a huge amount of data so ake sure you send the correct request to the API
- Create a welcome page component with some styling and an explanation of the app (don't forget to export and import components)
- Create a Population and a Person component
- In Population.js, write the code to get the Brastlewark gnomes from the API when the page loads (hint: you can use React's
useEffect()
method to load the gnomes on the page with afetch()
request) - In Person.js, create a card for each gnome with the details you get from the API (e.g. age, weight, height, hair_color, etc.)
- The gnomes should show on the screen as in the example image above: a header with the name of the gnome, an image, and a button to see more details.
- Add any styling you like to make it look better and more professional
- Create a navbar component with a home button and a button Get the Gnomes
- The home button should bring the user to the home page where they are greeted with some kind of welcome and an explanation of the app (hint: you can use React Router if you want to practice this)
- In Population.js, change the code so that you get all the gnomes from the API when the button in the navbar is clicked
- Add a Filter button with functionality to load 30, 100, 500 or 1000 gnomes.
- Add a Search button with functionality to search for a gnome name
- Add error handling
- Make the app fully responsive for mobile, tablet and desktop views
If you want to download a project on your local machine, do not fork it but clone the repo locally, on your computer. After that, create a new repo in your own GitHub account with exactly the same project name, and link the local repo to the remote repo in your GitHub account (see below). Why should you clone and not fork? It will show the project as your own project and not a fork of someone else's project. You can use it as a project for your portfolio.
You can connect a local project to a new, empty GitHub repo as follows. It is very good to know this so that you can start a project locally and afterwards link it with a remote GitHub repo.
To link your local project to your own GitHub repo, you need to change the remote origin. Have a look at this article: https://devconnected.com/how-to-change-git-remote-origin/. With git remote -v
you can again check if remote origin has been reset and now shows the name of your GitHub account.