forked from EarthWindandJS/help-desk
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor class-rost admin into separate .js file; added div setup
- Loading branch information
Showing
2 changed files
with
136 additions
and
123 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,129 +6,39 @@ | |
</head> | ||
<body> | ||
|
||
<div id="container"> | ||
<div id="react-mountpoint"> | ||
</div> | ||
</div> | ||
|
||
<link rel="stylesheet" href="./styles.css" /> | ||
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" /> | ||
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/0.14.0/react.js"></script> | ||
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/0.14.0/react-dom.js"></script> | ||
<script src="https://cdnjs.cloudflare.com/ajax/libs/babel-core/5.6.15/browser.js"></script> | ||
<script>console.log('babel loaded');</script> | ||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> | ||
<script src="https://cdnjs.cloudflare.com/ajax/libs/marked/0.3.2/marked.min.js"></script> | ||
<script src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/1.3.7/socket.io.min.js"></script> | ||
|
||
|
||
<script type="text/babel"> | ||
(function() { | ||
// global vars | ||
var imgStyle = {width: "100px", height: "100px", margin: "2px"}; | ||
var imagePath = './img'; | ||
var avatarPaths = []; | ||
for (var i=0; i<22; i++) { | ||
avatarPaths.push(imagePath + '/' + i + '.jpg'); | ||
} | ||
|
||
|
||
var AvatarGallery = React.createClass({ | ||
handleClick: function(e) { | ||
var imgsrc = e.target.getAttribute('src'); | ||
var state = {imgsrc: imgsrc}; | ||
this.props.updateParentState(state); | ||
}, | ||
render: function() { | ||
var imgs = avatarPaths.map(function(url, idx) { | ||
return ( | ||
<img id="imgsrc" | ||
src={ url } | ||
className="clickable img-rounded" | ||
style={ imgStyle } | ||
key={ idx } | ||
onClick={ this.handleClick } /> | ||
); | ||
}.bind(this)); | ||
return ( | ||
<div className="avatar-gallery" style={ {clear: "both"} }> | ||
<h3>Choose an avatar</h3> | ||
{ imgs } | ||
</div> | ||
); | ||
} | ||
}); | ||
|
||
var StudentPreview = React.createClass({ | ||
render: function() { | ||
var studentInfo = this.props.studentInfo; | ||
return ( | ||
<div className="col-md-4"> | ||
<img src={ studentInfo.imgsrc } className="img-rounded center-block" style={ imgStyle }/> | ||
<h4>{ studentInfo.firstname } { studentInfo.lastname }</h4> | ||
<p>{ studentInfo.email }</p> | ||
<p>http://github.com/{ studentInfo.gitHandle }</p> | ||
</div> | ||
); | ||
} | ||
}); | ||
|
||
var AddStudentForm = React.createClass({ | ||
handleChange: function(e) { | ||
console.log(e.target.id); | ||
var state = {}; | ||
state[e.target.id] = e.target.value; | ||
this.props.updateParentState(state); | ||
}, | ||
render: function() { | ||
return ( | ||
<div className="col-md-8"> | ||
<form method="post"> | ||
<label htmlFor="firstname">First name:</label> | ||
<input type="text" id="firstname" onChange={ this.handleChange } /> | ||
<label htmlFor="lastname">Last name:</label> | ||
<input type="text" id="lastname" onChange={ this.handleChange }/> | ||
<label htmlFor="email">Email:</label> | ||
<input type="text" id="email" onChange={ this.handleChange }/> | ||
<label htmlFor="git-handle">GitHub username:</label> | ||
<input type="text" id="gitHandle" onChange={ this.handleChange }/> | ||
</form> | ||
</div> | ||
); | ||
} | ||
}); | ||
|
||
var AddStudentContainer = React.createClass({ | ||
handleChange: function(state) { | ||
this.setState(state); | ||
}, | ||
getInitialState: function() { | ||
return { | ||
firstname: 'First', | ||
lastname: 'Last', | ||
email: '[email protected]', | ||
gitHandle: '', | ||
imgsrc: './img/default.gif' | ||
}; | ||
}, | ||
render: function() { | ||
return ( | ||
<div className="app"> | ||
<h1 className="text-center">Add New Student</h1> | ||
<AddStudentForm updateParentState={ this.handleChange }/> | ||
<StudentPreview studentInfo={ this.state }/> | ||
<AvatarGallery updateParentState={ this.handleChange } /> | ||
</div> | ||
); | ||
} | ||
}); | ||
|
||
ReactDOM.render( | ||
<AddStudentContainer />, | ||
document.getElementById('react-mountpoint') | ||
); | ||
})(); | ||
|
||
</script> | ||
<div class="container"> | ||
<div class="row"> | ||
<div class="sidebar col-sm-4"> | ||
<div class="row help-bar"> | ||
<div id="bug-log"></div> | ||
</div> | ||
<div class="row fellow-bar"> | ||
<div id="fellow-status"></div> | ||
</div> | ||
</div> | ||
|
||
<div class="main-bar col-sm-8"> | ||
<div id="navbar"></div> | ||
<div id="react-mountpoint" class="text-center2"></div> | ||
<div id="help-requests"></div> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
|
||
<link rel="stylesheet" href="./styles.css" /> | ||
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" /> | ||
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/0.14.0/react.js"></script> | ||
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/0.14.0/react-dom.js"></script> | ||
<script src="https://cdnjs.cloudflare.com/ajax/libs/babel-core/5.6.15/browser.js"></script> | ||
<script>console.log('babel loaded');</script> | ||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> | ||
<script src="https://cdnjs.cloudflare.com/ajax/libs/marked/0.3.2/marked.min.js"></script> | ||
<script src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/1.3.7/socket.io.min.js"></script> | ||
|
||
<script type="text/babel" src="../components/navbar.js"></script> | ||
<script type="text/babel" src="../components/admin.js"></script> | ||
|
||
</body> | ||
</html> |
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,103 @@ | ||
// global vars | ||
var imgStyle = {width: "100px", height: "100px", margin: "2px"}; | ||
var imagePath = '../class-roster/img'; | ||
var avatarPaths = []; | ||
for (var i=0; i<22; i++) { | ||
avatarPaths.push(imagePath + '/' + i + '.jpg'); | ||
} | ||
|
||
|
||
var AvatarGallery = React.createClass({ | ||
handleClick: function(e) { | ||
var imgsrc = e.target.getAttribute('src'); | ||
var state = {imgsrc: imgsrc}; | ||
this.props.updateParentState(state); | ||
}, | ||
render: function() { | ||
var imgs = avatarPaths.map(function(url, idx) { | ||
return ( | ||
<img id="imgsrc" | ||
src={ url } | ||
className="clickable img-rounded" | ||
style={ imgStyle } | ||
key={ idx } | ||
onClick={ this.handleClick } /> | ||
); | ||
}.bind(this)); | ||
return ( | ||
<div className="avatar-gallery" style={ {clear: "both"} }> | ||
<h3>Choose an avatar</h3> | ||
{ imgs } | ||
</div> | ||
); | ||
} | ||
}); | ||
|
||
var StudentPreview = React.createClass({ | ||
render: function() { | ||
var studentInfo = this.props.studentInfo; | ||
return ( | ||
<div className="col-md-4"> | ||
<img src={ studentInfo.imgsrc } className="img-rounded center-block" style={ imgStyle }/> | ||
<h4>{ studentInfo.firstname } { studentInfo.lastname }</h4> | ||
<p>{ studentInfo.email }</p> | ||
<p>http://github.com/{ studentInfo.gitHandle }</p> | ||
</div> | ||
); | ||
} | ||
}); | ||
|
||
var AddStudentForm = React.createClass({ | ||
handleChange: function(e) { | ||
console.log(e.target.id); | ||
var state = {}; | ||
state[e.target.id] = e.target.value; | ||
this.props.updateParentState(state); | ||
}, | ||
render: function() { | ||
return ( | ||
<div className="col-md-8"> | ||
<form method="post"> | ||
<label htmlFor="firstname">First name:</label> | ||
<input type="text" id="firstname" onChange={ this.handleChange } /> | ||
<label htmlFor="lastname">Last name:</label> | ||
<input type="text" id="lastname" onChange={ this.handleChange }/> | ||
<label htmlFor="email">Email:</label> | ||
<input type="text" id="email" onChange={ this.handleChange }/> | ||
<label htmlFor="git-handle">GitHub username:</label> | ||
<input type="text" id="gitHandle" onChange={ this.handleChange }/> | ||
</form> | ||
</div> | ||
); | ||
} | ||
}); | ||
|
||
var AddStudentContainer = React.createClass({ | ||
handleChange: function(state) { | ||
this.setState(state); | ||
}, | ||
getInitialState: function() { | ||
return { | ||
firstname: 'First', | ||
lastname: 'Last', | ||
email: '[email protected]', | ||
gitHandle: '', | ||
imgsrc: './img/default.gif' | ||
}; | ||
}, | ||
render: function() { | ||
return ( | ||
<div className="app"> | ||
<h1 className="text-center">Add New Student</h1> | ||
<AddStudentForm updateParentState={ this.handleChange }/> | ||
<StudentPreview studentInfo={ this.state }/> | ||
<AvatarGallery updateParentState={ this.handleChange } /> | ||
</div> | ||
); | ||
} | ||
}); | ||
|
||
ReactDOM.render( | ||
<AddStudentContainer />, | ||
document.getElementById('react-mountpoint') | ||
); |