Demo updates

pull/3852/head
Tuğçe Küçükoğlu 2023-04-11 10:17:19 +03:00
parent 586c2f563c
commit a01b5696fd
4 changed files with 174 additions and 78 deletions

View File

@ -0,0 +1,79 @@
<template>
<DocSectionText v-bind="$attrs">
<p>AccordionTabs can be generated dynamically using the standard <i>v-for</i> directive.</p>
</DocSectionText>
<div class="card">
<Accordion :activeIndex="0">
<AccordionTab v-for="tab in tabs" :key="tab.title" :header="tab.title">
<p>{{ tab.content }}</p>
</AccordionTab>
</Accordion>
</div>
<DocSectionCode :code="code" />
</template>
<script>
export default {
data() {
return {
tabs: [
{ title: 'Title 1', content: 'Content 1' },
{ title: 'Title 2', content: 'Content 2' },
{ title: 'Title 3', content: 'Content 3' }
],
code: {
basic: `
<Accordion :activeIndex="0">
<AccordionTab v-for="tab in tabs" :key="tab.title" :header="tab.title">
<p>{{ tab.content }}</p>
</AccordionTab>
</Accordion>`,
options: `
<template>
<div class="card">
<Accordion :activeIndex="0">
<AccordionTab v-for="tab in tabs" :key="tab.title" :header="tab.title">
<p>{{ tab.content }}</p>
</AccordionTab>
</Accordion>
</div>
</template>
<script>
export default {
data() {
return {
tabs: [
{ title: 'Title 1', content: 'Content 1' },
{ title: 'Title 2', content: 'Content 2' },
{ title: 'Title 3', content: 'Content 3' }
]
};
}
};
<\/script>`,
composition: `
<template>
<div class="card">
<Accordion :activeIndex="0">
<AccordionTab v-for="tab in tabs" :key="tab.title" :header="tab.title">
<p>{{ tab.content }}</p>
</AccordionTab>
</Accordion>
</div>
</template>
<script setup>
import { ref } from 'vue';
const tabs = ref([
{ title: 'Title 1', content: 'Content 1' },
{ title: 'Title 2', content: 'Content 2' },
{ title: 'Title 3', content: 'Content 3' }
]);
<\/script>`
}
};
}
};
</script>

View File

@ -1,26 +1,18 @@
<template>
<DocSectionText v-bind="$attrs">
<p>A simple Panel is created with a <i>header</i> property along with the content as children.</p>
</DocSectionText>
<DocSectionText v-bind="$attrs"> </DocSectionText>
<div class="card">
<Accordion :activeIndex="0">
<AccordionTab header="Header I" :pt="{ headeraction: { class: 'bg-blue-500' }, headericon: { class: 'text-white' }, headertitle: { class: 'text-white' } }">
<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>
</AccordionTab>
<AccordionTab header="Header II">
<p>
Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim
ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Consectetur, adipisci velit, sed quia non numquam eius modi.
</p>
</AccordionTab>
<AccordionTab header="Header III">
<p>
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.
</p>
<AccordionTab
v-for="(tab, index) in tabs"
:key="tab.title"
:header="tab.title"
:pt="{
headeraction: ({ props, parent }) => ({
class: panelClass(props, parent, index)
})
}"
>
<p>{{ tab.content }}</p>
</AccordionTab>
</Accordion>
</div>
@ -31,86 +23,104 @@
export default {
data() {
return {
tabs: Array.from({ length: 3 }, (_, i) => ({
title: `Header ${i + 1}`,
content: `Tab ${i + 1} Content`
})),
code: {
basic: `
<Accordion :activeIndex="0">
<AccordionTab header="Header I" :pt="{ headeraction: { class: 'bg-blue-500' }, headericon: { class: 'text-white' }, headertitle: { class: 'text-white' } }">
<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>
</AccordionTab>
<AccordionTab header="Header II">
<p>
Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim
ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Consectetur, adipisci velit, sed quia non numquam eius modi.
</p>
</AccordionTab>
<AccordionTab header="Header III">
<p>
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.
</p>
<AccordionTab v-for="(tab, index) in tabs" :key="tab.title" :header="tab.title"
:pt="{
headeraction: ({ props, parent }) => ({
class: panelClass(props, parent, index)
})
}">
<p>{{ tab.content }}</p>
</AccordionTab>
</Accordion>`,
options: `
<template>
<div class="card">
<Accordion :activeIndex="0">
<AccordionTab header="Header I" :pt="{ headeraction: { class: 'bg-blue-500' }, headericon: { class: 'text-white' }, headertitle: { class: 'text-white' } }">
<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>
</AccordionTab>
<AccordionTab header="Header II">
<p>
Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim
ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Consectetur, adipisci velit, sed quia non numquam eius modi.
</p>
</AccordionTab>
<AccordionTab header="Header III">
<p>
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.
</p>
<AccordionTab v-for="(tab, index) in tabs" :key="tab.title" :header="tab.title"
:pt="{
headeraction: ({ props, parent }) => ({
class: panelClass(props, parent, index)
})
}">
<p>{{ tab.content }}</p>
</AccordionTab>
</Accordion>
</div>
</template>
<script>
export default {
data() {
return {
tabs: Array.from({ length: 3 }, (_, i) => ({
title: \`Header \${i + 1}\`,
content: \`Tab \${i + 1} Content\`
}))
}
},
methods: {
panelClass(props, parent, index) {
return [
{
'bg-primary': parent.state.d_activeIndex === index
}
];
}
}
}
<\/script>`,
composition: `
<template>
<div class="card">
<Accordion :activeIndex="0">
<AccordionTab header="Header I" :pt="{ headeraction: { class: 'bg-blue-500' }, headericon: { class: 'text-white' }, headertitle: { class: 'text-white' } }">
<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>
</AccordionTab>
<AccordionTab header="Header II">
<p>
Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim
ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Consectetur, adipisci velit, sed quia non numquam eius modi.
</p>
</AccordionTab>
<AccordionTab header="Header III">
<p>
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.
</p>
<AccordionTab v-for="(tab, index) in tabs" :key="tab.title" :header="tab.title"
:pt="{
headeraction: ({ props, parent }) => ({
class: panelClass(props, parent, index)
})
}">
<p>{{ tab.content }}</p>
</AccordionTab>
</Accordion>
</div>
</template>
<script setup>
import { ref } from 'vue';
const tabs = ref(Array.from({ length: 3 }, (_, i) => ({
title: \`Header \${i + 1}\`,
content: \`Tab \${i + 1} Content\`
})));
const panelClass = (props, parent, index) => {
return [
{
'bg-primary': parent.state.d_activeIndex === index
}
];
};
<\/script>`
}
};
},
methods: {
panelClass(props, parent, index) {
console.log(props, parent);
return [
{
'bg-primary': parent.state.d_activeIndex === index
}
];
}
}
};
</script>

View File

@ -3,7 +3,7 @@
<div class="card">
<TabView>
<TabPanel
v-for="(tab, index) in scrollableTabs"
v-for="(tab, index) in tabs"
:key="tab.title"
:header="tab.title"
:pt="{
@ -23,14 +23,14 @@
export default {
data() {
return {
scrollableTabs: Array.from({ length: 3 }, (_, i) => ({
tabs: Array.from({ length: 3 }, (_, i) => ({
title: `Header ${i + 1}`,
content: `Tab ${i + 1} Content`
})),
code: {
basic: `
<TabView>
<TabPanel v-for="(tab, index) in scrollableTabs" :key="tab.title" :header="tab.title"
<TabPanel v-for="(tab, index) in tabs" :key="tab.title" :header="tab.title"
:pt="{
headeraction: ({ props, parent }) => ({
class: panelClass(props, parent, index)
@ -43,7 +43,7 @@ export default {
<template>
<div class="card">
<TabView>
<TabPanel v-for="(tab, index) in scrollableTabs" :key="tab.title" :header="tab.title"
<TabPanel v-for="(tab, index) in tabs" :key="tab.title" :header="tab.title"
:pt="{
headeraction: ({ props, parent }) => ({
class: panelClass(props, parent, index)
@ -59,7 +59,7 @@ export default {
export default {
data() {
return {
scrollableTabs: Array.from({ length: 3 }, (_, i) => ({
tabs: Array.from({ length: 3 }, (_, i) => ({
title: \`Header \${i + 1}\`,
content: \`Tab \${i + 1} Content\`
}))
@ -80,7 +80,7 @@ export default {
<template>
<div class="card">
<TabView>
<TabPanel v-for="(tab, index) in scrollableTabs" :key="tab.title" :header="tab.title"
<TabPanel v-for="(tab, index) in tabs" :key="tab.title" :header="tab.title"
:pt="{
headeraction: ({ props, parent }) => ({
class: panelClass(props, parent, index)
@ -95,7 +95,7 @@ export default {
<script setup>
import { ref } from 'vue';
const scrollableTabs = ref(Array.from({ length: 3 }, (_, i) => ({
const tabs = ref(Array.from({ length: 3 }, (_, i) => ({
title: \`Header \${i + 1}\`,
content: \`Tab \${i + 1} Content\`
})));

View File

@ -7,11 +7,13 @@ import AccessibilityDoc from '@/doc/accordion/AccessibilityDoc';
import BasicDoc from '@/doc/accordion/BasicDoc';
import ControlledDoc from '@/doc/accordion/ControlledDoc.vue';
import Disabled from '@/doc/accordion/DisabledDoc.vue';
import DynamicDoc from '@/doc/accordion/DynamicDoc';
import ImportDoc from '@/doc/accordion/ImportDoc';
import MultipleDoc from '@/doc/accordion/MultipleDoc.vue';
import StyleDoc from '@/doc/accordion/StyleDoc';
import TemplateDoc from '@/doc/accordion/TemplateDoc.vue';
import PTComponent from '@/doc/accordion/pt/index.vue';
export default {
data() {
return {
@ -26,6 +28,11 @@ export default {
label: 'Basic',
component: BasicDoc
},
{
id: 'dynamic',
label: 'Dynamic',
component: DynamicDoc
},
{
id: 'multiple',
label: 'Multiple',