mirror of
https://github.com/primefaces/primevue.git
synced 2025-05-10 01:12:37 +00:00
Update steps demos
This commit is contained in:
parent
4fdbe365ba
commit
a4a1f8dacb
19 changed files with 418 additions and 1235 deletions
|
@ -3,25 +3,7 @@
|
|||
<p>Steps requires a collection of menuitems as its <i>model</i>.</p>
|
||||
</DocSectionText>
|
||||
<div class="card">
|
||||
<Steps
|
||||
:model="items"
|
||||
aria-label="Form Steps"
|
||||
:readonly="false"
|
||||
:pt="{
|
||||
menuitem: ({ context }) => ({
|
||||
class: isActive(context.item) && 'p-highlight p-steps-current'
|
||||
})
|
||||
}"
|
||||
>
|
||||
<template #item="{ label, item, index, props }">
|
||||
<router-link v-if="item.route" v-slot="routerProps" :to="item.route" custom>
|
||||
<a :href="routerProps.href" v-bind="props.action" @click="($event) => routerProps.navigate($event)" @keydown.enter="($event) => routerProps.navigate($event)">
|
||||
<span v-bind="props.step">{{ index + 1 }}</span>
|
||||
<span v-bind="props.label">{{ label }}</span>
|
||||
</a>
|
||||
</router-link>
|
||||
</template>
|
||||
</Steps>
|
||||
<Steps :model="items" />
|
||||
</div>
|
||||
<DocSectionCode :code="code" />
|
||||
</template>
|
||||
|
@ -32,68 +14,23 @@ export default {
|
|||
return {
|
||||
items: [
|
||||
{
|
||||
label: 'Personal',
|
||||
route: '/steps/'
|
||||
label: 'Personal Info'
|
||||
},
|
||||
{
|
||||
label: 'Seat',
|
||||
route: '/steps/seat'
|
||||
label: 'Reservation'
|
||||
},
|
||||
{
|
||||
label: 'Payment',
|
||||
route: '/steps/payment'
|
||||
},
|
||||
{
|
||||
label: 'Confirmation',
|
||||
route: '/steps/confirmation'
|
||||
label: 'Review'
|
||||
}
|
||||
],
|
||||
code: {
|
||||
basic: `
|
||||
<Steps :model="items" aria-label="Form Steps" :readonly="false"
|
||||
:pt="{
|
||||
menuitem: ({ context }) => ({
|
||||
class: isActive(context.item) && 'p-highlight p-steps-current'
|
||||
})
|
||||
}">
|
||||
<template #item="{ label, item, index, props }">
|
||||
<router-link v-if="item.route" v-slot="routerProps" :to="item.route" custom>
|
||||
<a :href="routerProps.href" v-bind="props.action" @click="($event) => routerProps.navigate($event)" @keydown.enter="($event) => routerProps.navigate($event)">
|
||||
<span v-bind="props.step">{{ index + 1 }}</span>
|
||||
<span v-bind="props.label">{{ label }}</span>
|
||||
</a>
|
||||
</router-link>
|
||||
<span v-else v-bind="props.action">
|
||||
<span v-bind="props.step">{{ index + 1 }}</span>
|
||||
<span v-bind="props.label">{{ label }}</span>
|
||||
</span>
|
||||
</template>
|
||||
</Steps>
|
||||
<Steps :model="items" />
|
||||
`,
|
||||
options: `
|
||||
<template>
|
||||
<div>
|
||||
<div class="card">
|
||||
<Steps :model="items" aria-label="Form Steps" :readonly="false"
|
||||
:pt="{
|
||||
menuitem: ({ context }) => ({
|
||||
class: isActive(context.item) && 'p-highlight p-steps-current'
|
||||
})
|
||||
}">
|
||||
<template #item="{ label, item, index, props }">
|
||||
<router-link v-if="item.route" v-slot="routerProps" :to="item.route" custom>
|
||||
<a :href="routerProps.href" v-bind="props.action" @click="($event) => routerProps.navigate($event)" @keydown.enter="($event) => routerProps.navigate($event)">
|
||||
<span v-bind="props.step">{{ index + 1 }}</span>
|
||||
<span v-bind="props.label">{{ label }}</span>
|
||||
</a>
|
||||
</router-link>
|
||||
<span v-else v-bind="props.action">
|
||||
<span v-bind="props.step">{{ index + 1 }}</span>
|
||||
<span v-bind="props.label">{{ label }}</span>
|
||||
</span>
|
||||
</template>
|
||||
</Steps>
|
||||
</div>
|
||||
<div class="card">
|
||||
<Steps :model="items" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
|
@ -103,97 +40,46 @@ export default {
|
|||
return {
|
||||
items: [
|
||||
{
|
||||
label: 'Personal',
|
||||
route: '/'
|
||||
label: 'Personal Info'
|
||||
},
|
||||
{
|
||||
label: 'Seat',
|
||||
route: '/seat'
|
||||
label: 'Reservation'
|
||||
},
|
||||
{
|
||||
label: 'Payment',
|
||||
route: '/payment'
|
||||
},
|
||||
{
|
||||
label: 'Confirmation',
|
||||
route: '/confirmation'
|
||||
label: 'Review'
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
isActive(item) {
|
||||
return item.route ? this.$router.resolve(item.route).path === this.$route.path : false;
|
||||
}
|
||||
}
|
||||
}
|
||||
<\/script>
|
||||
`,
|
||||
composition: `
|
||||
<template>
|
||||
<div>
|
||||
<div class="card">
|
||||
<Steps :model="items" aria-label="Form Steps" :readonly="false"
|
||||
:pt="{
|
||||
menuitem: ({ context }) => ({
|
||||
class: isActive(context.item) && 'p-highlight p-steps-current'
|
||||
})
|
||||
}">
|
||||
<template #item="{ label, item, index, props }">
|
||||
<router-link v-if="item.route" v-slot="routerProps" :to="item.route" custom>
|
||||
<a :href="routerProps.href" v-bind="props.action" @click="($event) => routerProps.navigate($event)" @keydown.enter="($event) => routerProps.navigate($event)">
|
||||
<span v-bind="props.step">{{ index + 1 }}</span>
|
||||
<span v-bind="props.label">{{ label }}</span>
|
||||
</a>
|
||||
</router-link>
|
||||
<span v-else v-bind="props.action">
|
||||
<span v-bind="props.step">{{ index + 1 }}</span>
|
||||
<span v-bind="props.label">{{ label }}</span>
|
||||
</span>
|
||||
</template>
|
||||
</Steps>
|
||||
</div>
|
||||
<div class="card">
|
||||
<Steps :model="items" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref } from "vue";
|
||||
import { useRouter, useRoute } from "vue-router";
|
||||
|
||||
const router = useRouter();
|
||||
const route = useRoute();
|
||||
|
||||
const items = ref([
|
||||
{
|
||||
label: 'Personal',
|
||||
route: "/"
|
||||
label: 'Personal Info'
|
||||
},
|
||||
{
|
||||
label: 'Seat',
|
||||
route: "/seat",
|
||||
label: 'Reservation'
|
||||
},
|
||||
{
|
||||
label: 'Payment',
|
||||
route: "/payment",
|
||||
},
|
||||
{
|
||||
label: 'Confirmation',
|
||||
route: "/confirmation",
|
||||
label: 'Review'
|
||||
}
|
||||
]);
|
||||
|
||||
const isActive = (item) => {
|
||||
return item.route ? router.resolve(item.route).path === route.path : false;
|
||||
}
|
||||
<\/script>
|
||||
`
|
||||
}
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
isActive(item) {
|
||||
return item.route ? this.$router.resolve(item.route).path === this.$route.path : false;
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue