DEV: Convert input-tip to gjs (#24624)
This commit is contained in:
parent
265a8cd2b2
commit
0f7e4d2eaa
|
@ -0,0 +1,16 @@
|
|||
import icon from "discourse-common/helpers/d-icon";
|
||||
|
||||
const InputTip = <template>
|
||||
<div
|
||||
class="tip {{if @validation.failed 'bad' 'good'}}"
|
||||
id={{@id}}
|
||||
...attributes
|
||||
>
|
||||
{{#if @validation.reason}}
|
||||
{{icon (if @validation.failed "times" "check")}}
|
||||
{{@validation.reason}}
|
||||
{{/if}}
|
||||
</div>
|
||||
</template>;
|
||||
|
||||
export default InputTip;
|
|
@ -1,4 +0,0 @@
|
|||
{{#if this.tipReason}}
|
||||
{{this.tipIcon}}
|
||||
{{this.tipReason}}
|
||||
{{/if}}
|
|
@ -1,30 +0,0 @@
|
|||
import Component from "@ember/component";
|
||||
import { alias, not } from "@ember/object/computed";
|
||||
import { htmlSafe } from "@ember/template";
|
||||
import { iconHTML } from "discourse-common/lib/icon-library";
|
||||
|
||||
export default Component.extend({
|
||||
classNameBindings: [":tip", "good", "bad"],
|
||||
tipIcon: null,
|
||||
tipReason: null,
|
||||
|
||||
bad: alias("validation.failed"),
|
||||
good: not("bad"),
|
||||
|
||||
tipIconHTML() {
|
||||
let icon = iconHTML(this.good ? "check" : "times");
|
||||
return htmlSafe(`${icon}`);
|
||||
},
|
||||
|
||||
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);
|
||||
}
|
||||
},
|
||||
});
|
|
@ -58,7 +58,7 @@
|
|||
</label>
|
||||
<InputTip
|
||||
@validation={{this.emailValidation}}
|
||||
@id="account-email-validation"
|
||||
id="account-email-validation"
|
||||
/>
|
||||
<span class="more-info">{{i18n "user.email.instructions"}}</span>
|
||||
</div>
|
||||
|
@ -84,7 +84,7 @@
|
|||
|
||||
<InputTip
|
||||
@validation={{this.usernameValidation}}
|
||||
@id="username-validation"
|
||||
id="username-validation"
|
||||
/>
|
||||
<span class="more-info">
|
||||
{{i18n "user.username.instructions"}}
|
||||
|
@ -112,7 +112,7 @@
|
|||
|
||||
<InputTip
|
||||
@validation={{this.nameValidation}}
|
||||
@id="fullname-validation"
|
||||
id="fullname-validation"
|
||||
/>
|
||||
<span class="more-info">{{this.nameInstructions}}</span>
|
||||
{{/if}}
|
||||
|
@ -152,7 +152,7 @@
|
|||
<div class="create-account__password-tip-validation">
|
||||
<InputTip
|
||||
@validation={{this.passwordValidation}}
|
||||
@id="password-validation"
|
||||
id="password-validation"
|
||||
/>
|
||||
<span class="more-info">{{this.passwordInstructions}}</span>
|
||||
<div
|
||||
|
|
|
@ -46,7 +46,7 @@
|
|||
{{#unless this.isInviteLink}}
|
||||
<InputTip
|
||||
@validation={{this.emailValidation}}
|
||||
@id="account-email-validation"
|
||||
id="account-email-validation"
|
||||
/>
|
||||
{{/unless}}
|
||||
{{else}}
|
||||
|
@ -85,7 +85,7 @@
|
|||
</label>
|
||||
<InputTip
|
||||
@validation={{this.emailValidation}}
|
||||
@id="account-email-validation"
|
||||
id="account-email-validation"
|
||||
/>
|
||||
<div class="instructions">{{i18n
|
||||
"user.email.instructions"
|
||||
|
@ -108,7 +108,7 @@
|
|||
</label>
|
||||
<InputTip
|
||||
@validation={{this.usernameValidation}}
|
||||
@id="username-validation"
|
||||
id="username-validation"
|
||||
/>
|
||||
<div class="instructions">{{i18n
|
||||
"user.username.instructions"
|
||||
|
@ -150,7 +150,7 @@
|
|||
<div class="create-account__password-tip-validation">
|
||||
<InputTip
|
||||
@validation={{this.passwordValidation}}
|
||||
@id="password-validation"
|
||||
id="password-validation"
|
||||
/>
|
||||
<span
|
||||
class="more-info"
|
||||
|
|
Loading…
Reference in New Issue