NextAndPrevLinks.vue 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <template>
  2. <div v-if="hasLinks" class="next-and-prev-link">
  3. <div class="container">
  4. <div class="prev">
  5. <a v-if="prev" class="link" :href="$withBase(prev.link)">
  6. <ArrowLeft class="icon icon-prev" />
  7. <span class="text">{{ prev.text }}</span>
  8. </a>
  9. </div>
  10. <div class="next">
  11. <a v-if="next" class="link" :href="$withBase(next.link)">
  12. <span class="text">{{ next.text }}</span>
  13. <ArrowRight class="icon icon-next" />
  14. </a>
  15. </div>
  16. </div>
  17. </div>
  18. </template>
  19. <script setup lang="ts">
  20. import { useNextAndPrevLinks } from '../composables/nextAndPrevLinks'
  21. import ArrowLeft from './icons/ArrowLeft.vue'
  22. import ArrowRight from './icons/ArrowRight.vue'
  23. const { hasLinks, prev, next } = useNextAndPrevLinks()
  24. </script>
  25. <style scoped>
  26. .next-and-prev-link {
  27. padding-top: 1rem;
  28. }
  29. .container {
  30. display: flex;
  31. justify-content: space-between;
  32. border-top: 1px solid var(--c-divider);
  33. padding-top: 1rem;
  34. }
  35. .prev,
  36. .next {
  37. display: flex;
  38. flex-shrink: 0;
  39. width: 50%;
  40. }
  41. .prev {
  42. justify-content: flex-start;
  43. padding-right: 12px;
  44. }
  45. .next {
  46. justify-content: flex-end;
  47. padding-left: 12px;
  48. }
  49. .link {
  50. display: inline-flex;
  51. align-items: center;
  52. max-width: 100%;
  53. font-size: 1rem;
  54. font-weight: 500;
  55. }
  56. .text {
  57. display: block;
  58. white-space: nowrap;
  59. overflow: hidden;
  60. text-overflow: ellipsis;
  61. }
  62. .icon {
  63. display: block;
  64. flex-shrink: 0;
  65. width: 16px;
  66. height: 16px;
  67. fill: var(--c-text);
  68. transform: translateY(1px);
  69. }
  70. .icon-prev {
  71. margin-right: 8px;
  72. }
  73. .icon-next {
  74. margin-left: 8px;
  75. }
  76. </style>