diff --git a/README.md b/README.md index 87a0d15..6c5897b 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,9 @@ Thirteen Tien Len TODO ---- +BUG TODO: First player / lowest card holder should not be able to pass +first play + ReactJS front-end Implement card graphics diff --git a/app/assets/javascripts/components/game.js.jsx b/app/assets/javascripts/components/game.js.jsx new file mode 100644 index 0000000..27632f1 --- /dev/null +++ b/app/assets/javascripts/components/game.js.jsx @@ -0,0 +1,47 @@ +var Game = React.createClass({ + propTypes: { + title: React.PropTypes.string, + id: React.PropTypes.number + }, + + getInitialState: function() { + return { + id: 0, + title: "" + }; + }, + + componentDidMount: function() { + $.get(this.props.source, function(result) { + if (this.isMounted()) { + console.log("Mounted"); + this.setState({ + title: result.title + }); + this.setProps({ + id: result.id + }); + } + }.bind(this)); + }, + + render: function() { + return ( +
+
Title: {this.state.title}
+
Id: {this.props.id}
+
+ +
+
+ ); + } +}); + +$(document).on("page:change", function() { + if (document.getElementById("game-container") != null) { + React.render( + , document.getElementById('game-container') + ); + } +}) diff --git a/app/assets/javascripts/components/inventory.js.jsx b/app/assets/javascripts/components/inventory.js.jsx index 63dbfb3..5f9dcdb 100644 --- a/app/assets/javascripts/components/inventory.js.jsx +++ b/app/assets/javascripts/components/inventory.js.jsx @@ -41,6 +41,7 @@ var Inventory = React.createClass({ } }); +// TODO: Remove this? $(document).on("page:change", function() { if (document.getElementById("inventory") != null) { React.render( diff --git a/app/views/games/show.html.haml b/app/views/games/show.html.haml index 985ed87..0dc1ef7 100644 --- a/app/views/games/show.html.haml +++ b/app/views/games/show.html.haml @@ -1,3 +1,5 @@ +#game-container + %p %b Status: = @game.status @@ -34,7 +36,7 @@ // Show the players' cards - if player.user == current_user && player.inventory.empty? == false - #inventory + -##inventory -# TODO better logic, not in view - unless @game.status == nil