We will be using HTML, CSS, JavaScript and React.
Basic functionality: we want our app to request data from the Studio Ghibli API (https://ghibliapi.herokuapp.com), to show films, locations, film directors etc.
Additional functionality: search function so that the user can search films, locations, and people.
Note: the basic CSS code has been created in the index.css
file. Don't forget to import the css! This is what the app will look like (left: basic version, right: full version including search functionality):
Steps:
- Create a new folder on your local computer with the name: project-react-film-app
- Track your code with Git by using git init in the terminal
- Create an index.html file with the general template code (there is a shortcut you can use!)
- 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 Ghibli Film App as the title in your HTML (this will show in the tab when your app runs in the browser)
- Build the page according to the example and improve the design any way you want (it is not very attractive as it is now)
- In the resources_info repository you will find links to websites where you can download pictures, images, icons etc. for free if you want to change the layout, font, colours etc.
- Feel free to use Bootstrap if you also want to practise that 😊
Basic project:
- Create a project folder using
npx create-react-app
- Delete all unnecessary code
- Make sure you have Ghibli Film App as the title in your HTML (this will show in the tab when your app runs in the browser)
- Create a header in App.js (see example image above)
- Create a Films.js component
- In Film.js write the code to get all the films from Studio Ghibli when the page loads (use the Ghibli API: https://ghibliapi.herokuapp.com)
- Create const
films
andsetFilms
to update this; you use React'suseEffect()
method to load the films on the page with afetch()
request - Show the films on the screen as in the example image above: a header with the film title, and then the film details Director, Producer, Release date and Rotten Tomato Score
- Add any styling you like to make it look better and more professional
Full project:
- Create a Search.js component
- Add an input field for a search plus a button with Search
- Add search functionality to your app so that when the user types one character in the search box, the results (film titles starting with that character) should show up immediately; each time when more characters are typed, the results that do not match should disappear
- For this, you have to create a search variable and a function to update the search in the Films component; the initial state is an empty string
- The Search component gets passed the update function from Films as a prop
- In the Search component, you create an input field for the search string; use the onChange event to update the search variable every time a character is typed as input
- The Films component should use the search variable that is updated continuously for a filter across the film titles
- The search string should return any film title that starts with the string that is typed into the input field; it should show the header with the film name, and the details Director, Producer, Release date and Rotten Tomato Score
- Add a button to clear the search. When the
Clear search
button is clicked, the filtered films are cleared and instead the full film list shows on the page - When the
Clear search
button is clicked, the search input is removed as well
You are going to change the app layout completely (see examples above):
- Align the content to the left
- Show the film title at the top, and the description of the film under the title
- Create a button under the film description that says 'Show extra info' when the button is not clicked (view is not expanded).
- When the button is clicked, it should say 'Hide extra info'
- When the button is clicked, the view should expand to show the following details:
- Original title
- Original title romanised
- Director
- Producer
- Released in: this should show the year
- Running time to be shown as h:m, for example: 1h:15m
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.