Skip to content

Commit

Permalink
Add scroll-to-top button and corresponding styles
Browse files Browse the repository at this point in the history
  • Loading branch information
PhantomYdn committed Jan 5, 2025
1 parent 5b960bd commit 32dd114
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/App.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script setup>
import { ref, computed, watch, reactive } from 'vue';
import { ref, reactive, watch } from 'vue';
import ScriptDisplay from './components/ScriptDisplay.vue';
import scriptData from './assets/fools.json';
Expand Down Expand Up @@ -60,6 +60,10 @@ watch(selectedScenes, (newVal) => {
watch(showLinesPrior, (newVal) => {
localStorage.setItem('showLinesPrior', JSON.stringify(newVal));
});
const scrollToTop = () => {
window.scrollTo({ top: 0, behavior: 'smooth' });
};
</script>

<template>
Expand Down Expand Up @@ -87,6 +91,11 @@ watch(showLinesPrior, (newVal) => {
<input type="checkbox" v-model="showLinesPrior" class="block" />
</div>
<ScriptDisplay :script="script" v-if="script" v-cloak/>

<!-- Floating button to scroll to top -->
<button @click="scrollToTop" class="scroll2top">
↑ Top
</button>
</div>
</template>

Expand Down
3 changes: 3 additions & 0 deletions src/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ button:focus-visible {
color: #646cff;
}

.scroll2top {
@apply fixed bottom-4 right-4 bg-blue-500 text-white p-3 rounded-full shadow-lg hover:bg-blue-700;
}

@media (prefers-color-scheme: light) {
:root {
Expand Down

0 comments on commit 32dd114

Please sign in to comment.