All files / utils getPlaceholderUrl.ts

100% Statements 9/9
100% Branches 0/0
100% Functions 3/3
100% Lines 5/5

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 181x               1x 1x           1x 1x  
export const getSvg = (width, height) => `
    <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${width} ${height}" style="background: #e7e7e7">
        <svg xmlns="http://www.w3.org/2000/svg" viewBox="-22.4 -37.5 135 165">
            <path fill="#a1a1a1" d="M5.53 22.89h78.95v61.58H5.53zM12.47 21.31H8.58V9.1h-3V5.52h10V9.1h-3.11zM16.8 5.52h6c3.55 0 5.59 1.94 5.59 5.32 0 2.78-1.18 4.4-3.64 4.94l4.37 5.53h-4.87l-3.61-5.15v5.15H16.8zm5.55 8a2.17 2.17 0 002.16-2.33 1.89 1.89 0 00-1.87-2.16h-1.92v4.44zM41.73 15.38c0 4.32-1.91 6.33-6.08 6.33-2.43 0-4.21-.86-5.13-2.5a8.14 8.14 0 01-.71-3.94V5.52h3.89v9.82c0 1.83.62 2.58 2.14 2.58s2-.78 2-2.63V5.52h3.89zM43.64 5.52h5.2l3.18 10.64 3-10.64h5.2v15.79h-3.58V10.39L53.3 21.31h-2.87l-3.29-10.79v10.79h-3.5zM62.25 5.52h6.1a4.94 4.94 0 015.23 5.3 5.24 5.24 0 01-5.19 5.56h-2.26v4.93h-3.88zm5.55 7.24a1.75 1.75 0 001.84-1.79 1.75 1.75 0 00-2-1.83h-1.47v3.66zM74.8 5.52h9.64V9.1h-5.39v2.5h5.39v3.62h-5.39v6.09H74.8z"/>
        </svg>
    </svg>
`;
 
export const convertToUrl = (input) =>
    `data:image/svg+xml,${encodeURIComponent(input)
        .replace(/%20/g, " ")
        .replace(/%0A/g, "")
        .replace(/\s\s+/g, " ")
        .trim()}`;
 
export const getPlaceholderUrl = (width, height) =>
    convertToUrl(getSvg(width, height));