Skip to content

Commit daec0e1

Browse files
committed
Adding remember me checkbox option
1 parent b0c4c4a commit daec0e1

File tree

5 files changed

+54
-1
lines changed

5 files changed

+54
-1
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<script setup lang="ts">
2+
import type { CheckboxRootEmits, CheckboxRootProps } from 'radix-vue'
3+
import { cn } from '@/lib/utils'
4+
import { Check } from 'lucide-vue-next'
5+
import { CheckboxIndicator, CheckboxRoot, useForwardPropsEmits } from 'radix-vue'
6+
import { computed, type HTMLAttributes } from 'vue'
7+
8+
const props = defineProps<CheckboxRootProps & { class?: HTMLAttributes['class'] }>()
9+
const emits = defineEmits<CheckboxRootEmits>()
10+
11+
const delegatedProps = computed(() => {
12+
const { class: _, ...delegated } = props
13+
14+
return delegated
15+
})
16+
17+
const forwarded = useForwardPropsEmits(delegatedProps, emits)
18+
</script>
19+
20+
<template>
21+
<CheckboxRoot
22+
v-bind="forwarded"
23+
:class="
24+
cn('peer h-4 w-4 shrink-0 rounded-sm border border-primary ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground',
25+
props.class)"
26+
>
27+
<CheckboxIndicator class="flex h-full w-full items-center justify-center text-current">
28+
<slot>
29+
<Check class="h-4 w-4" />
30+
</slot>
31+
</CheckboxIndicator>
32+
</CheckboxRoot>
33+
</template>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { default as Checkbox } from './Checkbox.vue'

resources/js/layouts/AuthLayout.vue

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
<!-- AuthBase.vue -->
22
<script setup lang="ts">
3-
import AuthLayout from '@/layouts/auth/AuthSplitLayout.vue';
3+
import AuthLayout from '@/layouts/auth/AuthSimpleLayout.vue';
4+
5+
defineProps<{
6+
title?: string;
7+
description?: string;
8+
}>();
49
</script>
510

611
<template>

resources/js/layouts/auth/AuthSimpleLayout.vue

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22
<script setup lang="ts">
33
import AppLogoIcon from '@/components/AppLogoIcon.vue';
44
import { Link } from '@inertiajs/vue3';
5+
6+
defineProps<{
7+
title?: string;
8+
description?: string;
9+
}>();
510
</script>
611

712
<template>

resources/js/pages/auth/Login.vue

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import InputError from '@/components/InputError.vue';
33
import TextLink from '@/components/TextLink.vue';
44
import { Button } from '@/components/ui/button';
5+
import { Checkbox } from '@/Components/ui/checkbox'
56
import { Input } from '@/components/ui/input';
67
import { Label } from '@/components/ui/label';
78
import AuthBase from '@/layouts/AuthLayout.vue';
@@ -53,6 +54,14 @@ const submit = () => {
5354
<InputError :message="form.errors.password" />
5455
</div>
5556

57+
<!-- Uncomment this below to enable remember me checkbox -->
58+
<!-- <div class="flex items-center justify-between">
59+
<Label for="remember" class="space-x-1.5 h-full flex items-center">
60+
<Checkbox id="remember" v-model:checked="form.remember" tabindex="4" />
61+
<span>Remember me</span>
62+
</Label>
63+
</div> -->
64+
5665
<Button type="submit" class="w-full" tabindex="3" :disabled="form.processing">
5766
<LoaderCircle v-if="form.processing" class="h-4 w-4 animate-spin" />
5867
Log In

0 commit comments

Comments
 (0)