TopBar.vue 4.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  1. <script setup>
  2. import { Inertia } from '@inertiajs/inertia'
  3. import { Link } from '@inertiajs/inertia-vue3'
  4. import { useConfirm } from 'primevue/useconfirm'
  5. const logoutConfirm = useConfirm()
  6. const logout = () => {
  7. logoutConfirm.require({
  8. message: 'Ingin keluar dari aplikasi',
  9. header: 'Keluar',
  10. acceptLabel: 'Iya',
  11. rejectLabel: 'Tidak',
  12. accept: () => {
  13. Inertia.post(route('logout'))
  14. },
  15. reject: () => {
  16. logoutConfirm.close()
  17. },
  18. })
  19. }
  20. </script>
  21. <template>
  22. <div class="layout-topbar">
  23. <Link href="/" class="layout-topbar-logo">
  24. <img alt="Brand Logo" src="/images/logo.svg" class="md:mr-3" />
  25. <span>{{ $page.props.company?.name ?? 'Your Company' }}</span>
  26. </Link>
  27. <button
  28. class="p-link layout-menu-button layout-topbar-button"
  29. @click="$emit('menu-toggle', $event)"
  30. >
  31. <i class="pi pi-bars"></i>
  32. </button>
  33. <button
  34. class="p-link layout-topbar-menu-button layout-topbar-button"
  35. v-styleclass="{
  36. selector: '@next',
  37. enterClass: 'hidden',
  38. enterActiveClass: 'scalein',
  39. leaveToClass: 'hidden',
  40. leaveActiveClass: 'fadeout',
  41. hideOnOutsideClick: true,
  42. }"
  43. >
  44. <i class="pi pi-ellipsis-v"></i>
  45. </button>
  46. <ul class="layout-topbar-menu hidden lg:flex origin-top">
  47. <li class="align-self-center">
  48. <span class="hidden lg:inline">{{ $page.props.auth.user.name }}</span>
  49. </li>
  50. <li>
  51. <Link
  52. :href="route('users.show', $page.props.auth.user.id)"
  53. class="p-link layout-topbar-button"
  54. v-tooltip.bottom="{
  55. value: 'Ubah Profil',
  56. class: 'layout-topbar-menu-tooltip',
  57. }"
  58. >
  59. <i class="pi pi-user"></i>
  60. <span>Ubah Profil</span>
  61. </Link>
  62. </li>
  63. <li>
  64. <button
  65. class="p-link layout-topbar-button"
  66. v-tooltip.bottom="{
  67. value: 'Keluar',
  68. class: 'layout-topbar-menu-tooltip',
  69. }"
  70. @click="logout"
  71. >
  72. <i class="pi pi-sign-out"></i>
  73. <span>Keluar</span>
  74. </button>
  75. </li>
  76. </ul>
  77. </div>
  78. </template>
  79. <style lang="scss" scoped>
  80. $transition: 0.2s;
  81. @mixin focused() {
  82. outline: 0 none;
  83. outline-offset: 0;
  84. transition: box-shadow $transition;
  85. box-shadow: var(--focus-ring);
  86. }
  87. .layout-topbar {
  88. position: fixed;
  89. height: 5rem;
  90. z-index: 994;
  91. left: 0;
  92. top: 0;
  93. width: 100%;
  94. padding: 0 2rem;
  95. background-color: var(--surface-card);
  96. transition: left $transition;
  97. display: flex;
  98. align-items: center;
  99. box-shadow: 0px 3px 5px rgba(0, 0, 0, 0.02), 0px 0px 2px rgba(0, 0, 0, 0.05),
  100. 0px 1px 4px rgba(0, 0, 0, 0.08);
  101. .layout-topbar-logo {
  102. display: flex;
  103. align-items: center;
  104. color: var(--surface-900);
  105. font-size: 1.5rem;
  106. font-weight: 500;
  107. width: 300px;
  108. border-radius: 12px;
  109. img {
  110. height: 2.5rem;
  111. margin-right: 0.5rem;
  112. }
  113. &:focus {
  114. @include focused();
  115. }
  116. }
  117. .layout-topbar-button {
  118. display: inline-flex;
  119. justify-content: center;
  120. align-items: center;
  121. position: relative;
  122. color: var(--text-color-secondary);
  123. border-radius: 50%;
  124. width: 3rem;
  125. height: 3rem;
  126. cursor: pointer;
  127. transition: background-color $transition;
  128. &:hover {
  129. color: var(--text-color);
  130. background-color: var(--surface-hover);
  131. }
  132. &:focus {
  133. @include focused();
  134. }
  135. i {
  136. font-size: 1.5rem;
  137. }
  138. span {
  139. font-size: 1rem;
  140. display: none;
  141. }
  142. }
  143. .layout-menu-button {
  144. margin-left: 2rem;
  145. }
  146. .layout-topbar-menu-button {
  147. display: none;
  148. i {
  149. font-size: 1.25rem;
  150. }
  151. }
  152. .layout-topbar-menu {
  153. margin: 0 0 0 auto;
  154. padding: 0;
  155. list-style: none;
  156. display: flex;
  157. .layout-topbar-button {
  158. margin-left: 1rem;
  159. }
  160. }
  161. }
  162. @media (max-width: 991px) {
  163. .layout-topbar {
  164. justify-content: space-between;
  165. .layout-topbar-logo {
  166. width: auto;
  167. order: 2;
  168. }
  169. .layout-menu-button {
  170. margin-left: 0;
  171. order: 1;
  172. }
  173. .layout-topbar-menu-button {
  174. display: inline-flex;
  175. margin-left: 0;
  176. order: 3;
  177. }
  178. .layout-topbar-menu {
  179. margin-left: 0;
  180. position: absolute;
  181. flex-direction: column;
  182. background-color: var(--surface-overlay);
  183. box-shadow: 0px 3px 5px rgba(0, 0, 0, 0.02),
  184. 0px 0px 2px rgba(0, 0, 0, 0.05), 0px 1px 4px rgba(0, 0, 0, 0.08);
  185. border-radius: 4px;
  186. padding: 1rem;
  187. right: 2rem;
  188. top: 5.5rem;
  189. min-width: 15rem;
  190. .layout-topbar-button {
  191. margin-left: 0;
  192. display: flex;
  193. width: 100%;
  194. height: auto;
  195. justify-content: flex-start;
  196. border-radius: 12px;
  197. padding: 1rem;
  198. i {
  199. font-size: 1rem;
  200. margin-right: 0.5rem;
  201. }
  202. span {
  203. font-weight: medium;
  204. display: block;
  205. }
  206. }
  207. }
  208. }
  209. }
  210. </style>