-
-
Notifications
You must be signed in to change notification settings - Fork 95
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(theme-yun): add animation for tags/categories
- Loading branch information
Showing
9 changed files
with
148 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
packages/valaxy-theme-yun/components/YunCategoryChildItem.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<script setup lang="ts"> | ||
import type { Post } from 'valaxy' | ||
import { isCategoryList } from 'valaxy' | ||
import { computed } from 'vue' | ||
import { useRoute } from 'vue-router' | ||
import { useI18n } from 'vue-i18n' | ||
defineProps<{ | ||
i?: number | ||
categoryItem: any | ||
parentKey?: string | ||
}>() | ||
/** | ||
* i18n | ||
*/ | ||
const { locale } = useI18n() | ||
function getTitle(post: Post | any) { | ||
const lang = locale.value === 'zh-CN' ? 'zh' : locale.value | ||
return post[`title_${lang}`] ? post[`title_${lang}`] : post.title | ||
} | ||
const route = useRoute() | ||
const categoryList = computed(() => { | ||
const c = (route.query.category as string) || '' | ||
return Array.isArray(c) ? [c] : c.split('/') | ||
}) | ||
</script> | ||
|
||
<template> | ||
<template v-if="isCategoryList(categoryItem)"> | ||
<YunCategory | ||
:parent-key="parentKey ? `${parentKey}/${categoryItem.name}` : categoryItem.name" | ||
:category="categoryItem" | ||
:collapsable="!categoryList.includes(categoryItem.name)" | ||
/> | ||
</template> | ||
|
||
<template v-else> | ||
<RouterLink | ||
v-if="categoryItem.title" | ||
:to="categoryItem.path || ''" | ||
class="inline-flex items-center gap-2 px-3 py-2 w-full rounded" | ||
hover="bg-black/5" | ||
> | ||
<div i-ri-file-text-line /> | ||
<span font="serif black">{{ getTitle(categoryItem) }}</span> | ||
</RouterLink> | ||
</template> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { useMotion } from '@vueuse/motion' | ||
import type { MaybeRef } from 'vue' | ||
import { cubicBezier } from '../client/constants' | ||
|
||
/** | ||
* 统一的弹跳出现动画 | ||
*/ | ||
export function useYunSpringAnimation(target: MaybeRef<HTMLElement | undefined>, options: { | ||
/** | ||
* index order | ||
*/ | ||
i: number | ||
y?: number | ||
duration?: number | ||
}) { | ||
useMotion(target, { | ||
initial: { | ||
opacity: 0, | ||
y: options.y || 40, | ||
}, | ||
enter: { | ||
opacity: 1, | ||
y: 0, | ||
transition: { | ||
delay: options.i * 50, | ||
type: 'spring', | ||
ease: cubicBezier.easeIn, | ||
damping: 8, | ||
duration: options.duration || 400, | ||
}, | ||
}, | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters