@synergy-design-system/assets
Version:
Assets for the Synergy Design System
21 lines (20 loc) • 845 B
JavaScript
import { sick2018Icons, sick2025Icons, } from './index.js';
export function createSpriteSheet(icons, iconset = 'sick2025') {
const setToUse = iconset === 'sick2018' ? sick2018Icons : sick2025Icons;
const foundIcons = Object
.entries(setToUse)
.filter(([key]) => icons.includes(key));
const symbols = foundIcons
// Make sure to sort the icons by key always.
// This may prevent problems when saving the sheet in the filesystem
// and new items are added to the icons object.
.sort(([a], [b]) => a.localeCompare(b))
.map(([key, value]) => value
.replace('<svg', `<symbol id="${key}"`)
.replace('</svg>', '</symbol>'));
return `
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
${symbols.join('\n\t')}
</svg>
`.trim();
}