Created
December 5, 2016 19:40
-
-
Save imkost/9e549c7adc48db18e6c79cf92d850735 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
function NameEditor({ id }) { | |
// Add color to distinguish name editors | |
const color = { | |
0: '#b6e1c1', | |
1: '#b7c4ed', | |
}[id]; | |
return ` | |
<div class="nameEditor" style="background: ${color}"> | |
... | |
Hello, <span class="nameEditor__name-${id}"></span> | |
... | |
</div> | |
`; | |
} | |
NameEditor.onKeyUp = (input, id) => { | |
const elems = document.getElementsByClassName(`nameEditor__name-${id}`); | |
for (const elem of elems) { | |
elem.innerText = input.value; | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment