Created
December 10, 2019 13:12
-
-
Save arash16/b75decaa13f97f6c2d1ab7cb9f455eff to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const cache = {}; | |
export function makePlaceholder(width, height) { | |
const key = `${width}x${height}`; | |
if (!cache[key]) { | |
cache[key] = 'data:image/svg+xml;base64,' + window.btoa( | |
`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${width} ${height}"> | |
<rect width="${width}" height="${height}" fill="#f0f0f0"/> | |
</svg>` | |
); | |
} | |
return cache[key]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment