AppSubSidebar.vue 2.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  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. $transition: 0.2s;
  47. li {
  48. &.layout-menuitem-category {
  49. margin-top: 0.75rem;
  50. &:first-child {
  51. margin-top: 0;
  52. }
  53. }
  54. .layout-menuitem-root-text {
  55. text-transform: uppercase;
  56. color: var(--surface-900);
  57. font-weight: 600;
  58. margin-bottom: 0.5rem;
  59. font-size: 0.875rem;
  60. }
  61. a {
  62. cursor: pointer;
  63. text-decoration: none;
  64. display: flex;
  65. align-items: center;
  66. color: var(--text-color);
  67. transition: color $transition;
  68. border-radius: 12px;
  69. padding: 0.75rem 1rem;
  70. transition: background-color 0.15s;
  71. span {
  72. margin-left: 0.5rem;
  73. }
  74. .menuitem-toggle-icon {
  75. margin-left: auto;
  76. }
  77. &:focus {
  78. outline: 0 none;
  79. outline-offset: 0;
  80. transition: box-shadow $transition;
  81. box-shadow: inset var(--focus-ring);
  82. }
  83. &:hover {
  84. background-color: var(--surface-hover);
  85. }
  86. &.router-link-exact-active {
  87. font-weight: 700;
  88. color: var(--primary-color);
  89. }
  90. }
  91. ul {
  92. list-style-type: none;
  93. margin: 0;
  94. padding: 0;
  95. ul {
  96. padding-left: 1rem;
  97. }
  98. }
  99. }
  100. </style>