DEV: migrates user-stat to gjs (#27867)

This commit is contained in:
Joffrey JAFFEUX 2024-07-11 11:55:20 +02:00 committed by GitHub
parent 6547f78ff8
commit 0614279b9d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 38 additions and 21 deletions

View File

@ -0,0 +1,38 @@
import Component from "@glimmer/component";
import { htmlSafe } from "@ember/template";
import formatDuration from "discourse/helpers/format-duration";
import number from "discourse/helpers/number";
import icon from "discourse-common/helpers/d-icon";
import i18n from "discourse-common/helpers/i18n";
export default class UserStat extends Component {
get type() {
return this.args.type ?? "number";
}
get isNumber() {
return this.type === "number";
}
get isDuration() {
return this.type === "duration";
}
<template>
<div class="user-stat">
<span class="value" title={{@rawTitle}}>
{{#if this.isNumber}}
{{number @value}}
{{else if this.isDuration}}
{{formatDuration @value}}
{{else}}
{{@value}}
{{/if}}
</span>
<span class="label">
{{#if @icon}}{{icon @icon}}{{/if}}
{{htmlSafe (i18n @label count=@value)}}
</span>
</div>
</template>
}

View File

@ -1,13 +0,0 @@
<span class="value" title={{this.rawTitle}}>
{{#if this.isNumber}}
{{number @value}}
{{else if this.isDuration}}
{{format-duration @value}}
{{else}}
{{@value}}
{{/if}}
</span>
<span class="label">
{{#if @icon}}{{d-icon @icon}}{{/if}}
{{html-safe (i18n @label count=@value)}}
</span>

View File

@ -1,8 +0,0 @@
import Component from "@ember/component";
import { equal } from "@ember/object/computed";
export default Component.extend({
classNames: ["user-stat"],
type: "number",
isNumber: equal("type", "number"),
isDuration: equal("type", "duration"),
});