diff options
| author | bvdoord <bvdoord@sogyo.nl> | 2019-02-25 08:21:20 +0100 |
|---|---|---|
| committer | bvdoord <bvdoord@sogyo.nl> | 2019-02-25 08:21:20 +0100 |
| commit | 72894723f6f1eb3ec07da8ab50c419dd17ea0c19 (patch) | |
| tree | 1b31d728c0f8448aac68aefbbeaac266ca8a3824 | |
| parent | 218c9918d212f3b0d9a3c8368ad53f7b15b183f6 (diff) | |
Duidelijkere opzet
| -rw-r--r-- | readme.md | 78 |
1 files changed, 41 insertions, 37 deletions
@@ -4,7 +4,7 @@ Sogyo Adventure is a new service for Sogyo employees to buy family tickets for a Because Sogyo Adventure wants a single, consistent theme throughout their site, the styling defined in `main.css` should be used across all pages. The stylesheet has already been referenced on the index page (also known as a home page) and should be included in the same manner on all other pages. -The target market being Sogyo employees the webshop can get away with assuming its userbase uses the latest version of Chrome, Firefox, Edge and other up to date browsers. This means that even though it's commonly advised to support as many older browsers as possible, Sogyo Adventure has the freedom to use the latest web technology. This includes (but is not limited to): +The target market being Sogyo employees, the webshop can get away with assuming its userbase uses the latest version of Chrome, Firefox, Edge and other up to date browsers. This means that even though it's commonly advised to support as many older browsers as possible, Sogyo Adventure has the freedom to use the latest web technology. This includes (but is not limited to): * Flexbox * CSS grid * CSS variables @@ -16,9 +16,13 @@ The target market being Sogyo employees the webshop can get away with assuming i To get an idea of what Sogyo Adventure could look like, a prototype will first be build. Your assignment is to make that first prototype. For now you won't have to worry about security, authorisation, payment and other such things. Of course all of those are important in real life applications, but not in the prototype. +For the time being we will focus solely on the files in the `client` folder. + Open `index.html` in your browser of choice to see what the the application looks like to users. Also open `index.html` in your favorite editor. If you make changes to the html file, you'll need to reload that page in your browser. By using the developer tools within your browser, you can usually edit the html and/or css on the go, but changes aren't saved. -# ** Task 1: styling ** +# Task 1: styling + +Take about a day for this first task. If you can't complete it in that timeframe, don't worry. Just move on with the other tasks and come back to it later. There's a few requirements to the look and feel of the page: * The header should always be at the top of the page, even if the user scrolls down, so that the shopping basket is easily accessible @@ -28,46 +32,21 @@ There's a few requirements to the look and feel of the page: * Style the 'add to shopping basket' button so it doesn't look like the default. * Set a favicon (the tiny icon shown in the browsers tab bar next to the tab name) -The layout should be responsive, i.e. work on desktop, tablet and phone. Use CSS media queries to set three breakpoints in your layout: smaller than 480px in width, smaller than 780px in width and bigger than that. - -On small devices: -* The Sogyo Adventure title bar should use 1.5rem size fonts and be 45px in height -* The blocks with available parks should take up the whole screen width -* The white bar with the Sogyo logo shouldn't be shown -* The navigation bar should be 32px in height - -On medium devices: -* The Sogyo Adventure title bar should use 2rem size fonts and be 60px in height -* Two parks should be shown next to each other -* The white bar with the Sogyo should be 200px high -* The navigation bar should be 32px in height - -On large devices: -* The Sogyo Adventure title bar should use 3rem size fonts and be 80px in height -* At least three parks should be shown next to each other -* The white bar with the Sogyo should be 200px high -* The navigation bar should be 32px in height - -On `map.html`: -* The div `#discoverablemap` should be 100vw (view width) wide and 100vh (view height) tall, minus the whole width of the white logo bar, the title bar and the navigation bar. This should result in the map taking up all remaining space. - Otherwise get creative! Try changing colors, fonts, color gradients, borders, rounded corners, shadows, transforms, animations, etc. Don't forget that the different pages should look and feel similar, yet clearly distinct from each other. It helps if you get comfortable with the idea of CSS selectors. `main.css` uses different three different kinds of CSS selectors by default, with comments describing what they do, but CSS selectors can be composed and there's more advanced ones as well. -You have about a day for this task (working on the requirements first before getting creative). - -# ** Task 2: the index page ** +# Task 2: the index page The buttons to order tickets will all get the same functionality. A so called event listener that gets fired when the user clicks on one of those buttons. The following steps will guide you through the process of registering event listeners and implementing their behavior. Don't worry about the discounts for family tickets just yet. -1. Define a function on the top level of your script that will act as the event listener for the "order" buttons. Name this function `orderButtonClicked`. Register it on every button using `document.querySelectorAll()` with a CSS selector as the first argument, iterating over all matching elements and finally calling `.addEventListener()` of type `"click"`. -2. Add a call to `console.log()`to the body of `orderButtonClicked`. Open the developer tools in your browser. Click on the order the buttons. Is the call properly logged? If not: debug! +1. Define a function on the top level of `index.js` that will act as the event listener for the "order" buttons. Name this function `orderButtonClicked`. Register it on every button using `document.querySelectorAll()` with a CSS selector as the first argument, iterating over all matching elements and finally calling `.addEventListener()` of type `"click"`. The browser will automatically call `orderButtonClicked` when the user clicks on the elements you've registered the event listener on. +2. Add a call to `console.log()`to the body of `orderButtonClicked`. Open the developer tools in your browser. Click on the order buttons. Is the call properly logged? If not: debug! 3. Write a separate function named `saveOrderInShoppingBasket` that will be called from `orderButtonClicked`. This function should receive three arguments: the name of the chosen attraction, the number of adults and the number of children. Give each of the parameters a sensible name. -4. Your event listener receives information on the event as the first argument. Add it to the parameter list, so it can be accessed from within the function. This object has a `.target` property, in our case the element the user clicked on (the order button.) Use this element reference as a starting point and walk the DOM tree using methods and properties like `parentNode`, `classList.contains()`, `nextElementSibling`, `previousElementSibling`, among others. We are interested in three nodes: the `<div>` containing the attraction name as the text content and two `<input>` elements for the user to enter numbers. -5. From your event listener pass the following information to `saveOrderInShoppingBasket`: the name of the attraction (obtained by calling `.innerText` on the `<div>` element), the number of adults (obtained by calling `.value` on the `<input>` element and casting the result to a number) and the number of children (obtained the same way). +4. Your event listener receives information on the event as the first argument. Add an argument named `event` to the parameter list of `orderButtonClicked`. This object has a `.target` property, in our case the element the user clicked on (the order button.) Use this element reference as a starting point and walk the DOM tree using methods and properties like `parentNode`, `classList.contains()`, `nextElementSibling`, `previousElementSibling`, among others. We are interested in three nodes: the `<div>` containing the attraction name as the text content and two `<input>` elements for the user to enter numbers. +5. From `orderButtonClicked` pass the following information to `saveOrderInShoppingBasket`: the name of the attraction (obtained by calling `.innerText` on the `<div>` element), the number of adults (obtained by calling `.value` on the `<input>` element and casting the result to a number) and the number of children (obtained the same way). 6. Implement `saveOrderInShoppingBasket`. The order should be saved locally on the clients machine in a way that allows the user to close the browser without the order being lost by using `localStorage`. The `localStorage` is a key-value pair store that works with string values only. You'll need to think of a way to persist/save several orders at once. 7. Once the order is added to the shopping basket the number of items in the shopping basket should be updated. It's displayed in the element with class `"badge"` under the `"#shoppingbasket"`. -# ** Task 3: Shopping Basket ** +# Task 3: Shopping Basket We'll now implement the shopping basket, in `shoppingbasket.html` and `shoppingbasket.js`. @@ -75,7 +54,7 @@ We'll now implement the shopping basket, in `shoppingbasket.html` and `shoppingb 2. `shoppingbasket.html` defines a template, i.e. the HTML that should be used for each of the users ordered tickets, but the template itself is never shown to the user. Iterate over each ticket in the shopping basket and add a node to the `<main>` element for each ticket, based on the pre-defined `<template>`. Make sure to display the correct park name, number of adults and number of children on each ticket. The button to finalize the order should remain at the bottom of the page. 3. Add an event listener to the finalize payment method. As this is only a prototype, we skip handling the actual payment. Instead simply call `api/placeorder` using the `fetch()` method. After the request has been handled clear the users shopping basket and redirect them to `orderplaced.html`. The fetch probably fails right now. That's because there's no server to fetch the resources from. -# ** Task 4: The server ** +# Task 4: The server 1. Install the Node.js webserver (https://nodejs.org/en/) and run the `npm install` command in the main folder of the project. This downloads the project dependencies defined in `package.json`. Finally run the project using `node main.js` and going to `localhost:8000` in your browser. You should see the working version of the Sogyo Adventure webshop so far. 2. Open `main.js` and look at the various routes defined there. Before continuing with the other tasks, understand what each of the routes does and what they might do. @@ -87,12 +66,37 @@ We'll now implement the shopping basket, in `shoppingbasket.html` and `shoppingb It helps if you're familiar with the basics of API's. Look into: HTTP requests, HTTP verbs and HTTP response codes. -# ** Task 5: Discoverable Map ** +# Task 5: A responsive design (optional) + +The layout should be responsive, i.e. work on desktop, tablet and phone. Use CSS media queries to set three breakpoints in your layout: smaller than 480px in width, smaller than 780px in width and bigger than that. + +On small devices: +* The Sogyo Adventure title bar should use 1.5rem size fonts and be 45px in height +* The blocks with available parks should take up the whole screen width +* The white bar with the Sogyo logo shouldn't be shown +* The navigation bar should be 32px in height + +On medium devices: +* The Sogyo Adventure title bar should use 2rem size fonts and be 60px in height +* Two parks should be shown next to each other +* The white bar with the Sogyo should be 200px high +* The navigation bar should be 32px in height + +On large devices: +* The Sogyo Adventure title bar should use 3rem size fonts and be 80px in height +* At least three parks should be shown next to each other +* The white bar with the Sogyo should be 200px high +* The navigation bar should be 32px in height + +# Task 6: Discoverable Map (optional) + +Work in `map.html` and `map.js`: +* The div `#discoverablemap` should be 100vw (view width) wide and 100vh (view height) tall, minus the whole width of the white logo bar, the title bar and the navigation bar. This should result in the map taking up all remaining space. 1. Install Leaflet.js (https://leafletjs.com/) and follow the instructions on https://maps.stamen.com (specifically those for Leaflet), replacing `"element_id"` in the example code with `"map"`. Stamen provides rendered map tiles based on the Open Street Map data, Leaflet is a library to work with those map tiles. As a starting point choose `(52.1026406, 5.175044799999999)` with a zoom level of 10. This should result in a large map of The Netherlands. Note: you're free to choose between the Toner, Terrain or Watercolor maps Stamen offers. 2. After the map has done loading, fetch all attractions from `api/attractions` and display a marker for each attraction. The user should be able to click on the marker to see the attraction name and description. -# ** Task 6: Finalizing the prototype (optional) ** +# Task 7: Finalizing the prototype (optional) If you're done with tasks 1 through 5 and have some time left, look into the following additional tasks to really complete the shop: @@ -101,7 +105,7 @@ If you're done with tasks 1 through 5 and have some time left, look into the fol * Display a list of attractions ordered by prize. Allow the user to sort from highest to lowest or lowest to highest. In addition you may also allow sorting nearby to far away. * Update your client side code to TypeScript instead of JavaScript. At the very least, define parameter types and return value types. The compiler should be able to infer the types of variables based on these other two type definitions. -# ** Task 7: Integration with a Database ** +# Task 8: Integration with a Database This step should only be completed after the Database case has been completed. |
