MainHeader.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  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. .night-mode {
  106. .nav-left,
  107. .nav-right {
  108. background-color: #222;
  109. }
  110. .nav-item {
  111. color: #ddd !important;
  112. }
  113. }
  114. .nav {
  115. flex-shrink: 0;
  116. background-color: $primary-color;
  117. height: 64px;
  118. border-radius: 0% 0% 33% 33% / 0% 0% 7% 7%;
  119. .nav-menu.is-active {
  120. .nav-item {
  121. color: $dark-grey-2;
  122. &:hover {
  123. color: $dark-grey-2;
  124. }
  125. }
  126. }
  127. a.nav-item.is-tab:hover {
  128. border-bottom: none;
  129. border-top: solid 1px $white;
  130. padding-top: 9px;
  131. }
  132. .nav-toggle {
  133. height: 64px;
  134. &.is-active span {
  135. background-color: $dark-grey-2;
  136. }
  137. }
  138. .is-brand {
  139. font-size: 2.1rem !important;
  140. line-height: 38px !important;
  141. padding: 0 20px;
  142. font-family: Pacifico, cursive;
  143. img {
  144. max-height: 38px;
  145. color: $musareBlue;
  146. }
  147. }
  148. .nav-item {
  149. font-size: 17px;
  150. color: $white;
  151. &:hover {
  152. color: $white;
  153. }
  154. }
  155. .admin strong {
  156. color: #9d42b1;
  157. }
  158. }
  159. .grouped {
  160. margin: 0;
  161. display: flex;
  162. text-decoration: none;
  163. }
  164. </style>