0.1
This commit is contained in:
36
src/jsx/ui/student.jsx
Normal file
36
src/jsx/ui/student.jsx
Normal file
@@ -0,0 +1,36 @@
|
||||
import React from 'react';
|
||||
|
||||
export class Student extends React.Component{
|
||||
constructor(props){
|
||||
super(props);
|
||||
this.state = {
|
||||
username:this.camelize(props.username),
|
||||
name:props.username,
|
||||
cl:props.cl,
|
||||
img_url:'/data/class/'+props.cl+'/'+props.username+'.svg',
|
||||
num:props.i
|
||||
}
|
||||
|
||||
this.onErr = this.onErr.bind(this);
|
||||
}
|
||||
camelize(str) {
|
||||
var x = str.split('_');
|
||||
for(var i in x){
|
||||
x[i] = x[i].charAt(0).toUpperCase() + x[i].slice(1);
|
||||
}
|
||||
return x.join(' ');
|
||||
}
|
||||
onErr(){
|
||||
var url = '/data/class/student.svg';
|
||||
this.setState({img_url:url});
|
||||
}
|
||||
render(){
|
||||
var c = "user chosen_"+this.state.num;
|
||||
return (
|
||||
<div className={c}>
|
||||
<div className="user_img"><img src={this.state.img_url} onError={this.onErr}></img></div>
|
||||
<div className="username">{this.state.username}</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user