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/plugins/chat/assets/javascripts/discourse/components/chat-skeleton.js
Joffrey JAFFEUX 432548432c wip
2023-03-03 00:32:25 +01:00

21 lines
658 B
JavaScript

import Component from "@glimmer/component";
import { htmlSafe } from "@ember/template";
export default class ChatSkeleton extends Component {
get placeholders() {
return Array.from({ length: 15 }, () => {
return {
image: this.#randomIntFromInterval(1, 10) === 5,
rows: Array.from({ length: this.#randomIntFromInterval(1, 5) }, () => {
return htmlSafe(`width: ${this.#randomIntFromInterval(20, 95)}%`);
}),
reactions: Array.from({ length: this.#randomIntFromInterval(0, 3) }),
};
});
}
#randomIntFromInterval(min, max) {
return Math.floor(Math.random() * (max - min + 1) + min);
}
}