Bläddra i källkod

finalize back to the top button

Olivier Massot 1 år sedan
förälder
incheckning
14f9d42b8e
2 ändrade filer med 23 tillägg och 13 borttagningar
  1. 2 3
      app.vue
  2. 21 10
      components/Common/ActionMenu.vue

+ 2 - 3
app.vue

@@ -1,6 +1,5 @@
 <template>
-  <div>
-    <Html :lang="i18nHead.htmlAttrs.lang" :dir="i18nHead.htmlAttrs.dir"></Html>
+  <Html :lang="i18nHead.htmlAttrs.lang" :dir="i18nHead.htmlAttrs.dir">
 
     <div id="top" />
 
@@ -9,7 +8,7 @@
     <nuxt-page />
 
     <LayoutFooter />
-  </div>
+  </Html>
 </template>
 
 <script setup lang="ts">

+ 21 - 10
components/Common/ActionMenu.vue

@@ -25,23 +25,24 @@ de l'écran (ou au bas de l'écran sur les petits écrans)
 
   <!-- Petits écrans : menu sous forme de bandeau en pied de page (sauf si le footer du site est visible) -->
   <div v-else-if="isVisible" class="sticky-menu band">
-    <v-btn
-      :to="{ path: '', hash: '#top' }"
-      class="primary"
-      :width="24"
-    >
-      <v-icon>fas fa-arrow-up</v-icon>
-    </v-btn>
-
     <v-btn
       v-for="(action, index) in actionsOrDefault"
       :key="index"
       :class="[action.color]"
       @click="() => onActionClick(action)"
     >
-      {{ action.text }}
+      <span v-if="mdAndUp">{{ action.text }}</span>
+      <v-icon v-else>{{ action.icon }}</v-icon>
     </v-btn>
   </div>
+
+  <v-btn
+    v-if="isVisible"
+    :to="{ path: '', hash: '#top' }"
+    class="back-to-the-top secondary"
+  >
+    <v-icon>fas fa-arrow-up</v-icon>
+  </v-btn>
 </template>
 
 <script setup lang="ts">
@@ -52,7 +53,7 @@ import { useLayoutStore } from '~/stores/layoutStore'
 import { ActionMenuItemType } from '~/types/enum/layout'
 import type { ActionMenuItem } from '~/types/interface'
 
-const { lgAndUp } = useDisplay()
+const { lgAndUp, mdAndUp } = useDisplay()
 const router = useRouter()
 const layoutStore = useLayoutStore()
 const { isMobileDevice } = useClientDevice()
@@ -197,6 +198,16 @@ const onActionClick = (action: ActionMenuItem) => {
   }
 }
 
+.back-to-the-top {
+  position: fixed;
+  right: 12px;
+  bottom: 58px;
+  z-index: 100;
+  height: 48px;
+  width: 48px;
+  border-radius: 32px;
+}
+
 .primary {
   background: var(--action-menu-primary-color);
   color: var(--action-menu-on-primary-color);