Add dialog for join form
This commit is contained in:
parent
996d7d06d4
commit
30157383e8
4 changed files with 165 additions and 10 deletions
45
components/join.js
Normal file
45
components/join.js
Normal file
|
@ -0,0 +1,45 @@
|
|||
import { html, Component } from "../lib/index.js";
|
||||
|
||||
export default class Join extends Component {
|
||||
state = {
|
||||
channel: "#",
|
||||
};
|
||||
|
||||
constructor(props) {
|
||||
super(props);
|
||||
|
||||
this.handleChange = this.handleChange.bind(this);
|
||||
this.handleSubmit = this.handleSubmit.bind(this);
|
||||
}
|
||||
|
||||
handleChange(event) {
|
||||
var target = event.target;
|
||||
var value = target.type == "checkbox" ? target.checked : target.value;
|
||||
this.setState({ [target.name]: value });
|
||||
}
|
||||
|
||||
handleSubmit(event) {
|
||||
event.preventDefault();
|
||||
|
||||
var params = {
|
||||
channel: this.state.channel,
|
||||
};
|
||||
|
||||
this.props.onSubmit(params);
|
||||
}
|
||||
|
||||
render() {
|
||||
return html`
|
||||
<form onChange=${this.handleChange} onSubmit=${this.handleSubmit}>
|
||||
<label>
|
||||
Channel:<br/>
|
||||
<input type="text" name="channel" value=${this.state.channel} autofocus required/>
|
||||
</label>
|
||||
<br/>
|
||||
|
||||
<br/>
|
||||
<button>Join</button>
|
||||
</form>
|
||||
`;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue