MainHeader.vue 3.5 KB

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