primevue-mirror/apps/showcase/doc/inputotp/SampleDoc.vue

229 lines
6.8 KiB
Vue
Raw Permalink Normal View History

2024-02-22 07:17:13 +00:00
<template>
<DocSectionText v-bind="$attrs">
<p>A sample UI implementation with templating and additional elements.</p>
</DocSectionText>
2024-05-20 12:14:38 +00:00
<div class="card flex justify-center">
<div class="flex flex-col items-center">
2024-02-22 07:17:13 +00:00
<div class="font-bold text-xl mb-2">Authenticate Your Account</div>
2024-05-20 12:14:38 +00:00
<p class="text-surface-500 dark:text-surface-400 block mb-8">Please enter the code sent to your phone.</p>
2024-02-22 07:17:13 +00:00
<InputOtp v-model="value" :length="6" style="gap: 0">
2024-02-22 07:42:48 +00:00
<template #default="{ attrs, events, index }">
2024-02-22 07:17:13 +00:00
<input type="text" v-bind="attrs" v-on="events" class="custom-otp-input" />
2024-05-20 12:14:38 +00:00
<div v-if="index === 3" class="px-4">
2024-02-22 07:42:48 +00:00
<i class="pi pi-minus" />
</div>
2024-02-22 07:17:13 +00:00
</template>
</InputOtp>
2024-05-20 12:14:38 +00:00
<div class="flex justify-between mt-8 self-stretch">
2024-02-22 07:17:13 +00:00
<Button label="Resend Code" link class="p-0"></Button>
<Button label="Submit Code"></Button>
</div>
</div>
</div>
<DocSectionCode :code="code" />
</template>
<script>
export default {
data() {
return {
value: null,
code: {
basic: `
2024-05-20 12:14:38 +00:00
<div class="flex flex-col items-center">
2024-02-22 07:17:13 +00:00
<div class="font-bold text-xl mb-2">Authenticate Your Account</div>
2024-05-20 12:14:38 +00:00
<p class="text-surface-500 dark:text-surface-400 block mb-8">Please enter the code sent to your phone.</p>
2024-02-22 07:17:13 +00:00
<InputOtp v-model="value" :length="6" style="gap: 0">
2024-02-22 07:42:48 +00:00
<template #default="{ attrs, events, index }">
2024-02-22 07:17:13 +00:00
<input type="text" v-bind="attrs" v-on="events" class="custom-otp-input" />
2024-05-20 12:14:38 +00:00
<div v-if="index === 3" class="px-4">
2024-02-22 07:42:48 +00:00
<i class="pi pi-minus" />
</div>
2024-02-22 07:17:13 +00:00
</template>
</InputOtp>
2024-05-20 12:14:38 +00:00
<div class="flex justify-between mt-8 self-stretch">
2024-02-22 07:17:13 +00:00
<Button label="Resend Code" link class="p-0"></Button>
<Button label="Submit Code"></Button>
</div>
</div>
`,
options: `
<template>
2024-05-20 12:14:38 +00:00
<div class="card flex justify-center">
<div class="flex flex-col items-center">
2024-02-22 07:42:48 +00:00
<div class="font-bold text-xl mb-2">Authenticate Your Account</div>
2024-05-20 12:14:38 +00:00
<p class="text-surface-500 dark:text-surface-400 block mb-8">Please enter the code sent to your phone.</p>
2024-02-22 07:42:48 +00:00
<InputOtp v-model="value" :length="6" style="gap: 0">
<template #default="{ attrs, events, index }">
<input type="text" v-bind="attrs" v-on="events" class="custom-otp-input" />
2024-05-20 12:14:38 +00:00
<div v-if="index === 3" class="px-4">
2024-02-22 07:42:48 +00:00
<i class="pi pi-minus" />
</div>
</template>
</InputOtp>
2024-05-20 12:14:38 +00:00
<div class="flex justify-between mt-8 self-stretch">
2024-02-22 07:42:48 +00:00
<Button label="Resend Code" link class="p-0"></Button>
<Button label="Submit Code"></Button>
</div>
2024-02-22 07:17:13 +00:00
</div>
</div>
</template>
<script>
export default {
data() {
return {
value: null
}
}
};
<\/script>
<style scoped>
.custom-otp-input {
width: 48px;
height: 48px;
font-size: 24px;
appearance: none;
text-align: center;
transition: all 0.2s;
border-radius: 0;
2024-03-27 08:30:38 +00:00
border: 1px solid var(--p-inputtext-border-color);
2024-02-22 07:17:13 +00:00
background: transparent;
outline-offset: -2px;
outline-color: transparent;
border-right: 0 none;
transition: outline-color 0.3s;
2024-03-27 08:30:38 +00:00
color: var(--p-inputtext-color);
2024-02-22 07:17:13 +00:00
}
.custom-otp-input:focus {
2024-03-27 08:30:38 +00:00
outline: 2px solid var(--p-focus-ring-color);
2024-02-22 07:17:13 +00:00
}
2024-02-22 07:42:48 +00:00
.custom-otp-input:first-child,
.custom-otp-input:nth-child(5) {
2024-02-22 07:17:13 +00:00
border-top-left-radius: 12px;
border-bottom-left-radius: 12px;
}
2024-02-22 07:42:48 +00:00
.custom-otp-input:nth-child(3),
2024-02-22 07:17:13 +00:00
.custom-otp-input:last-child {
border-top-right-radius: 12px;
border-bottom-right-radius: 12px;
border-right-width: 1px;
border-right-style: solid;
2024-03-27 08:30:38 +00:00
border-color: var(--p-inputtext-border-color);
2024-02-22 07:17:13 +00:00
}
<\/style>
`,
composition: `
<template>
2024-05-20 12:14:38 +00:00
<div class="card flex justify-center">
<div class="flex flex-col items-center">
2024-02-22 07:42:48 +00:00
<div class="font-bold text-xl mb-2">Authenticate Your Account</div>
2024-05-20 12:14:38 +00:00
<p class="text-surface-500 dark:text-surface-400 block mb-8">Please enter the code sent to your phone.</p>
2024-02-22 07:42:48 +00:00
<InputOtp v-model="value" :length="6" style="gap: 0">
<template #default="{ attrs, events, index }">
<input type="text" v-bind="attrs" v-on="events" class="custom-otp-input" />
2024-05-20 12:14:38 +00:00
<div v-if="index === 3" class="px-4">
2024-02-22 07:42:48 +00:00
<i class="pi pi-minus" />
</div>
</template>
</InputOtp>
2024-05-20 12:14:38 +00:00
<div class="flex justify-between mt-8 self-stretch">
2024-02-22 07:42:48 +00:00
<Button label="Resend Code" link class="p-0"></Button>
<Button label="Submit Code"></Button>
</div>
2024-02-22 07:17:13 +00:00
</div>
</div>
</template>
<script setup>
import { ref } from 'vue';
const value = ref(null);
<\/script>
<style scoped>
.custom-otp-input {
width: 48px;
height: 48px;
font-size: 24px;
appearance: none;
text-align: center;
transition: all 0.2s;
border-radius: 0;
2024-03-27 08:30:38 +00:00
border: 1px solid var(--p-inputtext-border-color);
2024-02-22 07:17:13 +00:00
background: transparent;
outline-offset: -2px;
outline-color: transparent;
border-right: 0 none;
transition: outline-color 0.3s;
2024-03-27 08:30:38 +00:00
color: var(--p-inputtext-color);
2024-02-22 07:17:13 +00:00
}
.custom-otp-input:focus {
2024-03-27 08:30:38 +00:00
outline: 2px solid var(--p-focus-ring-color);
2024-02-22 07:17:13 +00:00
}
2024-02-22 07:42:48 +00:00
.custom-otp-input:first-child,
.custom-otp-input:nth-child(5) {
2024-02-22 07:17:13 +00:00
border-top-left-radius: 12px;
border-bottom-left-radius: 12px;
}
2024-02-22 07:42:48 +00:00
.custom-otp-input:nth-child(3),
2024-02-22 07:17:13 +00:00
.custom-otp-input:last-child {
border-top-right-radius: 12px;
border-bottom-right-radius: 12px;
border-right-width: 1px;
border-right-style: solid;
2024-03-27 08:30:38 +00:00
border-color: var(--p-inputtext-border-color);
2024-02-22 07:17:13 +00:00
}
<\/style>
`
}
};
}
};
</script>
<style scoped>
.custom-otp-input {
width: 48px;
height: 48px;
font-size: 24px;
appearance: none;
text-align: center;
transition: all 0.2s;
border-radius: 0;
2024-03-27 08:30:38 +00:00
border: 1px solid var(--p-inputtext-border-color);
2024-02-22 07:17:13 +00:00
background: transparent;
outline-offset: -2px;
outline-color: transparent;
border-right: 0 none;
transition: outline-color 0.3s;
2024-03-27 08:30:38 +00:00
color: var(--p-inputtext-color);
2024-02-22 07:17:13 +00:00
}
.custom-otp-input:focus {
2024-03-27 08:30:38 +00:00
outline: 2px solid var(--p-focus-ring-color);
2024-02-22 07:17:13 +00:00
}
2024-02-22 07:42:48 +00:00
.custom-otp-input:first-child,
.custom-otp-input:nth-child(5) {
2024-02-22 07:17:13 +00:00
border-top-left-radius: 12px;
border-bottom-left-radius: 12px;
}
2024-02-22 07:42:48 +00:00
.custom-otp-input:nth-child(3),
2024-02-22 07:17:13 +00:00
.custom-otp-input:last-child {
border-top-right-radius: 12px;
border-bottom-right-radius: 12px;
border-right-width: 1px;
border-right-style: solid;
2024-03-27 08:30:38 +00:00
border-color: var(--p-inputtext-border-color);
2024-02-22 07:17:13 +00:00
}
</style>