Skip to content

Commit

Permalink
feat: updated
Browse files Browse the repository at this point in the history
  • Loading branch information
abdullah4tech committed Aug 15, 2024
1 parent b3149f1 commit bc3a22b
Show file tree
Hide file tree
Showing 7 changed files with 116 additions and 4 deletions.
23 changes: 23 additions & 0 deletions src/components/ui/pin-input/PinInput.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<script setup lang="ts">
import { type HTMLAttributes, computed } from 'vue'
import { PinInputRoot, type PinInputRootEmits, type PinInputRootProps, useForwardPropsEmits } from 'radix-vue'
import { cn } from '@/lib/utils'
const props = withDefaults(defineProps<PinInputRootProps & { class?: HTMLAttributes['class'] }>(), {
modelValue: () => [],
})
const emits = defineEmits<PinInputRootEmits>()
const delegatedProps = computed(() => {
const { class: _, ...delegated } = props
return delegated
})
const forwarded = useForwardPropsEmits(delegatedProps, emits)
</script>

<template>
<PinInputRoot v-bind="forwarded" :class="cn('flex gap-2 items-center', props.class)">
<slot />
</PinInputRoot>
</template>
18 changes: 18 additions & 0 deletions src/components/ui/pin-input/PinInputGroup.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<script setup lang="ts">
import { type HTMLAttributes, computed } from 'vue'
import { Primitive, type PrimitiveProps, useForwardProps } from 'radix-vue'
import { cn } from '@/lib/utils'
const props = defineProps<PrimitiveProps & { class?: HTMLAttributes['class'] }>()
const delegatedProps = computed(() => {
const { class: _, ...delegated } = props
return delegated
})
const forwardedProps = useForwardProps(delegatedProps)
</script>

<template>
<Primitive v-bind="forwardedProps" :class="cn('flex items-center', props.class)">
<slot />
</primitive>
</template>
18 changes: 18 additions & 0 deletions src/components/ui/pin-input/PinInputInput.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<script setup lang="ts">
import { type HTMLAttributes, computed } from 'vue'
import { PinInputInput, type PinInputInputProps, useForwardProps } from 'radix-vue'
import { cn } from '@/lib/utils'
const props = defineProps<PinInputInputProps & { class?: HTMLAttributes['class'] }>()
const delegatedProps = computed(() => {
const { class: _, ...delegated } = props
return delegated
})
const forwardedProps = useForwardProps(delegatedProps)
</script>

<template>
<PinInputInput v-bind="forwardedProps" :class="cn('relative text-center focus:outline-none focus:ring-2 focus:ring-ring focus:relative focus:z-10 flex h-9 w-9 items-center justify-center border-y border-r border-input text-sm transition-all first:rounded-l-md first:border-l last:rounded-r-md', props.class)" />
</template>
15 changes: 15 additions & 0 deletions src/components/ui/pin-input/PinInputSeparator.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<script setup lang="ts">
import { Primitive, type PrimitiveProps, useForwardProps } from 'radix-vue'
import { DashIcon } from '@radix-icons/vue'
const props = defineProps<PrimitiveProps>()
const forwardedProps = useForwardProps(props)
</script>

<template>
<Primitive v-bind="forwardedProps">
<slot>
<DashIcon />
</slot>
</primitive>
</template>
4 changes: 4 additions & 0 deletions src/components/ui/pin-input/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export { default as PinInput } from './PinInput.vue'
export { default as PinInputGroup } from './PinInputGroup.vue'
export { default as PinInputSeparator } from './PinInputSeparator.vue'
export { default as PinInputInput } from './PinInputInput.vue'
8 changes: 5 additions & 3 deletions src/views/Auth/Login.vue
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,11 @@ const toggleShowPassword = () => {
</div>
<p v-if="errors.password" class="text-red-500 text-sm">{{ errors.password }}</p>
</div>
<a to="/auth/reset" class="text-right">
<Button variant="link" class="ml-auto md:text-sm">Forgot your password?</Button>
</a>
<div class="text-right">
<RouterLink to="/auth/reset">
<p class="ml-auto md:text-sm underline">Forgot your password?</p>
</RouterLink>
</div>
</CardContent>
<CardFooter class="flex-col space-y-2">
<Button class="w-full" type="submit">
Expand Down
34 changes: 33 additions & 1 deletion src/views/Auth/Reset.vue
Original file line number Diff line number Diff line change
@@ -1,3 +1,35 @@
<script setup lang="ts">
import { ref } from 'vue'
import {
PinInput,
PinInputGroup,
PinInputInput,
PinInputSeparator,
} from '@/components/ui/pin-input'
const value = ref<string[]>([])
const handleComplete = (e: string[]) => alert(e.join(''))
</script>

<template>
<h1>Reset Page</h1>
<div>
<PinInput
id="pin-input"
v-model="value"
placeholder=""
@complete="handleComplete"
>
<PinInputGroup class="gap-1">
<template v-for="(id, index) in 6" :key="id">
<PinInputInput
class="rounded-md border"
:index="index"
/>
<template v-if="index !== 5">
<PinInputSeparator />
</template>
</template>
</PinInputGroup>
</PinInput>
</div>
</template>

0 comments on commit bc3a22b

Please sign in to comment.