This commit is contained in:
Luca Jäntsch
2019-05-24 13:51:51 +02:00
parent 41809ed190
commit 4f32da8b5d
20 changed files with 13176 additions and 0 deletions

36
src/jsx/ui/student.jsx Normal file
View 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>
);
}
}