snappymail/dev/Component/SvgIcon.js
djmaze e7180a86ce Made eslint using 'browser' environment and added globals, because RainLoop is used in browsers.
This also allowed to remove all webpack 'externals' overhead.
2020-08-12 00:25:36 +02:00

22 lines
561 B
JavaScript

let cachedUrl = null;
const getUrl = () => {
if (!cachedUrl) {
const version = jQuery('#rlAppVersion').attr('content') || '0.0.0';
cachedUrl = `rainloop/v/${version}/static/css/svg/icons.svg`;
}
return cachedUrl;
};
export default {
template: '<b></b>',
viewModel: {
createViewModel: ({ icon = 'null' }, componentInfo) => {
if (componentInfo && componentInfo.element) {
jQuery(componentInfo.element).replaceWith(
`<svg class="svg-icon svg-icon-${icon}"><use xlink:href="${getUrl()}#svg-icon-${icon}"></use></svg>`
);
}
}
}
};