UNPKG

@synergy-design-system/assets

Version:
22 lines (21 loc) 926 B
import { defaultIcons as sick2018Icons } from './default-icons.js'; import { defaultIcons as sick2025Icons } from './default-icons-2025.js'; export function createSpriteSheet(icons, iconset = 'sick2018') { const setToUse = iconset === 'sick2025' ? sick2025Icons : sick2018Icons; 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(); }