MobileNav.vue 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <template>
  2. <nav class="main mobile">
  3. <button v-if="canGoBack" @click="router.back()">
  4. <IconBack />
  5. </button>
  6. <span>{{ title }}</span>
  7. <span class="button-placeholder"></span>
  8. </nav>
  9. </template>
  10. <script setup lang="ts">
  11. import { computed } from 'vue';
  12. import { useRouter } from 'vue-router'
  13. import IconBack from './icons/IconBack.vue';
  14. const router = useRouter();
  15. const canGoBack = computed(() => router.currentRoute.value.name !== 'Home');
  16. defineProps({
  17. title: {
  18. type: String,
  19. default: '',
  20. },
  21. })
  22. </script>
  23. <style lang="scss">
  24. @use '@/assets/scss/colors.scss' as *;
  25. $nav-height: 44px;
  26. nav.main.mobile {
  27. position: fixed;
  28. display: flex;
  29. justify-content: space-between;
  30. align-items: center;
  31. z-index: 100;
  32. width: 100%;
  33. height: $nav-height;
  34. padding: 0;
  35. background-color: $primary-color;
  36. border-bottom: 1px solid rgba(#fff, 0.2);
  37. color: #fff;
  38. transition: all ease-in-out 0.3s;
  39. button {
  40. width: $nav-height;
  41. height: $nav-height;
  42. cursor: pointer;
  43. display: flex;
  44. justify-content: center;
  45. align-items: center;
  46. color: #fff;
  47. background-color: transparent;
  48. outline: none;
  49. border: none;
  50. &:hover {
  51. background-color: rgba(#fff, 0.2);
  52. }
  53. svg {
  54. width: 25px;
  55. height: 25px;
  56. fill: currentColor;
  57. }
  58. }
  59. .button-placeholder {
  60. width: $nav-height;
  61. }
  62. }
  63. main.mobile-nav {
  64. .nav-placeholder {
  65. height: $nav-height;
  66. background-color: $primary-color;
  67. }
  68. }
  69. </style>