NavDropdownLinkItem.vue 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <template>
  2. <div class="nav-dropdown-link-item">
  3. <a class="item" v-bind="linkProps">
  4. <span class="arrow" />
  5. <span class="text">{{ item.text }}</span>
  6. <span class="icon"><OutboundLink v-if="isExternal" /></span>
  7. </a>
  8. </div>
  9. </template>
  10. <script setup lang="ts">
  11. import { defineProps, toRefs } from 'vue'
  12. import type { DefaultTheme } from '../config'
  13. import { useNavLink } from '../composables/navLink'
  14. import OutboundLink from './icons/OutboundLink.vue'
  15. const props = defineProps<{
  16. item: DefaultTheme.NavItemWithLink
  17. }>()
  18. const propsRefs = toRefs(props)
  19. const { props: linkProps, isExternal } = useNavLink(propsRefs.item)
  20. </script>
  21. <style scoped>
  22. .item {
  23. display: block;
  24. padding: 0 1.5rem 0 2.5rem;
  25. line-height: 32px;
  26. font-size: 0.9rem;
  27. font-weight: 500;
  28. color: var(--c-text);
  29. white-space: nowrap;
  30. }
  31. @media (min-width: 720px) {
  32. .item {
  33. padding: 0 24px 0 12px;
  34. line-height: 32px;
  35. font-size: 0.85rem;
  36. font-weight: 500;
  37. color: var(--c-text);
  38. white-space: nowrap;
  39. }
  40. .item.active .arrow {
  41. opacity: 1;
  42. }
  43. }
  44. .item:hover,
  45. .item.active {
  46. text-decoration: none;
  47. color: var(--c-brand);
  48. }
  49. .item.external:hover {
  50. border-bottom-color: transparent;
  51. color: var(--c-text);
  52. }
  53. @media (min-width: 720px) {
  54. .arrow {
  55. display: inline-block;
  56. margin-right: 8px;
  57. border-top: 6px solid #ccc;
  58. border-right: 4px solid transparent;
  59. border-bottom: 0;
  60. border-left: 4px solid transparent;
  61. vertical-align: middle;
  62. opacity: 0;
  63. transform: translateY(-2px) rotate(-90deg);
  64. }
  65. }
  66. </style>