Skip to content

Commit

Permalink
feat(runtime): create Tabs component and improve demo app (WIP)
Browse files Browse the repository at this point in the history
  • Loading branch information
msaelices committed May 17, 2020
1 parent 5c3178d commit 188a0bf
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 35 deletions.
70 changes: 36 additions & 34 deletions apps/demo/app/Tabs.js
Original file line number Diff line number Diff line change
@@ -1,39 +1,41 @@
import PageComp from '~/PageComp'
import { ref } from 'nativescript-vue'
import { Tabs } from 'nativescript-vue'

export default {
template: `<Tabs selectedIndex="1">
<TabStrip>
<TabStripItem>
<Label text="Home"></Label>
</TabStripItem>
<TabStripItem>
<Label text="Account"></Label>
</TabStripItem>
<TabStripItem>
<Label text="Search"></Label>
</TabStripItem>
</TabStrip>
<TabContentItem>
<GridLayout>
<Label text="Home Page"></Label>
</GridLayout>
</TabContentItem>
<TabContentItem>
<GridLayout>
<Label text="Account Page"></Label>
</GridLayout>
</TabContentItem>
<TabContentItem>
<GridLayout>
<Label text="Search Page"></Label>
</GridLayout>
</TabContentItem>
</Tabs>`,
data() {
return {}
components: {
Tabs,
},
watch: {
model(value) {},
template: `
<StackLayout>
<Label :text="activeTab" />
<Button text="Add tab" @tap="tabs.push({title: 'new', text: 'new tab'})" />
<Button text="Go last" @tap="activeTab = tabs.length - 1" />
<Tabs v-model="activeTab">
<TabStrip>
<TabStripItem
v-for="(tab, i) in tabs"
:key="i + tab.title"
:title="tab.title">
</TabStripItem>
</TabStrip>
<TabContentItem
v-for="(tab, i) in tabs"
:key="i + tab.title">
<GridLayout>
<Label :text="tab.text" />
</GridLayout>
</TabContentItem>
</Tabs>
</StackLayout>`,
data() {
return {
activeTab: 1,
tabs: [
{ title: 'First Tab', text: 'im the first tab' },
{ title: 'Second Tab', text: 'im the second tab' },
{ title: 'Third Tab', text: 'im the third tab' },
],
}
},
mounted() {},
}
17 changes: 17 additions & 0 deletions packages/runtime/src/components/Tabs.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { FunctionalComponent, h } from '@vue/runtime-core'
import { NSVElement } from '../nodes'

export const Tabs: FunctionalComponent = (props, ctx) => {
return h(
'InternalTabs',
{
...ctx.attrs,
onVnodeMounted(vnode) {
const el = vnode.el as NSVElement
console.log(el)
// TODO: Implement
},
},
ctx.slots.default ? ctx.slots.default() : undefined
)
}
1 change: 1 addition & 0 deletions packages/runtime/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,5 +79,6 @@ export { vShow } from './directives/vShow'
// Runtime components
export { ActionBar } from './components/ActionBar'
export { ListView } from './components/ListView'
export { Tabs } from './components/Tabs'

export * from '@vue/runtime-core'
2 changes: 1 addition & 1 deletion packages/runtime/src/registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ if (!__TEST__) {
}
)
registerElement(
'Tabs',
'InternalTabs',
() => require('@nativescript/core').Tabs,
{
model: {
Expand Down

0 comments on commit 188a0bf

Please sign in to comment.