Created
February 3, 2020 17:56
-
-
Save danhollick/72b30c0ce5a73849d46ce5adfaf5be2c to your computer and use it in GitHub Desktop.
Updating the UI
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
<div id="background"> | |
<h3 id="foreground">The quick brown fox</h3> | |
</div> | |
<h2 id="contrast"> </h2> | |
<script> | |
window.onmessage = async event => { | |
const message = event.data.pluginMessage | |
console.log(message) | |
if (message.type === 'selectionChange') { | |
const background = document.getElementById('background') | |
const foreground = document.getElementById('foreground') | |
const contrast = document.getElementById('contrast') | |
background.style = `background-color: ${message.background};` | |
foreground.style = `color: ${message.foreground};` | |
contrast.textContent = message.contrast | |
} | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment