initial commit
This commit is contained in:
25
app/components/chat/composer.js
Normal file
25
app/components/chat/composer.js
Normal file
@@ -0,0 +1,25 @@
|
||||
import Component from '@glimmer/component';
|
||||
import { tracked } from '@glimmer/tracking';
|
||||
import { action } from '@ember/object';
|
||||
|
||||
export default class ChatComposer extends Component {
|
||||
@tracked draft = '';
|
||||
|
||||
@action update(event) {
|
||||
this.draft = event.target.value;
|
||||
}
|
||||
|
||||
@action keydown(event) {
|
||||
if (event.key === 'Enter' && !event.shiftKey) {
|
||||
event.preventDefault();
|
||||
this.submit();
|
||||
}
|
||||
}
|
||||
|
||||
@action submit() {
|
||||
const content = this.draft.trim();
|
||||
if (!content || this.args.disabled) return;
|
||||
this.args.onSend(content);
|
||||
this.draft = '';
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user