Skip to content

Instantly share code, notes, and snippets.

@brunojppb
Created February 25, 2019 12:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brunojppb/3185d7f2e1045d33c616dd90f5fedd7e to your computer and use it in GitHub Desktop.
Save brunojppb/3185d7f2e1045d33c616dd90f5fedd7e to your computer and use it in GitHub Desktop.
Show select input to change icon font-size for preview in Fontastic generated HTM
/** Show select input to change icon font-size for preview in Fontastic generated HTML (http://app.fontastic.me) */
const xpath = "//h2[text()='CSS mapping']";
const mainHeader = document.evaluate(xpath, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
const fontSizes = [16, 24, 32, 64, 128, 256];
const selectList = document.createElement('select');
selectList.id = "font-size-select";
fontSizes.forEach(size => {
const option = document.createElement('option');
option.value = `${size}px`;
option.text = `${size}px`;
selectList.appendChild(option);
});
selectList.addEventListener('change', (event) => {
const fontSize = event.target.value;
const icons = document.getElementsByClassName('icon');
for (let icon of icons) {
icon.style.width = fontSize;
icon.style.height = fontSize;
icon.style.fontSize = fontSize;
icon.style.padding = 0;
}
});
mainHeader.parentNode.insertBefore(selectList, mainHeader.nextSibling);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment