-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from Authman2/observables
Observables
- Loading branch information
Showing
16 changed files
with
506 additions
and
630 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 |
---|---|---|
@@ -0,0 +1,73 @@ | ||
.app { | ||
position: absolute; | ||
margin: 0px; | ||
width: 100%; | ||
padding: 0px; | ||
min-height: 100%; | ||
overflow-y: auto; | ||
text-align: center; | ||
padding-bottom: 100px; | ||
background-color: #4341b5; | ||
} | ||
|
||
.app-title { | ||
color: white; | ||
font-weight: 300; | ||
font-family: 'Avenir'; | ||
} | ||
|
||
input { | ||
width: 70%; | ||
height: 50px; | ||
border: none; | ||
padding: 15px; | ||
font-size: 16px; | ||
border-radius: 10px; | ||
font-family: 'Avenir'; | ||
} | ||
|
||
button { | ||
position: relative; | ||
width: 20%; | ||
height: 50px; | ||
border: none; | ||
outline: none; | ||
display: block; | ||
color: white; | ||
cursor: pointer; | ||
font-size: 14px; | ||
margin-top: 10px; | ||
margin-left: auto; | ||
margin-right: auto; | ||
border-radius: 25px; | ||
transition-duration: 0.1s; | ||
background-color: #6866d8; | ||
} | ||
button:hover { | ||
color: lightgray; | ||
background-color: #5856b9; | ||
} | ||
button:active { | ||
color: gray; | ||
background-color: #333194; | ||
} | ||
|
||
.todo-item { | ||
width: 70%; | ||
padding: 15px; | ||
color: white; | ||
cursor: pointer; | ||
font-weight: 300; | ||
margin-top: 20px; | ||
margin-left: auto; | ||
margin-right: auto; | ||
border-radius: 10px; | ||
font-family: 'Avenir'; | ||
background-color: #6866d8; | ||
} | ||
.todo-item:hover { | ||
background-color: #5856b9; | ||
} | ||
.todo-item:active { | ||
background-color: #333194; | ||
} |
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,42 +1,48 @@ | ||
import { h, Mosaic } from '../src/index'; | ||
import Home from './home'; | ||
|
||
const root = document.getElementById('root'); | ||
root.innerHTML = ''; | ||
/* Example of a Todo application using Mosaic. */ | ||
const TodoItem = new Mosaic({ | ||
data: { title: "" }, | ||
view: function() { | ||
return <div class='todo-item' onclick={this.data.deleteTodo}> | ||
{this.data.title} | ||
</div> | ||
} | ||
}); | ||
|
||
const appStyles = { | ||
width: '100%', | ||
color: 'white', | ||
paddingTop: '10px', | ||
textAlign: 'center', | ||
fontFamily: 'Avenir', | ||
paddingBottom: '100px', | ||
backgroundColor: '#4341B5' | ||
} | ||
const app = new Mosaic({ | ||
element: root, | ||
const todoApp = new Mosaic({ | ||
element: document.getElementById('root'), | ||
data: { | ||
title: "Mosaic", | ||
subtitle: "A front-end JavaScript library for building user interfaces" | ||
todos: ['Click the "Add Todo" button to add another todo item!', | ||
'Click on a todo item to delete it.'] | ||
}, | ||
components: { | ||
home1: Mosaic.Child(Home, { instance: 0, componentInstance: "First Home Instance: " }), | ||
home2: Mosaic.Child(Home, { instance: 1, componentInstance: "Second Home Instance: " }), | ||
actions: { | ||
addTodo: function() { | ||
let value = document.getElementById('inp').value; | ||
document.getElementById('inp').value = ''; | ||
|
||
this.data.todos = this.data.todos.concat(value); | ||
}, | ||
deleteTodo: function(todoIndex) { | ||
this.data.todos = this.data.todos.filter((_, index) => index !== todoIndex); | ||
} | ||
}, | ||
view: function() { | ||
return ( | ||
<div style={appStyles}> | ||
<h1>Welcome to {this.data.title}!</h1> | ||
<h4>{this.data.subtitle}</h4> | ||
<p>Use the buttons below to try out the counter!</p> | ||
return <div class='app'> | ||
<h1 class='app-title'>Mosaic Todo List</h1> | ||
<input id='inp' type='text' placeholder='Enter your todo item' | ||
onkeypress={(e) => { if(e.keyCode === 13) this.actions.addTodo() }}/> | ||
<button onclick={this.actions.addTodo}>Add Todo</button> | ||
|
||
{ this.home1.view() } | ||
{ this.home2.view() } | ||
</div> | ||
) | ||
}, | ||
created: function() { | ||
this.home1.setData({ count: 10 }); | ||
{ | ||
this.data.todos.map((todo, index) => { | ||
return <TodoItem data={{ | ||
title: todo, | ||
deleteTodo: this.actions.deleteTodo.bind(this, index) | ||
}}/> | ||
}) | ||
} | ||
</div> | ||
} | ||
}); | ||
app.paint(); | ||
todoApp.paint(); |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
Oops, something went wrong.