chore: dynamically change text size depending on route

This commit is contained in:
rajat-ht
2025-05-30 22:50:55 +05:30
parent 1337c60784
commit 1e68ed9cc1

View File

@@ -1,5 +1,6 @@
<script setup lang="ts"> <script setup lang="ts">
import { onMounted, type Ref, ref } from 'vue'; import { useRoute } from 'vitepress';
import { computed, onMounted, type Ref, ref } from 'vue';
interface Taglines { interface Taglines {
label: string; label: string;
@@ -23,6 +24,11 @@ const taglines: Taglines[] = [
const index: Ref<number> = ref(0); const index: Ref<number> = ref(0);
const isPaused: Ref<boolean> = ref(false); const isPaused: Ref<boolean> = ref(false);
const route = useRoute();
const isHomePage = computed(() => {
return route.path === '/';
});
onMounted(() => { onMounted(() => {
index.value = Math.floor(Math.random() * taglines.length); index.value = Math.floor(Math.random() * taglines.length);
@@ -41,7 +47,7 @@ onMounted(() => {
@mouseenter="isPaused = true" @mouseenter="isPaused = true"
@mouseleave="isPaused = false" @mouseleave="isPaused = false"
> >
<p class="w-full tracking-wide fade-text text-lg"> <p class="w-full tracking-wide fade-text text-lg" :class="isHomePage ? 'text-lg' : 'text-sm'">
<transition name="fade" mode="out-in"> <transition name="fade" mode="out-in">
<a <a
:key="index" :key="index"
@@ -51,7 +57,8 @@ onMounted(() => {
> >
<span class="font-semibold">{{ taglines[index].label }}</span> <span class="font-semibold">{{ taglines[index].label }}</span>
<button <button
class="bg-[#1E1A2E] shrink-0 text-lg rounded-lg p-1.5 px-4 font-semibold tracking-wide" class="bg-[#1E1A2E] shrink-0 rounded-lg p-1.5 px-4 font-semibold tracking-wide"
:class="isHomePage ? 'text-lg' : 'text-sm'"
> >
Try now Try now
</button> </button>