-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
93 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
import { renderUI } from './view/controller.js'; | ||
|
||
window.addEventListener('load', () => { | ||
console.log('aaaaaaaa') | ||
renderUI(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import Header from './Header.js'; | ||
import Todos from './Todos.js'; | ||
import Footer from './Footer.js'; | ||
|
||
/** | ||
* Crea el html de la app dinamicamente basandose | ||
* en los `todos` que se reciben como parametro | ||
* | ||
* @param todos Array de objetos con los todos existentes | ||
*/ | ||
export default (todos) => { | ||
// Creamos cada una de las secciones | ||
const headerSrc = Header(); | ||
const todosSrc = Todos(todos); | ||
const footerSrc = Footer(todos.length); | ||
|
||
// Creamos el elemento padre con template string | ||
const appSrc = ` | ||
<section class="todoapp"> | ||
${headerSrc} | ||
${todosSrc} | ||
${footerSrc} | ||
</section> | ||
`; | ||
|
||
return appSrc; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/** | ||
* Crea el html del footer | ||
* | ||
* @param count Cantidad de todos en la app | ||
*/ | ||
export default count => ( | ||
`<footer class="footer" style="display: block;"> | ||
<span class="todo-count"><strong>${count}</strong> todos</span> | ||
</footer>` | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/** | ||
* Crea el html de la cabecera | ||
*/ | ||
export default () => (` | ||
<header class="header"> | ||
<h1>todos</h1> | ||
<input class="new-todo" placeholder="What needs to be done?" autofocus=""> | ||
</header> | ||
` | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/** | ||
* Crea el html de la lista de todos | ||
* | ||
* @param todos Array de objetos con los todos existentes | ||
* Los todos deben tener `id` y `label` | ||
*/ | ||
export default todos => ( | ||
`<section class="main"> | ||
<ul class="todo-list"> | ||
${todos.map(t => (` | ||
<li data-id="${t.id}"> | ||
<div class="view"> | ||
<label>${t.label}</label> | ||
<button class="destroy"></button> | ||
</div> | ||
</li> | ||
`))} | ||
</ul> | ||
</section>` | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import App from './App.js'; | ||
|
||
/** | ||
* Renderiza el html de la aplicacion | ||
*/ | ||
export const renderUI = () => { | ||
// Por el momento comenzamos con todos estaticos | ||
const todos = [ | ||
{ | ||
id: 'id', | ||
label: 'Un todo', | ||
}, | ||
]; | ||
|
||
// creamos el HTML en formator string dinamicamente usando los todos | ||
const app = App(todos); | ||
|
||
// lo insertamos en el elemento #root | ||
const root = document.getElementById('root'); | ||
root.innerHTML = app; | ||
}; |