Skip to content

Commit

Permalink
Basic tabs support; switch cargo console to tabs
Browse files Browse the repository at this point in the history
  • Loading branch information
neersighted committed Feb 8, 2016
1 parent 21f0209 commit e4373d6
Show file tree
Hide file tree
Showing 7 changed files with 77 additions and 54 deletions.
10 changes: 5 additions & 5 deletions tgui/assets/tgui.js

Large diffs are not rendered by default.

16 changes: 8 additions & 8 deletions tgui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
"private": true,
"dependencies": {
"autoprefixer": "6.3.1",
"babel-core": "6.4.5",
"babel-plugin-external-helpers": "6.4.0",
"babel-polyfill": "6.3.14",
"babel-preset-es2015": "6.3.13",
"babel-core": "6.5.1",
"babel-plugin-external-helpers": "6.5.0",
"babel-polyfill": "6.5.0",
"babel-preset-es2015": "6.5.0",
"babel-preset-es2015-loose": "7.0.0",
"babel-register": "6.4.3",
"babel-register": "6.5.1",
"babelify": "7.2.0",
"babelify-external-helpers": "1.1.0",
"browserify": "13.0.0",
Expand All @@ -23,11 +23,11 @@
"gulp-cssnano": "2.1.0",
"gulp-if": "2.0.0",
"gulp-load-plugins": "1.2.0",
"gulp-postcss": "6.0.1",
"gulp-postcss": "6.1.0",
"gulp-size": "2.0.0",
"gulp-sourcemaps": "1.6.0",
"gulp-stylus": "2.3.0",
"gulp-uglify": "1.5.1",
"gulp-uglify": "1.5.2",
"gulplog": "1.0.0",
"html5shiv": "3.7.3",
"ie8": "0.3.2",
Expand All @@ -40,7 +40,7 @@
"postcss-font-weights": "2.0.1",
"postcss-opacity": "3.0.0",
"ractive": "0.7.3",
"ractive-componentify": "0.2.3",
"ractive-componentify": "0.2.4",
"ractive-events-keys": "0.2.1",
"ractive-transitions-fade": "0.3.1",
"require-globify": "1.3.0",
Expand Down
27 changes: 27 additions & 0 deletions tgui/src/components/tabs.ract
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<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>
3 changes: 3 additions & 0 deletions tgui/src/components/tabs/tab.ract
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{{#if shown}}
{{yield}}
{{/if}}
34 changes: 17 additions & 17 deletions tgui/src/components/warnings.ract
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
<script>
const versions = [11, 10, 9, 8]
const versions = [11, 10, 9, 8]

component.exports = {
data: {
userAgent: navigator.userAgent
},
computed: {
ie () {
if (document.documentMode) return document.documentMode
for (let version in versions) {
const div = document.createElement('div')
div.innerHTML = `<!--[if IE ${version}]><span></span><![endif]-->`
if (div.getElementsByTagName('span').length) return version
component.exports = {
data: {
userAgent: navigator.userAgent
},
computed: {
ie () {
if (document.documentMode) return document.documentMode
for (let version in versions) {
const div = document.createElement('div')
div.innerHTML = `<!--[if IE ${version}]><span></span><![endif]-->`
if (div.getElementsByTagName('span').length) return version
}
return undefined
}
return undefined
},
oninit () {
this.on('debug', () => this.toggle('debug'))
}
},
oninit () {
this.on('debug', () => this.toggle('debug'))
}
}
</script>


Expand Down
40 changes: 16 additions & 24 deletions tgui/src/interfaces/cargo.ract
Original file line number Diff line number Diff line change
@@ -1,24 +1,14 @@
<script>
import { filterMulti } from 'util/filter'
component.exports = {
data: {
filter: ''
},
oninit () {
this.observe('filter', (newkey, oldkey, keypath) => {
const categories = this.findAll('.display:nth-child(n+4)')
filterMulti(categories, this.get('filter').toLowerCase())
}, { init: false })
computed: {
tabs () {
return this.get('data.supplies').map(group => group.name)
}
}
}
</script>

<ui-display title='Cargo' button>
{{#partial button}}
{{#if config.fancy}}
<ui-input value='{{filter}}' placeholder='Filter...'/>
{{/if}}
{{/partial}}
<ui-display title='Cargo'>
<ui-section label='Shuttle'>
{{#if data.docked && !data.requestonly}}
<ui-button action='send'>{{data.location}}</ui-button>
Expand Down Expand Up @@ -85,12 +75,14 @@
<span>No Requests</span>
{{/each}}
</ui-display>
{{#each data.supplies}}
<ui-display title='{{name}}'>
{{#each packs}}
<ui-section label='{{name}}' candystripe right>
<ui-button action='add' params='{"id": "{{id}}"}'>{{cost}} Points</ui-button>
</ui-section>
{{/each}}
</ui-display>
{{/each}}
<ui-tabs tabs='{{tabs}}'>
{{#each data.supplies}}
<tab name='{{name}}'>
{{#each packs}}
<ui-section label='{{name}}' candystripe right>
<ui-button action='add' params='{"id": "{{id}}"}'>{{cost}} Points</ui-button>
</ui-section>
{{/each}}
</tab>
{{/each}}
</ui-tabs>
1 change: 1 addition & 0 deletions tgui/src/tgui.ract
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ component.exports = {
'ui-notice': require('components/notice'),
'ui-section': require('components/section'),
'ui-subdisplay': require('components/subdisplay'),
'ui-tabs': require('components/tabs'),
},
events: {
enter: require('ractive-events-keys').enter,
Expand Down

0 comments on commit e4373d6

Please sign in to comment.