feat: make totop optional and normal

This commit is contained in:
eggy 2022-08-10 11:40:02 -04:00
parent de40d01939
commit b739e46fe7
5 changed files with 23 additions and 11 deletions

View File

@ -1,23 +1,16 @@
<template> <template>
<Teleport to="body"> <a href="#" class="go-top" /></Teleport> <a href="#" class="go-top" />
</template> </template>
<style>
body {
display: grid;
grid-template-columns: 0 auto;
}
</style>
<style scoped> <style scoped>
.go-top { .go-top {
--offset: 20rem; --offset: 20rem;
position: sticky; position: sticky;
bottom: 1rem; bottom: 1rem;
left: 1rem; left: 1rem;
margin-right: 1rem;
place-self: end; place-self: end;
margin-top: calc(100vh + var(--offset)); margin-top: calc(100vh + var(--offset));
width: 2rem; width: 2rem;
height: 2rem; height: 2rem;
background: #ff8b24; background: #ff8b24;

View File

@ -1,6 +1,5 @@
<script setup lang="ts"> <script setup lang="ts">
import Navbar from "../components/Navbar.vue"; // this is in /components so i can import the thing
useHead({ title: "Eggworld" }); useHead({ title: "Eggworld" });
</script> </script>
@ -25,6 +24,7 @@ useHead({ title: "Eggworld" });
</p> </p>
</footer> </footer>
</div> </div>
<slot name="top-button" />
</template> </template>
<style> <style>

1
layouts/error.vue Normal file
View File

@ -0,0 +1 @@
<template>error!</template>

17
layouts/withtop.vue Normal file
View File

@ -0,0 +1,17 @@
<script setup lang="ts">
import Default from "./default.vue";
</script>
<template>
<Default>
<slot />
<template #top-button> <ButtonToTop /> </template>
</Default>
</template>
<style>
div#__nuxt {
display: grid;
grid-template-columns: auto 0;
}
</style>

View File

@ -2,6 +2,7 @@
import Services from "@/components/index/services.vue"; import Services from "@/components/index/services.vue";
import About from "@/components/index/about.vue"; import About from "@/components/index/about.vue";
definePageMeta({ layout: "withtop" });
useTitle("Home"); useTitle("Home");
</script> </script>