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 a04201ae01
UX: implements a random and auto generated skeleton (#20202)
UI is not modified much besides removing the border-bottom, and using only message body.

However instead of having a fix template, this is all automatically generated and random, resulting in a more natural experience.
2023-02-07 22:48:10 +01:00

17 lines
494 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 Array.from({ length: this.#randomIntFromInterval(1, 5) }, () => {
return htmlSafe(`width: ${this.#randomIntFromInterval(20, 95)}%`);
});
});
}
#randomIntFromInterval(min, max) {
return Math.floor(Math.random() * (max - min + 1) + min);
}
}