Created
February 25, 2019 12:17
-
-
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
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
/** 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