Files
David TaylorandGitHub 666b5dddde DEV: Move discourse-common/(utils|lib) to discourse/lib (#30733)
`discourse-common` was created in the past to share logic between the
'wizard' app and the main 'discourse' app. Since then, the wizard has
been consolidated into the main app, so the separation of
`discourse-common` is no longer useful.

This commit moves `discourse-common/(lib|utils)/*` into
`discourse/lib/*`, adds shims for the imports, and updates existing
uses in core.
2025-01-13 13:02:49 +00:00

30 lines
900 B
JavaScript

import Component from "@ember/component";
import { classNames, tagName } from "@ember-decorators/component";
import { afterRender } from "discourse/lib/decorators";
import { REPLACEMENTS } from "discourse/lib/icon-library";
import discourseLater from "discourse/lib/later";
@tagName("section")
@classNames("styleguide-icons")
export default class StyleguideIcons extends Component {
iconIds = [];
init() {
super.init(...arguments);
this.setIconIds();
}
@afterRender
setIconIds() {
let symbols = document.querySelectorAll("#svg-sprites symbol");
if (symbols.length > 0) {
let ids = Array.from(symbols).mapBy("id");
ids.push(...Object.keys(REPLACEMENTS));
this.set("iconIds", [...new Set(ids.sort())]);
} else {
// Let's try again a short time later if there are no svgs loaded yet
discourseLater(this, this.setIconIds, 1500);
}
}
}