Add animated text gradient component and update references in content files

This commit is contained in:
2025-04-19 11:24:54 +02:00
parent 5d7b58624b
commit 3d5027c81f
4 changed files with 47 additions and 3 deletions

View File

@@ -0,0 +1,44 @@
<script setup lang="ts">
const props = withDefaults(defineProps<{
text?: string
gradient?: string
class?: string
speed?: number
}>(), {
text: 'This is a text',
gradient: 'bg-radial from-orange-400 to-pink-500',
class: 'font-bold',
speed: 2,
})
const styleVars = {
'--animated-speed': `${props.speed}s`,
}
</script>
<template>
<span
class="inline-block bg-clip-text text-transparent animate-gradient" :class="[
gradient,
props.class,
]"
:style="styleVars"
>
<slot>{{ text }}</slot>
</span>
</template>
<style scoped>
.animate-gradient {
background-size: 200% auto;
-webkit-background-clip: text;
background-clip: text;
-webkit-text-fill-color: transparent;
animation: animatedTextGradient-to-right var(--animated-speed) linear infinite;
}
@keyframes animatedTextGradient-to-right {
to {
background-position: 200% center;
}
}
</style>