Update Tabview demo

pull/1533/head
mertsincan 2021-08-31 10:12:19 +03:00
parent 85be3bb715
commit 41fe395bf3
2 changed files with 73 additions and 22 deletions

View File

@ -33,12 +33,12 @@
<div class="card"> <div class="card">
<h5>Programmatic</h5> <h5>Programmatic</h5>
<div class="p-py-2"> <div class="p-py-2">
<Button @click="active = 0" class="p-button-text" label="Activate 1st" /> <Button @click="active1 = 0" class="p-button-text" label="Activate 1st" />
<Button @click="active = 1" class="p-button-text p-mr-2" label="Activate 2nd" /> <Button @click="active1 = 1" class="p-button-text p-mr-2" label="Activate 2nd" />
<Button @click="active = 2" class="p-button-text p-mr-2" label="Activate 3rd" /> <Button @click="active1 = 2" class="p-button-text p-mr-2" label="Activate 3rd" />
</div> </div>
<TabView ref="tabview2" v-model:activeIndex="active"> <TabView ref="tabview2" v-model:activeIndex="active1">
<TabPanel header="Header I"> <TabPanel header="Header I">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation
ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
@ -121,6 +121,21 @@
</TabPanel> </TabPanel>
</TabView> </TabView>
</div> </div>
<div class="card">
<h5>Scrollable</h5>
<div class="p-py-2">
<Button @click="active2 = 0" class="p-button-text" label="Activate 1st" />
<Button @click="active2 = 29" class="p-button-text p-mr-2" label="Activate 30th" />
<Button @click="active2 = 49" class="p-button-text p-mr-2" label="Activate 50th" />
</div>
<TabView v-model:activeIndex="active2" :scrollable="true">
<TabPanel v-for="tab in scrollableTabs" :key="tab.title" :header="tab.title">
<p>{{tab.content}}</p>
</TabPanel>
</TabView>
</div>
</div> </div>
<TabViewDoc/> <TabViewDoc/>
@ -134,7 +149,8 @@ import EventBus from '@/AppEventBus';
export default { export default {
data() { data() {
return { return {
active: 0, active1: 0,
active2: 0,
tabs: [ tabs: [
{ {
title: 'Header I', title: 'Header I',
@ -154,7 +170,8 @@ export default {
cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio.
Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus.` Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus.`
} }
] ],
scrollableTabs: Array.from({ length: 50 }, (_, i) => ({ title: `Tab ${i + 1}`, content: `Tab ${i + 1} Content` }))
} }
}, },
timeout: null, timeout: null,

View File

@ -333,12 +333,12 @@ export default {
<div class="card"> <div class="card">
<h5>Programmatic</h5> <h5>Programmatic</h5>
<div class="p-py-2"> <div class="p-py-2">
<Button @click="active = 0" class="p-button-text" label="Activate 1st" /> <Button @click="active1 = 0" class="p-button-text" label="Activate 1st" />
<Button @click="active = 1" class="p-button-text p-mr-2" label="Activate 2nd" /> <Button @click="active1 = 1" class="p-button-text p-mr-2" label="Activate 2nd" />
<Button @click="active = 2" class="p-button-text p-mr-2" label="Activate 3rd" /> <Button @click="active1 = 2" class="p-button-text p-mr-2" label="Activate 3rd" />
</div> </div>
<TabView ref="tabview2" v-model:activeIndex="active"> <TabView ref="tabview2" v-model:activeIndex="active1">
<TabPanel header="Header I"> <TabPanel header="Header I">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p> <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
</TabPanel> </TabPanel>
@ -409,6 +409,21 @@ export default {
</TabPanel> </TabPanel>
</TabView> </TabView>
</div> </div>
<div class="card">
<h5>Scrollable</h5>
<div class="p-py-2">
<Button @click="active2 = 0" class="p-button-text" label="Activate 1st" />
<Button @click="active2 = 29" class="p-button-text p-mr-2" label="Activate 30th" />
<Button @click="active2 = 49" class="p-button-text p-mr-2" label="Activate 50th" />
</div>
<TabView v-model:activeIndex="active2" :scrollable="true">
<TabPanel v-for="tab in scrollableTabs" :key="tab.title" :header="tab.title">
<p>{{tab.content}}</p>
</TabPanel>
</TabView>
</div>
</div> </div>
</template> </template>
@ -416,7 +431,8 @@ export default {
export default { export default {
data() { data() {
return { return {
active: 0, active1: 0,
active2: 0,
tabs: [ tabs: [
{ {
title: 'Header I', title: 'Header I',
@ -430,7 +446,8 @@ export default {
title: 'Header III', title: 'Header III',
content: "At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus." content: "At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus."
} }
] ],
scrollableTabs: Array.from({ length: 50 }, (_, i) => ({ title: \`Tab \${i + 1}\`, content: \`Tab \${i + 1} Content\` }))
} }
} }
} }
@ -476,12 +493,12 @@ export default {
<div class="card"> <div class="card">
<h5>Programmatic</h5> <h5>Programmatic</h5>
<div class="p-py-2"> <div class="p-py-2">
<Button @click="active = 0" class="p-button-text" label="Activate 1st" /> <Button @click="active1 = 0" class="p-button-text" label="Activate 1st" />
<Button @click="active = 1" class="p-button-text p-mr-2" label="Activate 2nd" /> <Button @click="active1 = 1" class="p-button-text p-mr-2" label="Activate 2nd" />
<Button @click="active = 2" class="p-button-text p-mr-2" label="Activate 3rd" /> <Button @click="active1 = 2" class="p-button-text p-mr-2" label="Activate 3rd" />
</div> </div>
<TabView ref="tabview2" v-model:activeIndex="active"> <TabView ref="tabview2" v-model:activeIndex="active1">
<TabPanel header="Header I"> <TabPanel header="Header I">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p> <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
</TabPanel> </TabPanel>
@ -552,6 +569,21 @@ export default {
</TabPanel> </TabPanel>
</TabView> </TabView>
</div> </div>
<div class="card">
<h5>Scrollable</h5>
<div class="p-py-2">
<Button @click="active2 = 0" class="p-button-text" label="Activate 1st" />
<Button @click="active2 = 29" class="p-button-text p-mr-2" label="Activate 30th" />
<Button @click="active2 = 49" class="p-button-text p-mr-2" label="Activate 50th" />
</div>
<TabView v-model:activeIndex="active2" :scrollable="true">
<TabPanel v-for="tab in scrollableTabs" :key="tab.title" :header="tab.title">
<p>{{tab.content}}</p>
</TabPanel>
</TabView>
</div>
</div> </div>
</template> </template>
@ -560,7 +592,8 @@ import { ref } from 'vue';
export default { export default {
setup() { setup() {
const active = ref(0); const active1 = ref(0);
const active2 = ref(0);
const tabs = ref([ const tabs = ref([
{ {
title: 'Header I', title: 'Header I',
@ -575,8 +608,9 @@ export default {
content: "At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus." content: "At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus."
} }
]); ]);
const scrollableTabs = ref(Array.from({ length: 50 }, (_, i) => ({ title: \`Tab \${i + 1}\`, content: \`Tab \${i + 1} Content\` })));
return { active, tabs } return { active1, active2, tabs, scrollableTabs }
} }
} }
<\\/script> <\\/script>