mirror of
https://github.com/discourse/discourse.git
synced 2024-11-27 08:15:48 +08:00
DEV: migrates user-stat to gjs (#27867)
This commit is contained in:
parent
6547f78ff8
commit
0614279b9d
|
@ -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>
|
||||
}
|
|
@ -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>
|
|
@ -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"),
|
||||
});
|
Loading…
Reference in New Issue
Block a user