123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. <script setup>
  2. import { Link } from '@inertiajs/inertia-vue3'
  3. defineProps({
  4. items: Array,
  5. root: {
  6. type: Boolean,
  7. default: false,
  8. },
  9. })
  10. </script>
  11. <template>
  12. <ul v-if="items">
  13. <template v-for="(item, i) of items">
  14. <li
  15. v-if="item"
  16. :key="i"
  17. :class="[{ 'layout-menuitem-category': root }]"
  18. role="none"
  19. >
  20. <template v-if="root">
  21. <div class="layout-menuitem-root-text" :aria-label="item.label">
  22. {{ item.label }}
  23. </div>
  24. <AppSubSidebar :items="item.items"></AppSubSidebar>
  25. </template>
  26. <template v-else>
  27. <Link
  28. v-if="item.to"
  29. role="menuitem"
  30. :href="item.to"
  31. :class="[
  32. {
  33. 'router-link-active':
  34. $page.component.startsWith(item.component) ||
  35. $page.url.startsWith(item.to),
  36. 'router-link-exact-active':
  37. $page.component.startsWith(item.component) ||
  38. $page.url.startsWith(item.to),
  39. },
  40. ]"
  41. :aria-label="item.label"
  42. >
  43. <i :class="item.icon"></i>
  44. <span>{{ item.label }}</span>
  45. </Link>
  46. <a v-if="!item.to" href="#" role="menuitem" :aria-label="item.label">
  47. <i :class="item.icon"></i>
  48. <span>{{ item.label }}</span>
  49. </a>
  50. <AppSubSidebar :items="item.items"></AppSubSidebar>
  51. </template>
  52. </li>
  53. </template>
  54. </ul>
  55. </template>
  56. <style lang="scss" scoped>
  57. $transition: 0.2s;
  58. li {
  59. &.layout-menuitem-category {
  60. margin-top: 0.75rem;
  61. &:first-child {
  62. margin-top: 0;
  63. }
  64. }
  65. .layout-menuitem-root-text {
  66. text-transform: uppercase;
  67. color: var(--surface-900);
  68. font-weight: 600;
  69. margin-bottom: 0.5rem;
  70. font-size: 0.875rem;
  71. }
  72. a {
  73. cursor: pointer;
  74. text-decoration: none;
  75. display: flex;
  76. align-items: center;
  77. color: var(--text-color);
  78. transition: color $transition;
  79. border-radius: 12px;
  80. padding: 0.75rem 1rem;
  81. transition: background-color 0.15s;
  82. span {
  83. margin-left: 0.5rem;
  84. }
  85. .menuitem-toggle-icon {
  86. margin-left: auto;
  87. }
  88. &:focus {
  89. outline: 0 none;
  90. outline-offset: 0;
  91. transition: box-shadow $transition;
  92. box-shadow: inset var(--focus-ring);
  93. }
  94. &:hover {
  95. background-color: var(--surface-hover);
  96. }
  97. &.router-link-exact-active {
  98. font-weight: 700;
  99. color: var(--primary-color);
  100. }
  101. }
  102. ul {
  103. list-style-type: none;
  104. margin: 0;
  105. padding: 0;
  106. ul {
  107. padding-left: 1rem;
  108. }
  109. }
  110. }
  111. </style>