This repository has been archived on 2023-03-18. You can view files and clone it, but cannot push or open issues or pull requests.
osr-discourse-src/app/assets/javascripts/discourse/components/input-tip.js.es6
Blake Erickson fe9293b8b5 DEV: Remove buffered rendering from input tips
This is another refactoring in the multi-step process to remove all uses
of our custom Render Buffer.

Previous commit: 2290ec9e87 in this
series.

This commit affects the display of input tips. It is just a refactor and
does not change any functionality.
2019-12-04 18:11:00 -07:00

31 lines
778 B
JavaScript

import { alias, not } from "@ember/object/computed";
import Component from "@ember/component";
import { iconHTML } from "discourse-common/lib/icon-library";
export default Component.extend({
classNameBindings: [":tip", "good", "bad"],
rerenderTriggers: ["validation"],
tipIcon: null,
tipReason: null,
bad: alias("validation.failed"),
good: not("bad"),
tipIconHTML() {
let icon = iconHTML(this.good ? "check" : "times");
return `${icon}`.htmlSafe();
},
didReceiveAttrs() {
this._super(...arguments);
let reason = this.get("validation.reason");
if (reason) {
this.set("tipIcon", this.tipIconHTML());
this.set("tipReason", reason);
} else {
this.set("tipIcon", null);
this.set("tipReason", null);
}
}
});