Skip to content

Commit d11db70

Browse files
committed
feat: add motion
related to #12
1 parent 66a3f38 commit d11db70

File tree

8 files changed

+59
-15
lines changed

8 files changed

+59
-15
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
"dependencies": {
1313
"@inertiajs/vue3": "^2.0.17",
1414
"@nuxt/ui-pro": "^3.3.0",
15-
"@vueuse/core": "^13.6.0"
15+
"@vueuse/core": "^13.6.0",
16+
"motion-v": "^1.7.0"
1617
},
1718
"devDependencies": {
1819
"@antfu/eslint-config": "^5.2.1",

pnpm-lock.yaml

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

resources/js/components/Profile/DeleteCurrentUserSection.vue

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ const deleteCurrentUserSection = tv({
88
})
99
1010
export interface DeleteCurrentUserSectionProps {
11+
delay?: number
1112
class?: any
1213
ui?: Partial<typeof deleteCurrentUserSection.slots>
1314
}
@@ -36,6 +37,7 @@ const ui = computed(() => deleteCurrentUserSection())
3637
<ProfileSection
3738
title="Delete Account"
3839
description="Permanently delete your account."
40+
:delay="props.delay"
3941
:class="ui.base({ class: [props.ui?.base, props.class] })"
4042
>
4143
<template #actions>

resources/js/components/Profile/PasswordSection.vue

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ const passwordSection = tv({
1010
})
1111
1212
export interface PasswordSectionProps {
13+
delay?: number
1314
class?: any
1415
ui?: Partial<typeof passwordSection.slots>
1516
}
@@ -56,6 +57,7 @@ const ui = computed(() => passwordSection())
5657
<ProfileSection
5758
title="Update Password"
5859
description="Ensure your account is using a long, random password to stay secure."
60+
:delay="props.delay"
5961
:class="ui.base({ class: [props.ui?.base, props.class] })"
6062
:ui="{ actions: 'flex-row-reverse lg:flex-row' }"
6163
>
Lines changed: 41 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
<script lang="ts">
2+
import { Motion } from 'motion-v'
3+
24
const profileSection = tv({
35
slots: {
46
base: 'flex flex-col gap-6',
@@ -7,6 +9,7 @@ const profileSection = tv({
79
})
810
911
export interface ProfileSectionProps {
12+
delay?: number
1013
title: string
1114
description?: string
1215
class?: any
@@ -20,7 +23,9 @@ export interface ProfileSectionSlots {
2023
</script>
2124

2225
<script lang="ts" setup>
23-
const props = defineProps<ProfileSectionProps>()
26+
const props = withDefaults(defineProps<ProfileSectionProps>(), {
27+
delay: 0,
28+
})
2429
defineEmits<ProfileSectionEmits>()
2530
const slots = defineSlots<ProfileSectionSlots>()
2631
@@ -30,17 +35,44 @@ const ui = computed(() => profileSection())
3035
<template>
3136
<div :class="ui.base({ class: [props.ui?.base, props.class] })">
3237
<UPageCard
33-
:title="props.title"
34-
:description="props.description"
3538
variant="naked"
3639
orientation="horizontal"
3740
>
38-
<div :class="ui.actions({ class: props.ui?.actions })">
39-
<slot name="actions" />
40-
</div>
41-
</UPageCard>
42-
<UPageCard v-if="!!slots.default" variant="subtle">
43-
<slot />
41+
<template #title>
42+
<Motion
43+
:initial="{ opacity: 0, transform: 'translateY(10px)' }"
44+
:animate="{ opacity: 1, transform: 'translateY(0)', transition: { duration: 0.3, delay: props.delay } }"
45+
>
46+
{{ props.title }}
47+
</Motion>
48+
</template>
49+
50+
<template #description>
51+
<Motion
52+
:initial="{ opacity: 0, transform: 'translateY(10px)' }"
53+
:animate="{ opacity: 1, transform: 'translateY(0)', transition: { duration: 0.2, delay: 0.1 + props.delay } }"
54+
>
55+
{{ props.description }}
56+
</Motion>
57+
</template>
58+
59+
<Motion
60+
:initial="{ opacity: 0, scale: 0.96 }"
61+
:animate="{ opacity: 1, scale: 1, transition: { duration: 0.2, delay: 0.1 + props.delay } }"
62+
>
63+
<div :class="ui.actions({ class: props.ui?.actions })">
64+
<slot name="actions" />
65+
</div>
66+
</Motion>
4467
</UPageCard>
68+
69+
<Motion
70+
:initial="{ opacity: 0, transform: 'translateY(10px)' }"
71+
:animate="{ opacity: 1, transform: 'translateY(0)', transition: { duration: 0.2, delay: 0.25 + props.delay } }"
72+
>
73+
<UPageCard v-if="!!slots.default" variant="subtle">
74+
<slot />
75+
</UPageCard>
76+
</Motion>
4577
</div>
4678
</template>

resources/js/components/Profile/TwoFactorAuthenticationSection.vue

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ const twoFactorAuthenticationSection = tv({
1515
})
1616
1717
export interface TwoFactorAuthenticationSectionProps {
18+
delay?: number
1819
class?: any
1920
ui?: Partial<typeof twoFactorAuthenticationSection.slots>
2021
}
@@ -131,6 +132,7 @@ const ui = computed(() => twoFactorAuthenticationSection())
131132
<ProfileSection
132133
title="Two Factor Authentication"
133134
description="Add additional security to your account using two factor authentication."
135+
:delay="props.delay"
134136
:class="ui.base({ class: [props.ui?.base, props.class] })"
135137
:ui="{ actions: 'flex-row-reverse lg:flex-row' }"
136138
>

resources/js/components/Profile/UserProfileInformationSection.vue

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ const userProfileInformationSection = tv({
1414
})
1515
1616
export interface UserProfileInformationSectionProps {
17+
delay?: number
1718
class?: any
1819
ui?: Partial<typeof userProfileInformationSection.slots>
1920
}
@@ -72,6 +73,7 @@ const ui = computed(() => userProfileInformationSection())
7273
<ProfileSection
7374
title="Profile Information"
7475
description="These informations will be displayed publicly."
76+
:delay="props.delay"
7577
:class="ui.base({ class: [props.ui?.base, props.class] })"
7678
:ui="{ actions: 'flex-row-reverse lg:flex-row' }"
7779
>

resources/js/pages/user/profile/index.vue

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@
1515

1616
<template #body>
1717
<div class="flex flex-col gap-4 sm:gap-6 lg:gap-12 w-full lg:max-w-2xl mx-auto">
18-
<UserProfileInformationSection />
18+
<UserProfileInformationSection :delay="0" />
1919

20-
<PasswordSection />
20+
<PasswordSection :delay="0.3" />
2121

22-
<TwoFactorAuthenticationSection />
22+
<TwoFactorAuthenticationSection :delay="0.6" />
2323

24-
<SessionsSection />
24+
<SessionsSection :delay="0.9" />
2525

26-
<DeleteCurrentUserSection />
26+
<DeleteCurrentUserSection :delay="1.2" />
2727
</div>
2828
</template>
2929
</UDashboardPanel>

0 commit comments

Comments
 (0)