UNPKG

@publidata/utils-svg

Version:

Collection of methods to handle svg files and src

23 lines (17 loc) 870 B
import { ELEMENT_WIDTH, BORDER, BORDER_WIDTH_WRAPPER, WIDTH_ELEMENT_WRAPPER } from "./constants.js"; export const getCircleTranslate = iconWidth => `${16 + 2 - iconWidth / 29 / 2} 10`; export const getImageWidth = isArtBoard => isArtBoard ? "0.2 0.2" : "0.024 0.024"; export const getWidthWrapper = (icons) => (BORDER_WIDTH_WRAPPER[icons.length - 1] * 2 + WIDTH_ELEMENT_WRAPPER[icons.length - 1] * icons.length) * 10; // * 10 is same as PixelRatio export const getXOffset = (position, iconWidth) => BORDER + ELEMENT_WIDTH * position - Number(iconWidth / 2) - ELEMENT_WIDTH / 2; export const getBgXoffset = position => ELEMENT_WIDTH * position + BORDER; export const getIconTransform = (position, icon, isBody = false) => { const x = getXOffset(position, icon.viewbox.w); const y = icon.isImage && !isBody ? "180" : "358"; return `${x} ${y}`; };