GithubHelp home page GithubHelp logo

rrmba's Introduction

RRMBa

WHY

How many times you would have wished you knew the status of the tube line you were going to take? Maybe if you had known you were going to feel that frustrated you would have changed your route!

We felt it was useful to display the information about the status of the tubes lines as well as illustrating how you would feel after taking them.

WHAT

In our website, when clicking on the tube line that you will be using, the information regarding the status of the line will be displayed as well as an image indicating you how you would feel after using it.

HOW

Software Architecture


We begin

We change our mind

Let's talk about our file structure..

Almost there

First pseudo code

Much clearer!

Ta Da!

File Structure


We decided to divide our code in 4 folders:

  • HTML
  • CSS
  • Logic - where our pure functions (logic.js), tests (logic.test.js) and Dom.js will be written.
  • Resources
  • ReadMe

There was a initial discussion about creating another file inside logic called API.js where our not-pure functions will be written. That would allow us to have 100 % test coverage and have all the pure functions together. However, to make the code more readable, we decided not to take this approach.

Logic


Once the pseudocode was ready to be implemented, each pair started writing tests for a couple of functions. Once the test failed (you all know how TDD works ;) ), we started writing the code for our pure and not to so pure (ex. apicall) functions.

As a consequence of our not pure functions, once we got the data from the server, the tests do not longer pass.

A great function that helped our code being clearer and work better was the waterfall function, which passes an array of functions as first argument, and an array of urls as a second one which will run in series.

DOM


Almost all the magic happened in our logic file. However, we needed two main things to make it work:

  • Our event listener which will get the data that the user has selected.
  • And our render function which will get the data obtained by the functions in our logic file.

CSS


We did not go crazy with the css, some cool details could be:

  • Tube lines' style so they matched the underground colors: For this, we created radio buttons in our form in order to style them properly later on in our stylesheet.

Ahh..and we used the London Tube font! =)

Do you want to run this project in your own computer?

In your terminal, you should run the following commands:

Learning

Styling Radio buttons

Waterfall functions

XML HttpRequest

rrmba's People

Contributors

bartbucknill avatar maxgerber avatar rachaelcodes avatar rebecacalvoquintero avatar

Watchers

 avatar  avatar

rrmba's Issues

Really fun app!

Good idea, amazing execution, bold design, I love it guys!! ❤️ 🍺 🌵 💯

Update the line names

here is a list of the line ids that the tfl api uses - can we update our HTML form to return these? (this might mean we don't need the parsing name function in logic.js and have to cut out a couple of lines like TFL rail)

exports.lines = {

  | "bakerloo": "Bakerloo",
  | "central": "Central",
  | "circle": "Circle",
  | "district": "District",
  | "hammersmith-city": "Hammersmith & City",
  | "jubilee": "Jubilee",
  | "metropolitan": "Metropolitan",
  | "northern": "Northern",
  | "piccadilly": "Piccadilly",
  | "victoria": "Victoria",
  | "waterloo-city": "Waterloo & City"
  | };

could we use iife for all dom.js content?

Currently we expose the render function for easy access in the global scope by simply putting it outside the iife. We could avoid exposing it all together by putting everything inside the iife and passing the render function to logicObj.init as a callback parameter, which init passes towaterfall, and which is called when waterfall has completed the tasks array

Mock data in tests

There's quite a lot of mock API data in your tests file. This makes the tests hard to read.

Maybe think about alternative ways to organise this. For example, you could have all the mock data saved in another file, and use variables to refer to it. Or you could have global variables at the top of your file.

Suggestion

Would be nice to see the words "Good service" refreshing when you click on another line so that you know it updates with the correct information.

Accessibility: contrast ratio on tram and overground blocks

There's a yellow warning as follows:

Text elements should have a reasonable contrast ratio (2)

<span class=​"line-text">​London Overground​​
<span class=​"line-text">​Tram​​

Proposed solution: get TFL to change their official overground and tram lines colours? 😅

single click triggers 2 events causing double api calls and double renders

On clicks after the first (not including the first), two events fire and thus init is called twice. This triggers an api call based on the line clicked, the result of which is rendered, and then a second api call and render for the same line.
A quick fix is to set checked to false as in this snippet from dom.js:

form.addEventListener( 'click', function( e ) {
    tubeLines.forEach( function( line ) {
     if ( line.checked ) {
        line.checked = false;
        logicObj.init( line.value );

This means that the second time forEach loops it does not find a truthy line.checked.

But we should really fix the root cause.
The event.target for the two events are different; the event.target that gets through first is the containing label element, and second is the input element. An answer to this stackoverflow question suggests that might want to consider making label and input elements siblings, rather than making label the containing element.
This relates to #50, perhaps the two could be fixed together.

create a map.js file

this will contain the mapping object between tfl status codes and giphy search terms

  • declare the variable: var mapReference = [{line-status1: search term1}...]
  • declare map.js in the html file, along with other js files
  • mapReference will be available as a global object in logic.js
    (it worked in another project I've done)

Great project!

Not an issue just love the project it's hilarious 😄. Right actual issues now

make user stories

what do we want our different users to experience

think about accessibility

Well Organised Css One little thing

Good use of a thorough css reset and structure generally of your CSS file, in the interest of the DRY principle (Do Not Repeat yourself) your browse loads in 10 duplicate lines of color white It seems like a small thing but how quickly your css loads depends on how big it is this in turn impacts the performance of your webpage youll have future talks on performance I hope but its a good habit to get into because users are not very patient

resources
https://developers.google.com/web/fundamentals/performance/
http://www.hongkiat.com/blog/ultimate-guide-to-web-optimization-tips-best-practices/

Error handling

Nice app and great work on the logic. It would be good to see some more handling of errors. In the waterfall, if one thing goes wrong it will break the whole app.

Remove unused files

perhaps remove unused files for example the unused jpegs as this could affect website performance

Accessibility check

Run an HTML accessibility audit:

  • in particular, make sure that the form is accessible via screen reader
  • is there a voiceover option for the Giphy image?

Project Instructions

Hey guys I love your readme although for next time I would always get in the habit of document how people should run your projects locally e.g.

  • git clone {REPO_NAME}
  • npm i
  • To run test run npm test or tape ....

The logic behind this is you dont know who is going to be looking at your projects/future products and its definitely not immediately obvious especially if I were say a java developer for example who was interested and maybe wanted to hire a node developer 😆 😉

what the ..name??

Great work guys but personally I would avoid any association with the world of the dead (i.e. Hades)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.