MainHeader.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. <template>
  2. <nav class="nav is-info">
  3. <div class="nav-left">
  4. <router-link class="nav-item is-brand" to="/">
  5. <img
  6. :src="`${this.siteSettings.logo_white}`"
  7. :alt="`${this.siteSettings.siteName}` || `Musare`"
  8. />
  9. </router-link>
  10. </div>
  11. <span
  12. class="nav-toggle"
  13. :class="{ 'is-active': isMobile }"
  14. @click="isMobile = !isMobile"
  15. >
  16. <span />
  17. <span />
  18. <span />
  19. </span>
  20. <div class="nav-right nav-menu" :class="{ 'is-active': isMobile }">
  21. <router-link
  22. v-if="role === 'admin'"
  23. class="nav-item is-tab admin"
  24. to="/admin"
  25. >
  26. <strong>Admin</strong>
  27. </router-link>
  28. <span v-if="loggedIn" class="grouped">
  29. <router-link
  30. class="nav-item is-tab"
  31. :to="{
  32. name: 'profile',
  33. params: { username }
  34. }"
  35. >
  36. Profile
  37. </router-link>
  38. <router-link class="nav-item is-tab" to="/settings"
  39. >Settings</router-link
  40. >
  41. <a class="nav-item is-tab" href="#" @click="logout()">Logout</a>
  42. </span>
  43. <span v-else class="grouped">
  44. <a
  45. class="nav-item"
  46. href="#"
  47. @click="
  48. openModal({
  49. sector: 'header',
  50. modal: 'login'
  51. })
  52. "
  53. >Login</a
  54. >
  55. <a
  56. class="nav-item"
  57. href="#"
  58. @click="
  59. openModal({
  60. sector: 'header',
  61. modal: 'register'
  62. })
  63. "
  64. >Register</a
  65. >
  66. </span>
  67. </div>
  68. </nav>
  69. </template>
  70. <script>
  71. import { mapState, mapActions } from "vuex";
  72. export default {
  73. data() {
  74. return {
  75. isMobile: false,
  76. frontendDomain: "",
  77. siteSettings: {
  78. logo: "",
  79. siteName: ""
  80. }
  81. };
  82. },
  83. mounted() {
  84. lofig.get("frontendDomain").then(frontendDomain => {
  85. this.frontendDomain = frontendDomain;
  86. });
  87. lofig.get("siteSettings").then(siteSettings => {
  88. this.siteSettings = siteSettings;
  89. });
  90. },
  91. computed: mapState({
  92. modals: state => state.modals.modals.header,
  93. role: state => state.user.auth.role,
  94. loggedIn: state => state.user.auth.loggedIn,
  95. username: state => state.user.auth.username
  96. }),
  97. methods: {
  98. ...mapActions("modals", ["openModal"]),
  99. ...mapActions("user/auth", ["logout"])
  100. }
  101. };
  102. </script>
  103. <style lang="scss" scoped>
  104. @import "styles/global.scss";
  105. .nav {
  106. background-color: $primary-color;
  107. height: 64px;
  108. border-radius: 0% 0% 33% 33% / 0% 0% 7% 7%;
  109. .nav-menu.is-active {
  110. .nav-item {
  111. color: $dark-grey-2;
  112. &:hover {
  113. color: $dark-grey-2;
  114. }
  115. }
  116. }
  117. a.nav-item.is-tab:hover {
  118. border-bottom: none;
  119. border-top: solid 1px $white;
  120. padding-top: 9px;
  121. }
  122. .nav-toggle {
  123. height: 64px;
  124. &.is-active span {
  125. background-color: $dark-grey-2;
  126. }
  127. }
  128. .is-brand {
  129. font-size: 2.1rem !important;
  130. line-height: 38px !important;
  131. padding: 0 20px;
  132. font-family: Pacifico, cursive;
  133. img {
  134. max-height: 38px;
  135. color: $musareBlue;
  136. }
  137. }
  138. .nav-item {
  139. font-size: 17px;
  140. color: $white;
  141. &:hover {
  142. color: $white;
  143. }
  144. }
  145. .admin strong {
  146. color: #9d42b1;
  147. }
  148. }
  149. .grouped {
  150. margin: 0;
  151. display: flex;
  152. text-decoration: none;
  153. }
  154. </style>