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

Styling #34

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
Binary file added 3-flux/documentation/data-flow.graffle
Binary file not shown.
Binary file added 3-flux/documentation/data-flow.pdf
Binary file not shown.
1 change: 0 additions & 1 deletion 3-flux/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
"webpack": "^1.12.9",
"webpack-dev-server": "^1.14.1"
},
"devDependencies": {},
"scripts": {
"dev": "webpack-dev-server --content-base src --inline --hot"
},
Expand Down
25 changes: 25 additions & 0 deletions 3-flux/src/assets/icon_done.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 22 additions & 0 deletions 3-flux/src/assets/icon_not_done.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 18 additions & 0 deletions 3-flux/src/assets/icon_trash.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion 3-flux/src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
<link href="https://maxcdn.bootstrapcdn.com/bootswatch/3.3.6/cerulean/bootstrap.min.css" rel="stylesheet">

<!-- Custom Fonts -->
<link href="font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css">
<link href="http://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,700,300italic,400italic,700italic" rel="stylesheet" type="text/css">
<link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet">
</head>

<body>
Expand Down
40 changes: 19 additions & 21 deletions 3-flux/src/js/actions/TodoActions.js
Original file line number Diff line number Diff line change
@@ -1,36 +1,34 @@
import dispatcher from "../dispatcher";

export function createTodo(text) {
export function deleteTodo(id) {
dispatcher.dispatch({
type: "CREATE_TODO",
text,
type: "DELETE_TODO",
id,
});
}

export function deleteTodo(id) {
export function createTodo(text) {
dispatcher.dispatch({
type: "DELETE_TODO",
id,
type: "CREATE_TODO",
text,
});
}

export function reloadTodos() {
// axios("http://someurl.com/somedataendpoint").then((data) => {
// console.log("got the data!", data);
// })
dispatcher.dispatch({type: "FETCH_TODOS"});
setTimeout(() => {
dispatcher.dispatch({type: "RECEIVE_TODOS", todos: [
{
id: 8484848484,
text: "Go Shopping Again",
complete: false
},
{
id: 6262627272,
text: "Hug Wife",
complete: true
},
]});
}, 1000);
// dispatcher.dispatch({type: "FETCH_TODOS"});
dispatcher.dispatch({type: "RECEIVE_TODOS", todos: [
{
id: 8484848484,
text: "Go Shopping Again",
complete: false
},
{
id: 6262627272,
text: "Hug Wife",
complete: true
},
]});
}
55 changes: 55 additions & 0 deletions 3-flux/src/js/components/NewTodo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import React from "react";

import * as TodoActions from "../actions/TodoActions";

export default class NewTodo extends React.Component {
constructor(props) {
super();
this.state = {
newTodo: ""
};
}

addTodo(e) {
e.preventDefault();
TodoActions.createTodo(this.state.newTodo);
this.setState({newTodo: ""});
}

handleChange(e) {
this.setState({newTodo: e.target.value});
}

render() {
const inputStyling = {
borderRadius: "10px",
borderStyle: "solid",
borderWidth: "1px",
borderColor: "#B19FBA",
marginRight: "20px",
minWidth: "200px",
backgroundColor: "#D8CFDD",
padding: "3px 15px 3px 15px"
};

const formStyling = {
paddingBottom: "10px"
};

const standardButton = {
borderRadius: "10px",
borderStyle: "none",
padding: "3px 15px 3px 15px",
fontFamily: "Roboto",
backgroundColor: "#765786",
color: "#FFF"
};

return (
<form style={formStyling}>
<input style={inputStyling} type="text" value={this.state.newTodo} onChange={this.handleChange.bind(this)}/>
<button style={standardButton} onClick={this.addTodo.bind(this)}>Add New</button>
</form>
);
}
}
22 changes: 20 additions & 2 deletions 3-flux/src/js/components/Todo.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,31 @@
import React from "react";

import * as TodoActions from "../actions/TodoActions";

export default class Todo extends React.Component {
constructor(props) {
super();
}

deleteTodo(e) {
TodoActions.deleteTodo(this.props.id);
}

render() {
const { complete, edit, text } = this.props;

const icon = complete ? "\u2714" : "\u2716"
const icon = complete ? "../../assets/icon_done.svg" : "../../assets/icon_not_done.svg";
const trash = "../../assets/icon_trash.svg";

const trashStyle = {
maxWidth: "50px",
padding: "5px"
};

const checkboxStyle = {
maxWidth: "50px",
padding: "10px"
};

if (edit) {
return (
Expand All @@ -20,8 +37,9 @@ export default class Todo extends React.Component {

return (
<li>
<span><img style={checkboxStyle} src={icon} /></span>
<span onClick={this.deleteTodo.bind(this)}><img style={trashStyle} src={trash} /></span>
<span>{text}</span>
<span>{icon}</span>
</li>
);
}
Expand Down
7 changes: 6 additions & 1 deletion 3-flux/src/js/components/layout/Nav.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,13 @@ export default class Nav extends React.Component {
const settingsClass = location.pathname.match(/^\/settings/) ? "active" : "";
const navClass = collapsed ? "collapse" : "";

const navStyle = {
backgroundColor: "#3C1053",
backgroundImage: "none"
};

return (
<nav class="navbar navbar-inverse navbar-fixed-top" role="navigation">
<nav style={navStyle} class="navbar navbar-inverse navbar-fixed-top" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" onClick={this.toggleCollapse.bind(this)} >
Expand Down
9 changes: 8 additions & 1 deletion 3-flux/src/js/pages/Favorites.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,16 @@ import React from "react";

export default class Archives extends React.Component {
render() {

const headerStyling = {
fontFamily: "Roboto",
color: "#3C1053",
marginBottom: "20px"
};

return (
<div>
<h1>Favorites</h1>
<h1 style={headerStyling}>Favorites</h1>
</div>
);
}
Expand Down
3 changes: 3 additions & 0 deletions 3-flux/src/js/pages/Layout.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@ import { Link } from "react-router";
import Footer from "../components/layout/Footer";
import Nav from "../components/layout/Nav";

import "../../styles.css";

export default class Layout extends React.Component {
render() {
const { location } = this.props;

const containerStyle = {
marginTop: "60px"
};
Expand Down
9 changes: 8 additions & 1 deletion 3-flux/src/js/pages/Settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,16 @@ import React from "react";

export default class Settings extends React.Component {
render() {

const headerStyling = {
fontFamily: "Roboto",
color: "#3C1053",
marginBottom: "20px"
};

return (
<div>
<h1>Settings</h1>
<h1 style={headerStyling}>Settings</h1>
</div>
);
}
Expand Down
21 changes: 16 additions & 5 deletions 3-flux/src/js/pages/Todos.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import React from "react";

import Todo from "../components/Todo";
import NewTodo from "../components/NewTodo";
import * as TodoActions from "../actions/TodoActions";
import TodoStore from "../stores/TodoStore";


export default class Todos extends React.Component {
constructor() {
super();
this.getTodos = this.getTodos.bind(this);
this.state = {
todos: TodoStore.getAll(),
todos: TodoStore.getAll()
};
}

Expand Down Expand Up @@ -39,11 +39,22 @@ export default class Todos extends React.Component {
return <Todo key={todo.id} {...todo}/>;
});

const customUl = {
listStyle: "none",
paddingLeft: "0"
};

const headerStyling = {
fontFamily: "Roboto",
color: "#3C1053",
marginBottom: "20px"
};

return (
<div>
<button onClick={this.reloadTodos.bind(this)}>Reload!</button>
<h1>Todos</h1>
<ul>{TodoComponents}</ul>
<h1 style={headerStyling}>To Do</h1>
<NewTodo />
<ul style={customUl}>{TodoComponents}</ul>
</div>
);
}
Expand Down
16 changes: 14 additions & 2 deletions 3-flux/src/js/stores/TodoStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class TodoStore extends EventEmitter {
{
id: 113464613,
text: "Go Shopping",
complete: false
complete: true
},
{
id: 235684679,
Expand All @@ -27,10 +27,16 @@ class TodoStore extends EventEmitter {
text,
complete: false,
});

this.emit("change");
}

deleteTodo(id) {
this.todos = this.todos.filter((entry) => {
return entry.id !== id;
});
// this.emit("change");
}

getAll() {
return this.todos;
}
Expand All @@ -39,13 +45,19 @@ class TodoStore extends EventEmitter {
switch(action.type) {
case "CREATE_TODO": {
this.createTodo(action.text);
this.emit("change");
break;
}
case "RECEIVE_TODOS": {
this.todos = action.todos;
this.emit("change");
break;
}
case "DELETE_TODO": {
this.deleteTodo(action.id);
this.emit("change");
break;
}
}
}

Expand Down
Loading