Initiated TabView component

pull/3/head
cagataycivici 2018-12-11 22:37:15 +03:00
parent e76afc4ec6
commit 4db09b7040
8 changed files with 309 additions and 1 deletions

View File

@ -46,6 +46,7 @@
<router-link to="/panel">&#9679; Panel</router-link> <router-link to="/panel">&#9679; Panel</router-link>
<router-link to="/fieldset">&#9679; Fieldset</router-link> <router-link to="/fieldset">&#9679; Fieldset</router-link>
<router-link to="/flexgrid">&#9679; FlexGrid</router-link> <router-link to="/flexgrid">&#9679; FlexGrid</router-link>
<router-link to="/tabview">&#9679; TabView</router-link>
<router-link to="/toolbar">&#9679; Toolbar</router-link> <router-link to="/toolbar">&#9679; Toolbar</router-link>
</div> </div>
</div> </div>

View File

@ -4,5 +4,6 @@
@import '../../components/button/Button.css'; @import '../../components/button/Button.css';
@import '../../components/panel/Panel.css'; @import '../../components/panel/Panel.css';
@import '../../components/fieldset/Fieldset.css'; @import '../../components/fieldset/Fieldset.css';
@import '../../components/tabview/TabView.css';
@import '../../components/textarea/Textarea.css'; @import '../../components/textarea/Textarea.css';
@import '../../components/toolbar/Toolbar.css'; @import '../../components/toolbar/Toolbar.css';

View File

@ -0,0 +1,19 @@
<template>
<div class="p-tabview-panel" role="tabpanel" v-show="active">
<slot></slot>
</div>
</template>
<script>
export default {
props: {
header: null,
disabled: Boolean
},
data() {
return {
active: false
}
}
}
</script>

View File

@ -0,0 +1,147 @@
.p-tabview {
padding: .25em;
}
.p-tabview .p-tabview-nav {
margin: 0;
}
.p-tabview .p-tabview-nav:after {
content: "";
display: table;
clear: both;
}
.p-tabview .p-tabview-nav li {
list-style: none;
float: left;
position: relative;
margin: 0 .125em 1px 0;
padding: 0;
white-space: nowrap;
}
.p-tabview .p-tabview-nav li a {
float: left;
padding: .5em 1em;
text-decoration: none;
}
.p-tabview .p-tabview-nav li.p-tabview-selected a,
.p-tabview .p-tabview-nav li.p-disabled a,
.p-tabview .p-tabview-nav li.p-state-processing a {
cursor: text;
}
.p-tabview .p-tabview-nav li a,
.p-tabview.p-tabview-collapsible .p-tabview-nav li.p-tabview-selected a {
cursor: pointer;
}
.p-tabview .p-tabview-panel {
border-width: 0;
padding: 1em;
background: none;
}
.p-tabview .p-tabview-nav li {
display: block;
}
.p-tabview .p-tabview-nav li .p-tabview-left-icon,
.p-tabview .p-tabview-nav li .p-tabview-right-icon,
.p-tabview .p-tabview-nav li .p-tabview-title {
vertical-align: middle;
}
.p-tabview .p-tabview-nav li .p-tabview-left-icon {
margin-right: .25em;
vertical-align: middle;
}
.p-tabview .p-tabview-nav li .p-tabview-right-icon {
margin-left: .25em;
vertical-align: middle;
}
.p-tabview .p-tabview-nav li .p-tabview-close {
margin: 0.5em 0.3em 0 0;
cursor: pointer;
}
/* per orientation settings */
/* top and bottom */
.p-tabview.p-tabview-top > .p-tabview-nav li {
border-bottom: 0;
top: 1px;
}
.p-tabview.p-tabview-top > .p-tabview-nav {
padding: .2em .2em 0;
}
.p-tabview.p-tabview-bottom > .p-tabview-nav {
padding: 0 .2em .2em;
}
.p-tabview.p-tabview-bottom > .p-tabview-nav li {
border-top: 0;
}
/* left and right*/
.p-tabview-left:after,
.p-tabview-right:after {
clear:both;
content: ".";
display: block;
height: 0;
visibility: hidden;
}
.p-tabview-left > .p-tabview-nav {
float:left;
width: 25%;
height: 300px;
background-image: none;
padding-top: 1px;
}
.p-tabview-left > .p-tabview-panels {
float:right;
width: 75%;
}
.p-tabview.p-tabview-left > .p-tabview-nav li,
.p-tabview.p-tabview-right > .p-tabview-nav li{
display: block;
float: right;
white-space: normal;
width: 99%;
}
.p-tabview.p-tabview-left > .p-tabview-nav li {
margin: 0 0 1px 0;
border-right:0 none;
}
.p-tabview.p-tabview-right > .p-tabview-nav {
float:right;
width: 25%;
height: 300px;
background-image: none;
padding-top: 1px;
}
.p-tabview.p-tabview-right > .p-tabview-panels {
float:left;
width: 75%;
}
.p-tabview.p-tabview-right > .p-tabview-nav li {
margin: 0 0 1px 0;
border-left:0 none;
}
/* RTL */
.p-rtl .p-tabview .p-tabview-nav li {
float: right;
}

View File

@ -0,0 +1,60 @@
<template>
<div class="p-tabview p-component p-tabview-top">
<ul class="p-tabview-nav p-resest" role="tablist">
<li role="presentation" v-for="(tab,i) of tabs" :key="tab.header" :class="{'p-highlight': (d_activeTabIndex === i)}">
<a role="tab" @click="onTabClick($event, tab, i)">
<span class="p-tabview-title">{{tab.header}}</span>
</a>
</li>
</ul>
<div class="p-tabview-panels">
<slot></slot>
</div>
</div>
</template>
<script>
export default {
props: {
activeIndex: {
type: Number,
default: 0,
},
orientation: {
type: String,
default: 'top'
}
},
data() {
return {
d_activeTabIndex: this.activeIndex,
tabs: []
};
},
watch: {
activeIndex(newValue) {
this.activateTab(newValue);
}
},
mounted() {
this.tabs = this.$children;
this.tabs[this.activeIndex].active = true;
},
methods: {
onTabClick(event, tab, index) {
this.activateTab(index);
this.$emit('tabchange', {
tab: tab,
index: index
});
},
activateTab(index) {
this.d_activeTabIndex = index;
for (let i = 0; i < this.tabs.length; i++) {
this.tabs[i].active = (i === index);
}
}
}
}
</script>

View File

@ -8,6 +8,8 @@ import ListBox from './components/listbox/ListBox';
import Panel from './components/panel/Panel'; import Panel from './components/panel/Panel';
import Textarea from './components/textarea/Textarea'; import Textarea from './components/textarea/Textarea';
import Toolbar from './components/toolbar/Toolbar'; import Toolbar from './components/toolbar/Toolbar';
import TabView from './components/tabview/TabView';
import TabPanel from './components/tabview/TabPanel';
import './assets/styles/primevue.css'; import './assets/styles/primevue.css';
import 'primeflex/primeflex.css'; import 'primeflex/primeflex.css';
@ -20,8 +22,10 @@ Vue.component('p-button', Button);
Vue.component('p-listBox', ListBox); Vue.component('p-listBox', ListBox);
Vue.component('p-panel', Panel); Vue.component('p-panel', Panel);
Vue.component('p-fieldset', Fieldset); Vue.component('p-fieldset', Fieldset);
Vue.component('p-toolbar', Toolbar); Vue.component('p-tabView', TabView);
Vue.component('p-tabPanel', TabPanel);
Vue.component('p-textarea', Textarea); Vue.component('p-textarea', Textarea);
Vue.component('p-toolbar', Toolbar);
new Vue({ new Vue({
router, router,

View File

@ -46,6 +46,11 @@ export default new Router({
name: 'textarea', name: 'textarea',
component: () => import('./views/textarea/TextareaDemo.vue') component: () => import('./views/textarea/TextareaDemo.vue')
}, },
{
path: '/tabview',
name: 'tabview',
component: () => import('./views/tabview/TabViewDemo.vue')
},
{ {
path: '/toolbar', path: '/toolbar',
name: 'toolbar', name: 'toolbar',

View File

@ -0,0 +1,71 @@
<template>
<div>
<div class="content-section introduction">
<div class="feature-intro">
<h1>TabView</h1>
<p>TabView is a container component to group content with tabs.</p>
</div>
</div>
<div class="content-section implementation">
<h3 class="first">Basic</h3>
<p-tabView>
<p-tabPanel header="Godfather I">
The story begins as Don Vito Corleone, the head of a New York Mafia family, overseeshis daughter's wedding. His beloved son ichael has just come home from the war,
but does not intend to become part of his father's business. Through Michael's life the nature of the family business becomes clear. The business of the family is
just like the head of the family, kind and benevolent to those who give respect, but given to ruthless violence whenever anything stands against the good of the family.
</p-tabPanel>
<p-tabPanel header="Godfather II">
Francis Ford Coppola's legendary continuation and sequel to his landmark 1972 film, TheGodfather parallels the young Vito Corleone's rise with his son Michael's spiritual fall,
deepening The Godfather's depiction of the dark side of the American dream. In the early 1900s, the child Vito flees his Sicilian village for America after the local Mafia kills
his family. Vito struggles to make a living, legally or illegally, for his wife and growing brood in Little Italy.
</p-tabPanel>
<p-tabPanel header="Godfather III">
The Godfather Part III is set in 1979 and 1980. Michael has moved back to New York and taken great strides to remove the family from crime. He turns over his New York criminal
interests to longtime enforcer Joey Zasa. He uses his wealth in an attempt to rehabilitate his reputation through numerous philanthropic acts, administered by a foundation named after his father.
A decade earlier, he gave custody of his two children to Kay, who has since remarried.
</p-tabPanel>
</p-tabView>
<h3>Programmatic</h3>
<p-button icon="pi pi-chevron-left" @click="prev" class="p-button-secondary" />
<p-button icon="pi pi-chevron-right" @click="next" style="margin-left: .5em" class="p-button-secondary"/>
<p-tabView :activeIndex="activeIndex">
<p-tabPanel header="Godfather I">
The story begins as Don Vito Corleone, the head of a New York Mafia family, overseeshis daughter's wedding. His beloved son ichael has just come home from the war,
but does not intend to become part of his father's business. Through Michael's life the nature of the family business becomes clear. The business of the family is
just like the head of the family, kind and benevolent to those who give respect, but given to ruthless violence whenever anything stands against the good of the family.
</p-tabPanel>
<p-tabPanel header="Godfather II">
Francis Ford Coppola's legendary continuation and sequel to his landmark 1972 film, TheGodfather parallels the young Vito Corleone's rise with his son Michael's spiritual fall,
deepening The Godfather's depiction of the dark side of the American dream. In the early 1900s, the child Vito flees his Sicilian village for America after the local Mafia kills
his family. Vito struggles to make a living, legally or illegally, for his wife and growing brood in Little Italy.
</p-tabPanel>
<p-tabPanel header="Godfather III">
The Godfather Part III is set in 1979 and 1980. Michael has moved back to New York and taken great strides to remove the family from crime. He turns over his New York criminal
interests to longtime enforcer Joey Zasa. He uses his wealth in an attempt to rehabilitate his reputation through numerous philanthropic acts, administered by a foundation named after his father.
A decade earlier, he gave custody of his two children to Kay, who has since remarried.
</p-tabPanel>
</p-tabView>
</div>
</div>
</template>
<script>
export default {
data() {
return {
activeIndex: 1
}
},
methods: {
next() {
this.activeIndex = this.activeIndex === 2 ? 0 : this.activeIndex + 1;
},
prev() {
this.activeIndex = this.activeIndex === 0 ? 2 : this.activeIndex - 1;
}
}
}
</script>