NavLink.vue 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <template>
  2. <div class="nav-link">
  3. <a class="item" v-bind="linkProps">
  4. {{ item.text }} <OutboundLink v-if="isExternal" />
  5. </a>
  6. </div>
  7. </template>
  8. <script setup lang="ts">
  9. import { defineProps, toRefs } from 'vue'
  10. import type { DefaultTheme } from '../config'
  11. import { useNavLink } from '../composables/navLink'
  12. import OutboundLink from './icons/OutboundLink.vue'
  13. const props = defineProps<{
  14. item: DefaultTheme.NavItemWithLink
  15. }>()
  16. const propsRefs = toRefs(props)
  17. const { props: linkProps, isExternal } = useNavLink(propsRefs.item)
  18. </script>
  19. <style scoped>
  20. .item {
  21. display: block;
  22. padding: 0 1.5rem;
  23. line-height: 36px;
  24. font-size: 1rem;
  25. font-weight: 600;
  26. color: var(--c-text);
  27. white-space: nowrap;
  28. }
  29. .item:hover,
  30. .item.active {
  31. text-decoration: none;
  32. color: var(--c-brand);
  33. }
  34. .item.external:hover {
  35. border-bottom-color: transparent;
  36. color: var(--c-text);
  37. }
  38. @media (min-width: 720px) {
  39. .item {
  40. border-bottom: 2px solid transparent;
  41. padding: 0;
  42. line-height: 24px;
  43. font-size: 0.9rem;
  44. font-weight: 500;
  45. }
  46. .item:hover,
  47. .item.active {
  48. border-bottom-color: var(--c-brand);
  49. color: var(--c-text);
  50. }
  51. }
  52. </style>