mirror of
https://github.com/DavidHDev/vue-bits.git
synced 2026-03-07 14:39:30 -07:00
Add prettier config, format codebase
This commit is contained in:
@@ -1,29 +1,33 @@
|
||||
<template>
|
||||
<Button :style="{
|
||||
fontWeight: 500,
|
||||
borderRadius: '0.75rem',
|
||||
border: '1px solid #142216',
|
||||
padding: '1rem',
|
||||
position: 'fixed',
|
||||
right: '2.3em',
|
||||
zIndex: 98,
|
||||
boxShadow: '10px 0 25px rgba(0, 0, 0, 0.2)',
|
||||
transition: '0.3s ease',
|
||||
opacity: visible ? 1 : 0,
|
||||
bottom: visible ? '2.5em' : '1em',
|
||||
cursor: visible ? 'pointer' : 'default'
|
||||
}" class="back-to-top" @click="visible && scrollToTop()">
|
||||
<i class="pi pi-arrow-up" style="color: #fff; font-size: 1rem;"></i>
|
||||
<Button
|
||||
:style="{
|
||||
fontWeight: 500,
|
||||
borderRadius: '0.75rem',
|
||||
border: '1px solid #142216',
|
||||
padding: '1rem',
|
||||
position: 'fixed',
|
||||
right: '2.3em',
|
||||
zIndex: 98,
|
||||
boxShadow: '10px 0 25px rgba(0, 0, 0, 0.2)',
|
||||
transition: '0.3s ease',
|
||||
opacity: visible ? 1 : 0,
|
||||
bottom: visible ? '2.5em' : '1em',
|
||||
cursor: visible ? 'pointer' : 'default'
|
||||
}"
|
||||
class="back-to-top"
|
||||
@click="visible && scrollToTop()"
|
||||
>
|
||||
<i class="pi pi-arrow-up" style="color: #fff; font-size: 1rem"></i>
|
||||
</Button>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, onMounted, onUnmounted } from 'vue'
|
||||
import { useToast } from 'primevue/usetoast'
|
||||
import Button from 'primevue/button'
|
||||
import { ref, onMounted, onUnmounted } from 'vue';
|
||||
import { useToast } from 'primevue/usetoast';
|
||||
import Button from 'primevue/button';
|
||||
|
||||
const toast = useToast()
|
||||
const visible = ref(false)
|
||||
const toast = useToast();
|
||||
const visible = ref(false);
|
||||
|
||||
const messages = [
|
||||
'🐴 Country roads, take me home!',
|
||||
@@ -33,34 +37,33 @@ const messages = [
|
||||
'🐉 Fus Ro Dah!',
|
||||
'🍄 The princess is in another castle!',
|
||||
'🦸♂️ Avengers, assemble!',
|
||||
'🗡️ It\'s dangerous to go alone! Take this.',
|
||||
"🗡️ It's dangerous to go alone! Take this.",
|
||||
'📜 A wizard is never late.',
|
||||
'💍 Foul Tarnished, in search of the Elden Ring!',
|
||||
'🐊 See you later, alligator.',
|
||||
'🔥 Dracarys!'
|
||||
]
|
||||
];
|
||||
|
||||
const getRandomMessage = (messages: string[]) =>
|
||||
messages[Math.floor(Math.random() * messages.length)]
|
||||
const getRandomMessage = (messages: string[]) => messages[Math.floor(Math.random() * messages.length)];
|
||||
|
||||
const scrollToTop = () => {
|
||||
window.scrollTo(0, 0)
|
||||
window.scrollTo(0, 0);
|
||||
toast.add({
|
||||
severity: 'secondary',
|
||||
summary: getRandomMessage(messages),
|
||||
life: 3000
|
||||
})
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
const onScroll = () => {
|
||||
visible.value = window.scrollY > 500
|
||||
}
|
||||
visible.value = window.scrollY > 500;
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
window.addEventListener('scroll', onScroll)
|
||||
})
|
||||
window.addEventListener('scroll', onScroll);
|
||||
});
|
||||
|
||||
onUnmounted(() => {
|
||||
window.removeEventListener('scroll', onScroll)
|
||||
})
|
||||
</script>
|
||||
window.removeEventListener('scroll', onScroll);
|
||||
});
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user