Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Week2 #8

Open
wants to merge 29 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
5a320df
Transfer file from another repo to this one
niyorn Feb 12, 2018
d2e94d2
Add todo for this week
niyorn Feb 12, 2018
e32d175
assignment 1
niyorn Feb 12, 2018
695a228
api set-up
niyorn Feb 12, 2018
f2f791a
add basic styling
niyorn Feb 12, 2018
cfc39d3
Merge pull request #1 from niyorn/week2
niyorn Feb 12, 2018
f95e48c
Add color to styling
niyorn Feb 12, 2018
90d1101
Merge pull request #2 from niyorn/week2
niyorn Feb 12, 2018
c904785
Add color to value change
niyorn Feb 14, 2018
ea8d216
Add comment to code
niyorn Feb 14, 2018
b54d0a4
Add images to coins
niyorn Feb 14, 2018
7bfa067
Add 1h change
niyorn Feb 14, 2018
13d2412
Add responsiveness
niyorn Feb 14, 2018
76afb15
add lower resolution images on small screen
niyorn Feb 14, 2018
fb628bf
Remove unnesecary check price
niyorn Feb 14, 2018
3d991be
Merge pull request #4 from niyorn/week2
niyorn Feb 14, 2018
703df2d
32 is too low resolution, 64 is better
niyorn Feb 14, 2018
7170010
Merge pull request #5 from niyorn/week2
niyorn Feb 14, 2018
cd2e704
Add more info for the coins when clicked
niyorn Feb 14, 2018
e22cf59
Merge pull request #6 from niyorn/week2
niyorn Feb 14, 2018
51ca2a8
Add promise handler to request
niyorn Feb 16, 2018
0da642b
Merge pull request #7 from niyorn/week2
niyorn Feb 16, 2018
03d39d7
Added a base for detail route.Some cleaning.
kyunwang Feb 16, 2018
f93d7c8
Merge pull request #8 from kyunwang/patch-4
niyorn Feb 16, 2018
007e9bf
creating detal-page
niyorn Feb 16, 2018
c390549
Merge branch 'master' of https://github.com/niyorn/wafs
niyorn Feb 16, 2018
7963b4c
Add detail page
niyorn Feb 16, 2018
a43ed2a
add right data detail
niyorn Feb 16, 2018
77da158
add back button
niyorn Feb 16, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 69 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,74 @@
# wafs
The course repo for 'Web App From Scratch'
# Web-App-from-Scratch
This is an single page web app. It is created from scratch without using any unnecessary libraries.

## Advantages and disadvantages of JavaScript libraries/frameworks
...
## Single page web app in general
*A single-page application (SPA) is an app that works inside a browser and does not require page reloading during use. You are using this type of applications every day. These are, for instance: Gmail, Google Maps, Facebook or GitHub.*

## Advantages and disadvantages of client-side single page web apps
...
### Pro
- SPA is fast, as most resources (HTML+CSS+Scripts) are only loaded once throughout the lifespan of application. Only data is transmitted back and forth.

- SPA can cache any local storage effectively. An application sends only one request, store all data, then it can use this data and works even offline.

- The development is simplified and streamlined. There is no need to write code to render pages on the server. It is much easier to get started because you can usually kick off development from a file file://URI, without using any server at all.

### Con
- It is slow to download because heavy client frameworks are required to be loaded to the client.

- It requires JavaScript to be present and enabled. If any user disables JavaScript in his or her browser, it won’t be possible to present application and its actions in a correct way.

Neoteric ('Single-page application vs. multiple-page application'), taken from: https://medium.com/@NeotericEU/single-page-application-vs-multiple-page-application-2591588efe58

## Frameworks in general

### Pro
- A good programmer know how to get the job done well and fast. If you don't need to write code from scratch why should you? Frameworks are just tools, tools that any profession has to work better.

- Efficiency is also about lines of code.


### Con

- If you don't know the underlying principles of the web, you'll eventually hit a wall thanks to the evolution of the language itself and the constant arrival of new frameworks.

- People start using frameworks and libraries without even thinking about how to solve the problem without them. Often, a solution in VanillaJS is very easy, but people are so used to work with frameworks and libraries that they load a lot of extra code to do very simple things.


Francois-Xavier P. Darveau ('Yes, You Should Learn Vanilla JavaScript Before Fancy JS Frameworks'), taken from: https://snipcart.com/blog/learn-vanilla-javascript-before-using-js-frameworks

Marco Alka ('Vanilla JavaScript vs. Frameworks & Libraries sFinding a good balance'), taken from : https://hashnode.com/post/vanilla-javascript-vs-frameworks-and-libraries-finding-a-good-balance-civ1zfus90pphdc53q8vtakz5

## Best practices
...


## Inspiration
*The first thing I did was looking for inspiration and and good examples of single page application.*

### district0x
url: https://district0x.io/

District0x makes great use of typography, color, and scroll animation. When viewing the site on mobile, the site is still great to use. The animation that is displayed still plays at around 60fps. And there is alot of whitespaces that gives the content more air to display itself.\
![district0x](readme-assets/district0x.gif "district0x")

### Kollergorna
url: https://radar.kollegorna.se/

Kollergorna is a beautifull site that doens't use a traditional layout. Also they give the user an option to view their content in a different layout. Lastly the loadying of the content in insanely fast.

![Kolergona](readme-assets/kollergorna.gif "kolergona")


# To do
1. Create an issue for Leonie
2. Create an issue for Kevin
3. create responsive menu
4. Best practices
5. Manage routes en states
6. Get / Post data van/naar API
7. Data manipuleren
8. Data presenteren
9. Web Worker implementeren (extra)
10. Code review



31 changes: 31 additions & 0 deletions app/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Web app</title>
<link href="https://fonts.googleapis.com/css?family=Roboto:400,700" rel="stylesheet">
<link rel="stylesheet" href="static/style/style.css">
</head>

<body>

<section id="start" class="crypto">
<div>
<a data-bind="coin_id" href="">
<span data-bind="rank" class="rank"></span>
<span data-bind="name" class="name"></span>
<span data-bind="price" class="price"></span>
<span data-bind="percent_change_24h" class="change change-24"></span>
</a>
</div>
</section>

<script src="static/script/routie.js"></script>
<script src="static/script/transparency.js"></script>
<script src="static/script/app.js"></script>
</body>

</html>
Empty file removed app/static/css/styles.css
Empty file.
Empty file removed app/static/js/script.js
Empty file.
82 changes: 82 additions & 0 deletions app/static/script/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
//Use IIFE to create variable but only in the IIFE scope
(function () {
'use strict'; //use strict mode only in this scope

var app = {
init: function () {
let xhr = new XMLHttpRequest();
let url = "https://api.coinmarketcap.com/v1/ticker/";
xhr.open("GET", url, true);
xhr.onload = function (e) {
if (xhr.readyState === 4) {
if (xhr.status === 200) {
var data = JSON.parse(xhr.responseText);
routes.init(data); //init route
} else {
console.error(xhr.statusText);
}
}
};
xhr.send();
}
}

var routes = {
init: function (data) {
this.routie(data);
},
routie(data) {
routie({
'': function () { //start page
section.insert(data);
},
'/detail/*': function () {
section.insert(data);
}
});
}
}

var section = {
toggle: function (route) {

//remove all active class
let section = document.querySelectorAll('section');
section.forEach(function (i) {
i.classList.remove('active');
});

//Add active class to the page-link that you've clicked
document.querySelector(route).classList.add('active');
},

insert: function (data) {
let dataCoin = data.map(function (i) { //Map function thanks to Keving Wang
return {
id: i.id,
rank: i.rank,
name: i.name,
price: i.price_usd,
percent_change_24h: i.percent_change_24h
}
});

let directives = {
coin_id: {
href: function (params) {
return "index.html/detail/" + this.id
},
percent_change_24h: {
class: function (params) {
return this.percent_change_24h
}
}
}
};

Transparency.render(document.querySelector('#start div'), dataCoin, directives);
}
}

app.init(); //start application
})();
Loading