MainHeader.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  1. <template>
  2. <header class="main-header">
  3. <b-navbar class="main-navbar">
  4. <div class="main-navbar-brand">
  5. <b-dropdown variant="link" no-caret>
  6. <template #button-content>
  7. <svg class="burger-icon" viewBox="0 0 16 16">
  8. <path v-for="n in [2, 8, 14]" :key="n" :d="`M 2,${n} h12`" />
  9. </svg>
  10. <span class="sr-only">Menu</span>
  11. </template>
  12. <b-dropdown-item
  13. v-for="link in mainRoutes" :key="link.to"
  14. :to="{ name: link.to }" class="d-tb-none" :class="'dropdown-item-' + link.variant"
  15. >
  16. {{ $t('sections.' + link.to) }}
  17. </b-dropdown-item>
  18. <b-dropdown-item
  19. v-for="page in burger" :key="page.id"
  20. :to="{ name: page.name, params: page.id ? { id: page.id } : {} }"
  21. >
  22. {{ page.id ? page.title : $t('sections.' + page.name ) }}
  23. </b-dropdown-item>
  24. </b-dropdown>
  25. <b-navbar-brand :to="{ name: 'home' }">
  26. {{ $t('title') }}
  27. </b-navbar-brand>
  28. </div>
  29. <nav class="nav-list d-none d-tb-block">
  30. <ul>
  31. <li v-for="link in mainRoutes" :key="link.to">
  32. <b-button :to="{ name: link.to }" :active="routeIsActive(link.to)" :variant="link.variant">
  33. {{ $t('sections.' + link.to) }}
  34. </b-button>
  35. </li>
  36. </ul>
  37. </nav>
  38. <b-button
  39. v-if="$route.name === 'library'"
  40. class=""
  41. :class="optionsVisible ? null : 'collapsed'"
  42. :aria-expanded="optionsVisible ? 'true' : 'false'"
  43. aria-controls="collapse-options"
  44. @click="optionsVisible = !optionsVisible"
  45. variant="outline-dark"
  46. >
  47. Options <span class="collapse-icon" :class="{ collapsed: !optionsVisible }">></span>
  48. </b-button>
  49. </b-navbar>
  50. <b-collapse id="collapse-options" v-model="optionsVisible">
  51. <router-view name="options" />
  52. </b-collapse>
  53. </header>
  54. </template>
  55. <script>
  56. import { mapGetters } from 'vuex'
  57. export default {
  58. name: 'MainHeader',
  59. data () {
  60. return {
  61. mainRoutes: [
  62. { to: 'library', variant: 'dark' },
  63. { to: 'kit', variant: 'kit' },
  64. { to: 'gallery', variant: 'creation' }
  65. ]
  66. }
  67. },
  68. computed: {
  69. ...mapGetters(['burger']),
  70. optionsVisible: {
  71. get () { return this.$store.state.optionsVisible },
  72. set (value) {
  73. this.$store.commit('UPDATE_OPTIONS_VISIBILITY', value)
  74. }
  75. }
  76. },
  77. methods: {
  78. routeIsActive (to) {
  79. return to === 'gallery'
  80. ? ['gallery', 'gallery-view'].includes(this.$route.name)
  81. : this.$route.name === to
  82. }
  83. },
  84. created () {
  85. this.$store.dispatch('GET_BURGER')
  86. }
  87. }
  88. </script>
  89. <style lang="scss" scoped>
  90. .main-header {
  91. width: 100%;
  92. border-bottom: $line;
  93. }
  94. .main-navbar {
  95. padding: $header-spacer-sm;
  96. font-size: $font-size-sm;
  97. justify-content: space-between;
  98. @include media-breakpoint-up($layout-bp) {
  99. height: $header-height;
  100. padding: 0 $header-spacer;
  101. }
  102. ::v-deep {
  103. .dropdown-toggle {
  104. padding: 0;
  105. border: 0;
  106. line-height: 1;
  107. padding: 0 .5rem;
  108. margin-left: -.5rem;
  109. @include media-breakpoint-up($size-bp) {
  110. padding: 0 .75rem;
  111. margin-left: -.75rem;
  112. }
  113. }
  114. .dropdown-menu {
  115. border: 0;
  116. z-index: 1500;
  117. .dropdown-item {
  118. padding: .25rem $header-spacer-sm;
  119. @include media-breakpoint-up($layout-bp) {
  120. padding: .25rem $header-spacer;
  121. }
  122. }
  123. @include media-breakpoint-down($size-bp-down) {
  124. width: 100vw;
  125. }
  126. @each $variant in 'dark', 'kit', 'creation' {
  127. .dropdown-item-#{$variant} {
  128. background-color: theme-color($variant);
  129. a:not(:hover):not(:focus) {
  130. color: if($variant == 'dark', $white, $black);
  131. }
  132. }
  133. }
  134. }
  135. }
  136. .burger-icon {
  137. width: 10px;
  138. height: 10px;
  139. display: block;
  140. path {
  141. stroke: $black;
  142. stroke-width: 2px;
  143. stroke-linecap: round;
  144. }
  145. @include media-breakpoint-up(md) {
  146. width: 16px;
  147. height: 16px;
  148. path {
  149. stroke-width: 2.5px;
  150. }
  151. }
  152. }
  153. &-brand {
  154. display: flex;
  155. .navbar-brand {
  156. font-size: inherit;
  157. font-weight: $font-weight-bold;
  158. text-decoration: none;
  159. line-height: 1;
  160. padding: 0;
  161. @include media-breakpoint-up(md) {
  162. font-size: 1.3125rem;
  163. }
  164. }
  165. }
  166. .nav-list {
  167. margin-left: auto;
  168. margin-right: 1rem;
  169. ul {
  170. display: flex;
  171. padding: 0;
  172. margin: 0;
  173. list-style: none;
  174. }
  175. @include media-breakpoint-down(xs) {
  176. width: 100%;
  177. ul {
  178. flex-direction: column;
  179. width: 100%;
  180. }
  181. li {
  182. height: 22px;
  183. &:not(:last-child) {
  184. margin-bottom: 3px;
  185. }
  186. }
  187. a {
  188. height: 22px;
  189. width: 100%;
  190. text-align: left;
  191. }
  192. }
  193. @include media-breakpoint-up(sm) {
  194. ul {
  195. height: 26px;
  196. }
  197. li:not(:last-child) {
  198. margin-right: 7px;
  199. }
  200. }
  201. a:not(.active) {
  202. opacity: .25;
  203. }
  204. }
  205. .btn {
  206. font-size: inherit;
  207. @include media-breakpoint-up(md) {
  208. font-size: 1rem;
  209. }
  210. }
  211. }
  212. // #collapse-options {
  213. // @include media-breakpoint-down(sm) {
  214. // position: absolute;
  215. // z-index: 11;
  216. // width: 100%;
  217. // border-bottom: $line;
  218. // }
  219. // }
  220. </style>