mirror of https://github.com/01-edu/public.git
OGordoo
4 years ago
4 changed files with 143 additions and 2 deletions
@ -0,0 +1,41 @@
|
||||
#### Functional |
||||
|
||||
###### Does the project contain documentation? (If so, you will need it) |
||||
|
||||
##### Create a project and use the mini-framework in it and try to run `npm start` at the root folder of the project. |
||||
|
||||
###### Did the website start without errors from the framework? |
||||
|
||||
##### First take a look at the behavior of the code presented in the [_dom/README.md_](https://public.01-edu.org/subjects/mini-framework/dom) file. Then try to replicate the behavior of the example with the corresponding template of the framework and run the app. |
||||
|
||||
###### Can you create the red box and the button present in the example? |
||||
|
||||
##### With the same example as above, open the Web Developer Tools (Ctrl+Shift+I) and go to the Inspector Tab. |
||||
|
||||
###### Are the elements created as they should (the red box and the button inside the app div)? |
||||
|
||||
##### Still on the Inspector Tab, does all the elements have the right attributes (id, class, style)? |
||||
|
||||
###### With the same example, did the box move when you clicked the button? |
||||
|
||||
##### First take a look at the behavior of the code presented in the [_routing/README.md_](https://public.01-edu.org/subjects/mini-framework/routing) file. Then try to replicate the behavior of the example with the corresponding template of the framework and run the app. (Making the page reload is not required) |
||||
|
||||
###### Were you able to switch between the two pages? |
||||
|
||||
###### With the same example as above, did the URL changed when you switch between pages? |
||||
|
||||
##### With the same example, try to define a state by assigning a value to it in the 'Home Page' and then switch to the 'Active Page'. |
||||
|
||||
###### If you check the state, does it kept the value assigned to it? |
||||
|
||||
#### Bonus |
||||
|
||||
###### +Is the performance similar both in the framework code and the examples above? |
||||
|
||||
###### +Is it easier to handle the DOM using the framework than it is to use plain HTML and JS? |
||||
|
||||
###### +Is it easier to handle the routing in JS using the framework? |
||||
|
||||
###### +Does the project runs quickly and effectively? (Favoring recursive, no unnecessary data requests, etc) |
||||
|
||||
###### +Is the code using synchronicity to increase performance? |
@ -0,0 +1,36 @@
|
||||
## DOM example |
||||
|
||||
The example consists in a red box moving by clicking on a button. |
||||
|
||||
```html |
||||
<!DOCTYPE html> |
||||
<html class="no-js"> |
||||
<head> |
||||
<meta charset="utf-8" /> |
||||
<title>SSS</title> |
||||
</head> |
||||
<body> |
||||
<div id="app"> |
||||
<div |
||||
id="box" |
||||
style=" |
||||
width: 100px; |
||||
height: 100px; |
||||
background: red; |
||||
transition: 0.3s; |
||||
transform: translateX(0px); |
||||
" |
||||
></div> |
||||
<button id="button" class>Click Me</button> |
||||
</div> |
||||
</body> |
||||
<script> |
||||
document.getElementById('button').addEventListener('click', (e) => { |
||||
let box = document.getElementById('box') |
||||
let actualTranslate = Number(box.style.transform.match(/\d+/g)[0]) + 50 |
||||
box.style.transform = `translateX(${actualTranslate}px)` |
||||
console.log(box.style.transform) |
||||
}) |
||||
</script> |
||||
</html> |
||||
``` |
@ -0,0 +1,62 @@
|
||||
## Routing example |
||||
|
||||
The example consists in switching between a **'Home Page'** to a **'Active Page'** by clicking on a **'Click Me'** hyperlink. |
||||
|
||||
You will need to two or three files depending if you include the script on the html files or not. All files should be in the same folder. |
||||
|
||||
index.html: |
||||
|
||||
```html |
||||
<!DOCTYPE html> |
||||
<html class="no-js"> |
||||
<head> |
||||
<meta charset="utf-8" /> |
||||
<title></title> |
||||
</head> |
||||
<body> |
||||
<h1>Home Page</h1> |
||||
<a href="./active">Click here</a> |
||||
<script src="./script.js"></script> |
||||
</body> |
||||
</html> |
||||
``` |
||||
|
||||
active.html: |
||||
|
||||
```html |
||||
<!DOCTYPE html> |
||||
<html class="no-js"> |
||||
<head> |
||||
<meta charset="utf-8" /> |
||||
<title>Active</title> |
||||
</head> |
||||
<body> |
||||
<h1>Active Page</h1> |
||||
<a href="/">Click Me</a> |
||||
<script src="script.js" async defer></script> |
||||
</body> |
||||
</html> |
||||
``` |
||||
|
||||
script.js: |
||||
|
||||
```js |
||||
const readTextFile = (file, allText = '') => { |
||||
let rawFile = new XMLHttpRequest() |
||||
rawFile.open('GET', file, false) |
||||
rawFile.onreadystatechange = () => { |
||||
if (rawFile.readyState === 4) { |
||||
if (rawFile.status === 200 || rawFile.status == 0) { |
||||
allText = rawFile.responseText |
||||
} |
||||
} |
||||
} |
||||
rawFile.send(null) |
||||
return allText |
||||
} |
||||
|
||||
document.body.innerHTML = |
||||
location.pathname === '/' |
||||
? readTextFile('./index.html') |
||||
: readTextFile('./active.html') |
||||
``` |
Loading…
Reference in new issue