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/styleguide/assets/javascripts/discourse/components/styleguide-icons.js
Jarek Radosz 4ad77f3382
DEV: Remove .es6 extensions from core (#14912)
Still supported in plugins though.
2021-11-13 12:51:53 +01:00

26 lines
655 B
JavaScript

import { afterRender } from "discourse-common/utils/decorators";
import { later } from "@ember/runloop";
export default Ember.Component.extend({
tagName: "section",
classNames: ["styleguide-icons"],
iconIds: [],
init() {
this._super(...arguments);
this.setIconIds();
},
@afterRender
setIconIds() {
let symbols = document.querySelectorAll("#svg-sprites symbol");
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);
}
},
});