Skip to content

Commit 71796eb

Browse files
committed
refactor(docs): remove motion-v dependency and enhance background decoration with particle effects
1 parent 293bdce commit 71796eb

File tree

5 files changed

+132
-150
lines changed

5 files changed

+132
-150
lines changed

docs/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
"dependencies": {
2020
"@soybeanjs/ui": "workspace:^",
2121
"@unocss/reset": "^66.5.9",
22-
"motion-v": "^1.7.4",
2322
"nprogress": "^0.2.0",
2423
"pinia": "^3.0.4",
2524
"vue": "^3.5.24",

docs/src/components/app-header.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { ref } from 'vue';
33
import { useRouter } from 'vue-router';
44
import { SButton, SDrawer, SIcon } from '@soybeanjs/ui';
55
import { useI18n } from 'vue-i18n';
6+
import pkg from '../../package.json' with { type: 'json' };
67
import ToolBar from './tool-bar.vue';
78
89
const router = useRouter();
@@ -64,7 +65,7 @@ function goHome() {
6465
<div
6566
class="hidden md:block text-xs font-mono text-gray-500 dark:text-gray-400 bg-gray-100 dark:bg-gray-800 px-2 py-1 rounded-full"
6667
>
67-
v0.0.1
68+
{{ pkg.version }}
6869
</div>
6970

7071
<!-- Tools -->
Lines changed: 62 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,66 @@
11
<script setup lang="ts">
2-
import { Motion } from 'motion-v';
2+
import { computed } from 'vue';
33
44
const orbs = [
55
{
66
size: 'w-[500px] h-[500px]',
7-
color: 'bg-blue-400/20 dark:bg-blue-600/20',
8-
initial: { x: -100, y: -100 },
9-
animate: {
10-
x: [0, 100, -50, 0],
11-
y: [0, -50, 100, 0],
12-
scale: [1, 1.2, 0.9, 1]
13-
},
14-
duration: 20
7+
color: 'bg-blue-400/20 dark:bg-blue-600/20'
158
},
169
{
1710
size: 'w-[400px] h-[400px]',
18-
color: 'bg-purple-400/20 dark:bg-purple-600/20',
19-
initial: { x: 400, y: 200 },
20-
animate: {
21-
x: [0, -100, 50, 0],
22-
y: [0, 100, -50, 0],
23-
scale: [1, 0.8, 1.1, 1]
24-
},
25-
duration: 25
11+
color: 'bg-purple-400/20 dark:bg-purple-600/20'
2612
},
2713
{
2814
size: 'w-[300px] h-[300px]',
29-
color: 'bg-cyan-400/20 dark:bg-cyan-600/20',
30-
initial: { x: 100, y: 400 },
31-
animate: {
32-
x: [0, 50, -100, 0],
33-
y: [0, -100, 50, 0],
34-
scale: [1, 1.1, 0.9, 1]
35-
},
36-
duration: 18
15+
color: 'bg-cyan-400/20 dark:bg-cyan-600/20'
3716
}
3817
];
18+
19+
// Tech Particles 配置
20+
const particleColors = [
21+
'bg-primary',
22+
'bg-purple-500',
23+
'bg-cyan-500',
24+
'bg-pink-500',
25+
'bg-indigo-500',
26+
'bg-teal-500',
27+
'bg-rose-500',
28+
'bg-amber-500',
29+
'bg-emerald-500'
30+
];
31+
32+
const particleSizes = ['w-1 h-1', 'w-1.5 h-1.5', 'w-2 h-2'];
33+
34+
// 生成9个粒子,使用3x3网格均匀分布
35+
const gridCols = 3;
36+
const gridRows = 3;
37+
const totalParticles = gridCols * gridRows;
38+
39+
const particles = computed(() => {
40+
return Array.from({ length: totalParticles }, (_, index) => {
41+
const col = index % gridCols;
42+
const row = Math.floor(index / gridCols);
43+
44+
// 计算均匀分布的位置(留出边距,避免太靠边)
45+
const leftPercent = 10 + col * (80 / (gridCols - 1));
46+
const topPercent = 10 + row * (80 / (gridRows - 1));
47+
48+
// 随机选择颜色和大小
49+
const color = particleColors[index % particleColors.length];
50+
const size = particleSizes[index % particleSizes.length];
51+
52+
// 延迟时间(0-2000ms之间,每个粒子间隔约200ms)
53+
const delay = index * 200;
54+
55+
return {
56+
color,
57+
size,
58+
left: leftPercent,
59+
top: topPercent,
60+
delay
61+
};
62+
});
63+
});
3964
</script>
4065

4166
<template>
@@ -46,16 +71,9 @@ const orbs = [
4671
/>
4772

4873
<!-- Floating Orbs -->
49-
<Motion
74+
<div
5075
v-for="(orb, index) in orbs"
5176
:key="index"
52-
:initial="orb.initial"
53-
:animate="orb.animate"
54-
:transition="{
55-
duration: orb.duration,
56-
repeat: Infinity,
57-
ease: 'linear'
58-
}"
5977
class="absolute rounded-full blur-[100px]"
6078
:class="[orb.size, orb.color]"
6179
:style="{
@@ -66,9 +84,17 @@ const orbs = [
6684

6785
<!-- Tech Particles / Accents -->
6886
<div class="absolute inset-0 opacity-30 dark:opacity-50">
69-
<div class="absolute top-1/4 left-1/4 w-2 h-2 bg-primary rounded-full animate-ping" />
70-
<div class="absolute top-3/4 right-1/4 w-1.5 h-1.5 bg-purple-500 rounded-full animate-ping delay-700" />
71-
<div class="absolute bottom-1/4 left-1/2 w-1 h-1 bg-cyan-500 rounded-full animate-ping delay-1000" />
87+
<div
88+
v-for="(particle, index) in particles"
89+
:key="index"
90+
:style="{
91+
left: `${particle.left}%`,
92+
top: `${particle.top}%`,
93+
animationDelay: `${particle.delay}ms`
94+
}"
95+
class="absolute rounded-full animate-ping"
96+
:class="[particle.color, particle.size]"
97+
/>
7298
</div>
7399
</div>
74100
</template>

docs/src/pages/index.vue

Lines changed: 68 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import { useRouter } from 'vue-router';
44
import { useDark } from '@vueuse/core';
55
import { SIcon } from '@soybeanjs/ui';
66
import { useI18n } from 'vue-i18n';
7-
import { Motion } from 'motion-v';
87
import BackgroundDecoration from '@/motion/background-decoration.vue';
98
109
const router = useRouter();
@@ -37,14 +36,6 @@ const features = computed(() => [
3736
class: 'text-pink-500'
3837
}
3938
]);
40-
41-
function getDelay(index: number) {
42-
return {
43-
delay: index * 0.1 + 0.5,
44-
duration: 0.5,
45-
ease: 'easeOut' as const
46-
};
47-
}
4839
</script>
4940

5041
<template>
@@ -55,56 +46,31 @@ function getDelay(index: number) {
5546

5647
<div class="container mx-auto px-4 relative z-10">
5748
<div class="text-center max-w-5xl mx-auto">
58-
<Motion
59-
:initial="{ opacity: 0, scale: 0.5 }"
60-
:animate="{ opacity: 1, scale: 1 }"
61-
:transition="{ duration: 0.8, ease: 'easeOut' }"
62-
class="lg:!mt-4 mt-28 mb-4 inline-block relative z-20"
63-
>
64-
<Motion :animate="{ y: [0, -20, 0] }" :transition="{ duration: 2, repeat: Infinity, ease: 'easeInOut' }">
65-
<div class="group relative">
66-
<div
67-
class="absolute inset-0 bg-primary/20 rounded-full blur-3xl opacity-0 group-hover:opacity-100 transition-opacity duration-500"
68-
/>
69-
<img
70-
src="/logo.svg"
71-
alt="Logo"
72-
class="size-28 md:size-36 mx-auto drop-shadow-2xl filter relative z-10 transition-transform duration-300 group-hover:scale-105"
73-
/>
74-
</div>
75-
</Motion>
76-
</Motion>
49+
<div class="logo-float group relative z-20 mt-28 mb-4 lg:!mt-4">
50+
<div
51+
class="absolute inset-0 bg-primary/20 rounded-full blur-3xl opacity-0 group-hover:opacity-100 transition-opacity duration-500"
52+
/>
53+
<img
54+
src="/logo.svg"
55+
alt="Logo"
56+
class="size-28 md:size-36 mx-auto drop-shadow-2xl filter relative z-10 transition-transform duration-300 group-hover:scale-105"
57+
/>
58+
</div>
7759

78-
<Motion
79-
:initial="{ opacity: 0, y: 50 }"
80-
:animate="{ opacity: 1, y: 0 }"
81-
:transition="{ duration: 0.8, ease: 'easeOut' }"
82-
>
60+
<div class="hero-content">
8361
<h1
8462
class="text-4xl md:text-6xl lg:text-7xl font-extrabold tracking-tight mb-8 bg-clip-text text-transparent bg-gradient-to-r from-primary-600 to-primary dark:from-primary dark:to-primary-300"
8563
>
8664
{{ t('components.home.title') }}
8765
</h1>
88-
</Motion>
89-
90-
<Motion
91-
:initial="{ opacity: 0, y: 30 }"
92-
:animate="{ opacity: 1, y: 0 }"
93-
:transition="{ duration: 0.8, delay: 0.2, ease: 'easeOut' }"
94-
>
9566
<p
9667
class="text-lg md:text-xl text-gray-600 dark:text-gray-300 mb-12 max-w-3xl mx-auto leading-relaxed font-medium"
9768
>
9869
{{ t('components.home.description') }}
9970
</p>
100-
</Motion>
71+
</div>
10172

102-
<Motion
103-
:initial="{ opacity: 0, scale: 0.9 }"
104-
:animate="{ opacity: 1, scale: 1 }"
105-
:transition="{ duration: 0.5, delay: 0.4 }"
106-
class="flex flex-wrap gap-6 justify-center mb-24"
107-
>
73+
<div class="flex flex-wrap gap-6 justify-center mb-24">
10874
<button
10975
class="group flex-center gap-2 w-45 px-4 py-2 rounded-full text-center bg-primary text-white font-semibold text-lg hover:bg-primary-600 transition-all shadow-lg hover:shadow-primary/30 active:scale-95 flex items-center"
11076
@click="router.push('/components/button')"
@@ -121,16 +87,14 @@ function getDelay(index: number) {
12187
<SIcon :icon="isDark ? 'skill-icons:github-light' : 'skill-icons:github-dark'" />
12288
{{ t('components.home.actions.github') }}
12389
</a>
124-
</Motion>
90+
</div>
12591

12692
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-6 text-left">
127-
<Motion
93+
<div
12894
v-for="(feature, index) in features"
12995
:key="feature.title"
130-
:initial="{ opacity: 0, y: 20 }"
131-
:animate="{ opacity: 1, y: 0 }"
132-
:transition="getDelay(index)"
133-
class="group bg-white/40 dark:bg-white/5 backdrop-blur-xl p-6 rounded-2xl border border-border shadow-lg shadow-gray-200/20 dark:shadow-none hover:bg-white/60 dark:hover:bg-white/10 hover:border-white/80 dark:hover:border-white/20 hover:-translate-y-1 transition-all duration-300"
96+
:style="{ animationDelay: `${index * 0.1 + 0.5}s` }"
97+
class="feature-card group bg-white/40 dark:bg-white/5 backdrop-blur-xl p-6 rounded-2xl border border-border shadow-lg shadow-gray-200/20 dark:shadow-none hover:bg-white/60 dark:hover:bg-white/10 hover:border-white/80 dark:hover:border-white/20 hover:-translate-y-1 transition-all duration-300"
13498
>
13599
<div class="text-3xl mb-4 p-3 rounded-xl bg-gray-50 dark:bg-white/5 w-fit" :class="feature.class">
136100
<SIcon :icon="feature.icon" />
@@ -139,13 +103,63 @@ function getDelay(index: number) {
139103
{{ feature.title }}
140104
</h3>
141105
<p class="text-gray-600 dark:text-gray-400 text-sm leading-relaxed">{{ feature.description }}</p>
142-
</Motion>
106+
</div>
143107
</div>
144108
</div>
145109
</div>
146110
</div>
147111
</template>
148112

113+
<style scoped>
114+
/* Logo 上下浮动动画 */
115+
@keyframes float {
116+
0%,
117+
100% {
118+
transform: translateY(0);
119+
}
120+
50% {
121+
transform: translateY(-20px);
122+
}
123+
}
124+
125+
.logo-float {
126+
animation: float 2s ease-in-out infinite;
127+
}
128+
129+
/* 标题和描述淡入+向上移动动画 */
130+
@keyframes fadeInUp {
131+
from {
132+
opacity: 0;
133+
transform: translateY(50px);
134+
}
135+
to {
136+
opacity: 1;
137+
transform: translateY(0);
138+
}
139+
}
140+
141+
.hero-content {
142+
animation: fadeInUp 0.8s ease-out forwards;
143+
}
144+
145+
/* 特性卡片淡入+向上移动动画 */
146+
@keyframes fadeInUpCard {
147+
from {
148+
opacity: 0;
149+
transform: translateY(20px);
150+
}
151+
to {
152+
opacity: 1;
153+
transform: translateY(0);
154+
}
155+
}
156+
157+
.feature-card {
158+
animation: fadeInUpCard 0.5s ease-out forwards;
159+
opacity: 0;
160+
}
161+
</style>
162+
149163
<route lang="yaml">
150164
meta:
151165
layout: home

0 commit comments

Comments
 (0)