Created
February 27, 2018 18:13
-
-
Save siwalikm/573a039d990c470295e29d608f873ce6 to your computer and use it in GitHub Desktop.
function to convert your css string to downloadable file
This file contains 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
cssStringToFileDownloader = function (cssString) { | |
var blob = new Blob([cssString], { type: 'text/css' }); | |
var el = document.createElement('a'); | |
el.download = 'cssPaletteBundle.css'; | |
el.href = URL.createObjectURL(blob); | |
el.dataset.downloadurl = ['text/css', el.download, el.href].join(':'); | |
el.style.display = 'none'; | |
document.body.appendChild(el); | |
el.click(); | |
document.body.removeChild(el); | |
setTimeout(function () { URL.revokeObjectURL(el.href); }, 1500); | |
}; | |
/* cssStringToFileDownloader('body{padding:12px;}') */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment