Skip to content

Instantly share code, notes, and snippets.

@wanderer
Last active December 31, 2017 03:10
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 wanderer/172f9a9646e1981076763f4a75024684 to your computer and use it in GitHub Desktop.
Save wanderer/172f9a9646e1981076763f4a75024684 to your computer and use it in GitHub Desktop.
import 'tachyons'
import 'tachyons-base/css/tachyons-base.css'
import {h, app} from 'hyperapp'
const state = {
windows: []
}
const actions = {
changeURL: value => state => {
if (value.code === 'Enter') {
const newState = {windows: []}
newState.windows[value.srcElement.dataset.index] = {
url: value.srcElement.value
}
return newState
}
}
}
const view = (state, actions) =>
h('div', {class: 'fl w-100 h-100'}, state.windows.map((window, i) => {
return h('div', {class: 'fl w-100 h-100 flex flex-column', key: i}, [
h('input', {type: 'text', onkeydown: actions.changeURL, 'data-index': i}),
h('iframe', {
class: 'fl w-100 h-100 bw0',
src: window.url
})
])
}))
window.main = app(state, actions, view, document.body)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment