mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-12-11 08:11:15 -05:00
25 lines
791 B
JavaScript
25 lines
791 B
JavaScript
import { registerUnbound } from 'discourse-common/lib/helpers';
|
|
|
|
export function iconClasses(icon, params) {
|
|
let classes = "fa fa-" + icon;
|
|
if (params.modifier) { classes += " fa-" + params.modifier; }
|
|
if (params['class']) { classes += ' ' + params['class']; }
|
|
return classes;
|
|
}
|
|
|
|
export function iconHTML(icon, params) {
|
|
params = params || {};
|
|
|
|
var html = "<i class='" + iconClasses(icon, params) + "'";
|
|
if (params.title) { html += ` title='${I18n.t(params.title)}'`; }
|
|
if (params.label) { html += " aria-hidden='true'"; }
|
|
html += "></i>";
|
|
if (params.label) {
|
|
html += "<span class='sr-only'>" + I18n.t(params.label) + "</span>";
|
|
}
|
|
return html;
|
|
}
|
|
|
|
registerUnbound('fa-icon', function(icon, params) {
|
|
return new Handlebars.SafeString(iconHTML(icon, params));
|
|
});
|