Files
GS13NG/tgui/src/components/tabs.ract
T

28 lines
659 B
Plaintext

<link rel='ractive' href='components/tabs/tab.ract'>
<script>
component.exports = {
oninit () {
this.set('active', this.findComponent('tab').get('name'))
this.on('switch', event => {
this.set('active', event.node.textContent.trim()) // Hack but it works...
})
this.observe('active', (newkey, oldkey, path) => {
for (let tab of this.findAllComponents('tab')) {
tab.set('shown', (tab.get('name') === newkey))
}
})
}
}
</script>
<header>
{{#each tabs}}
<ui-button pane='{{.}}' on-press='switch'>{{.}}</ui-button>
{{/each}}
</header>
<ui-display>
{{>content}}
</ui-display>