mirror of
https://github.com/discourse/discourse.git
synced 2025-03-26 23:51:08 +08:00
DEV: Update composer-fullscreen-prompt to template-only component (#17871)
1. Replace `{{did-insert` with the builtin `{{on` modifier 2. Move the i18n call into the template With both of those changes, there is no logic left in the backing class, so we can switch to `templateOnly()` which is significantly faster. (granted, not a big deal for a component like this, but it makes for a good demonstration)
This commit is contained in:
parent
06030743e8
commit
e4fbb3be21
app/assets/javascripts
admin/addon/templates/components
discourse/app/components
@ -1,3 +1,3 @@
|
||||
<div class="composer-fullscreen-prompt" {{did-insert this.registerAnimationListener}}>
|
||||
{{html-safe this.exitPrompt}}
|
||||
<div class="composer-fullscreen-prompt" {{on "animationend" @removeFullScreenExitPrompt}}>
|
||||
{{html-safe (i18n "composer.exit_fullscreen_prompt")}}
|
||||
</div>
|
||||
|
@ -1,24 +1,3 @@
|
||||
import { action } from "@ember/object";
|
||||
import GlimmerComponent from "@glimmer/component";
|
||||
import I18n from "I18n";
|
||||
import templateOnly from "@ember/component/template-only";
|
||||
|
||||
export default class ComposerFullscreenPrompt extends GlimmerComponent {
|
||||
@action
|
||||
registerAnimationListener(element) {
|
||||
this.#addAnimationEventListener(element);
|
||||
}
|
||||
|
||||
#addAnimationEventListener(element) {
|
||||
element.addEventListener(
|
||||
"animationend",
|
||||
() => {
|
||||
this.args.removeFullScreenExitPrompt();
|
||||
},
|
||||
{ once: true }
|
||||
);
|
||||
}
|
||||
|
||||
get exitPrompt() {
|
||||
return I18n.t("composer.exit_fullscreen_prompt");
|
||||
}
|
||||
}
|
||||
export default templateOnly();
|
||||
|
Loading…
x
Reference in New Issue
Block a user