DEV: Sort styleguide icons alphabetically and fix render on refresh (#14463)

Co-authored-by: Jarek Radosz <jradosz@gmail.com>
This commit is contained in:
Penar Musaraj 2021-09-28 14:09:15 -04:00 committed by GitHub
parent b7fc576a8c
commit 574cb28b0e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 3 deletions

View File

@ -1,4 +1,5 @@
import { afterRender } from "discourse-common/utils/decorators";
import { later } from "@ember/runloop";
export default Ember.Component.extend({
tagName: "section",
@ -13,8 +14,12 @@ export default Ember.Component.extend({
@afterRender
setIconIds() {
let symbols = document.querySelectorAll("#svg-sprites symbol");
let ids = Array.from(symbols).mapBy("id");
this.set("iconIds", ids);
if (symbols.length > 0) {
let ids = Array.from(symbols).mapBy("id");
this.set("iconIds", ids.sort());
} else {
// Let's try again a short time later if there are no svgs loaded yet
later(this, this.setIconIds, 1500);
}
},
});