AppSubSidebar.vue 2.5KB

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