Skip to content

Instantly share code, notes, and snippets.

@vertcitron
Created September 26, 2019 21:19
Show Gist options
  • Save vertcitron/7905837e93b36dbc92bed9e50d8e609a to your computer and use it in GitHub Desktop.
Save vertcitron/7905837e93b36dbc92bed9e50d8e609a to your computer and use it in GitHub Desktop.
import TextFieldButton from "./components/TextFieldButton"
import Viewer from "./components/Viewer"
const appElement = document.getElementById('app')
const instantViewer = new Viewer()
instantViewer.label = 'I react to input events:'
const validatedViewer = new Viewer()
validatedViewer.label = 'I react to change events:'
const textFieldBtn = new TextFieldButton()
textFieldBtn.placeholder = 'Enter text here...'
textFieldBtn.value = ''
textFieldBtn.onInput = (value: string) => {
instantViewer.content = value
}
textFieldBtn.onChange = (value: string) => {
validatedViewer.content = value
}
function renderApp() {
if (appElement !== null) {
appElement.innerHTML = ''
textFieldBtn.render(appElement)
instantViewer.render(appElement)
validatedViewer.render(appElement)
}
}
renderApp()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment