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