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> <template>
<DocSectionText v-bind="$attrs"> <DocSectionText v-bind="$attrs"> </DocSectionText>
<p>A simple Panel is created with a <i>header</i> property along with the content as children.</p>
</DocSectionText>
<div class="card"> <div class="card">
<Accordion :activeIndex="0"> <Accordion :activeIndex="0">
<AccordionTab header="Header I" :pt="{ headeraction: { class: 'bg-blue-500' }, headericon: { class: 'text-white' }, headertitle: { class: 'text-white' } }"> <AccordionTab
<p> v-for="(tab, index) in tabs"
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 :key="tab.title"
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. :header="tab.title"
</p> :pt="{
</AccordionTab> headeraction: ({ props, parent }) => ({
<AccordionTab header="Header II"> class: panelClass(props, parent, index)
<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> <p>{{ tab.content }}</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> </AccordionTab>
</Accordion> </Accordion>
</div> </div>
@ -31,86 +23,104 @@
export default { export default {
data() { data() {
return { return {
tabs: Array.from({ length: 3 }, (_, i) => ({
title: `Header ${i + 1}`,
content: `Tab ${i + 1} Content`
})),
code: { code: {
basic: ` basic: `
<Accordion :activeIndex="0"> <Accordion :activeIndex="0">
<AccordionTab header="Header I" :pt="{ headeraction: { class: 'bg-blue-500' }, headericon: { class: 'text-white' }, headertitle: { class: 'text-white' } }"> <AccordionTab v-for="(tab, index) in tabs" :key="tab.title" :header="tab.title"
<p> :pt="{
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 headeraction: ({ props, parent }) => ({
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. class: panelClass(props, parent, index)
</p> })
</AccordionTab> }">
<AccordionTab header="Header II"> <p>{{ tab.content }}</p>
<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> </AccordionTab>
</Accordion>`, </Accordion>`,
options: ` options: `
<template> <template>
<div class="card"> <div class="card">
<Accordion :activeIndex="0"> <Accordion :activeIndex="0">
<AccordionTab header="Header I" :pt="{ headeraction: { class: 'bg-blue-500' }, headericon: { class: 'text-white' }, headertitle: { class: 'text-white' } }"> <AccordionTab v-for="(tab, index) in tabs" :key="tab.title" :header="tab.title"
<p> :pt="{
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 headeraction: ({ props, parent }) => ({
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. class: panelClass(props, parent, index)
</p> })
</AccordionTab> }">
<AccordionTab header="Header II"> <p>{{ tab.content }}</p>
<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> </AccordionTab>
</Accordion> </Accordion>
</div> </div>
</template> </template>
<script> <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>`, <\/script>`,
composition: ` composition: `
<template> <template>
<div class="card"> <div class="card">
<Accordion :activeIndex="0"> <Accordion :activeIndex="0">
<AccordionTab header="Header I" :pt="{ headeraction: { class: 'bg-blue-500' }, headericon: { class: 'text-white' }, headertitle: { class: 'text-white' } }"> <AccordionTab v-for="(tab, index) in tabs" :key="tab.title" :header="tab.title"
<p> :pt="{
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 headeraction: ({ props, parent }) => ({
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. class: panelClass(props, parent, index)
</p> })
</AccordionTab> }">
<AccordionTab header="Header II"> <p>{{ tab.content }}</p>
<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> </AccordionTab>
</Accordion> </Accordion>
</div> </div>
</template> </template>
<script setup> <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>` <\/script>`
} }
}; };
},
methods: {
panelClass(props, parent, index) {
console.log(props, parent);
return [
{
'bg-primary': parent.state.d_activeIndex === index
}
];
}
} }
}; };
</script> </script>

View File

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

View File

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