Last active
December 31, 2017 03:10
-
-
Save wanderer/172f9a9646e1981076763f4a75024684 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
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