Skip to content

Commit

Permalink
Add animated transitions
Browse files Browse the repository at this point in the history
  • Loading branch information
sidharthv96 committed Aug 7, 2024
1 parent 657e38f commit 42177a3
Showing 1 changed file with 39 additions and 17 deletions.
56 changes: 39 additions & 17 deletions packages/mermaid/src/docs/.vitepress/components/TopBar.vue
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<script setup lang="ts">
import { ref, onMounted } from 'vue';
interface Taglines {
label: string;
url: string;
Expand All @@ -19,27 +21,47 @@ const taglines: Taglines[] = [
},
];
const index = Math.floor(Math.random() * taglines.length);
const currentTagline = taglines[index];
let index = ref(Math.floor(Math.random() * taglines.length));
onMounted(() => {
setInterval(() => {
index.value = (index.value + 1) % taglines.length;
}, 60_000);
});
</script>

<template>
<div
class="mb-4 w-full top-bar bg-gradient-to-r from-[#bd34fe] to-[#ff3670] flex items-center text-center justify-center p-1 text-white"
>
<p class="flex-grow text-center tracking-wide text-text">
<a
href="{{ currentTagline.url }}"
target="_blank"
class="unstyled flex-grow tracking-wide plausible-event-name=bannerClick"
>
<span class="text-primary-50 font-semibold">{{ currentTagline.label }}</span>
<button
class="ml-4 rounded bg-[#111113] p-1 px-2 text-sm font-semibold tracking-wide text-white"
<div class="mb-4 w-full top-bar bg-gradient-to-r from-[#bd34fe] to-[#ff3670] flex p-1">
<p class="w-full tracking-wide fade-text">
<transition name="fade" mode="out-in">
<a
:key="index"
href="{{ taglines[index].url }}"
target="_blank"
class="unstyled flex justify-center items-center gap-4 tracking-wide plausible-event-name=bannerClick"
>
Try it now
</button>
</a>
<span class="text-primary-50 font-semibold">{{ taglines[index].label }}</span>
<button
class="rounded bg-[#111113] p-1 px-2 text-sm font-semibold tracking-wide text-white"
>
Try it now
</button>
</a>
</transition>
</p>
</div>
</template>

<style>
.fade-enter-active,
.fade-leave-active {
transition: opacity 1s;
}
.fade-enter-from,
.fade-leave-to {
opacity: 0;
}
.fade-enter-to,
.fade-leave-from {
opacity: 1;
}
</style>

0 comments on commit 42177a3

Please sign in to comment.