MainHeader.vue 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  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="$route.name === 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. created () {
  78. this.$store.dispatch('GET_BURGER')
  79. }
  80. }
  81. </script>
  82. <style lang="scss" scoped>
  83. .main-header {
  84. width: 100%;
  85. border-bottom: $line;
  86. }
  87. .main-navbar {
  88. padding: $header-spacer-sm;
  89. font-size: $font-size-sm;
  90. justify-content: space-between;
  91. @include media-breakpoint-up($layout-bp) {
  92. height: $header-height;
  93. padding: 0 $header-spacer;
  94. }
  95. ::v-deep {
  96. .dropdown-toggle {
  97. padding: 0;
  98. border: 0;
  99. line-height: 1;
  100. padding: 0 .5rem;
  101. margin-left: -.5rem;
  102. @include media-breakpoint-up($size-bp) {
  103. padding: 0 .75rem;
  104. margin-left: -.75rem;
  105. }
  106. }
  107. .dropdown-menu {
  108. border: 0;
  109. z-index: 1500;
  110. .dropdown-item {
  111. padding: .25rem $header-spacer-sm;
  112. @include media-breakpoint-up($layout-bp) {
  113. padding: .25rem $header-spacer;
  114. }
  115. }
  116. @include media-breakpoint-down($size-bp-down) {
  117. width: 100vw;
  118. }
  119. @each $variant in 'dark', 'kit', 'creation' {
  120. .dropdown-item-#{$variant} {
  121. background-color: theme-color($variant);
  122. a:not(:hover):not(:focus) {
  123. color: if($variant == 'dark', $white, $black);
  124. }
  125. }
  126. }
  127. }
  128. }
  129. .burger-icon {
  130. width: 10px;
  131. height: 10px;
  132. display: block;
  133. path {
  134. stroke: $black;
  135. stroke-width: 2px;
  136. stroke-linecap: round;
  137. }
  138. @include media-breakpoint-up(md) {
  139. width: 16px;
  140. height: 16px;
  141. path {
  142. stroke-width: 2.5px;
  143. }
  144. }
  145. }
  146. &-brand {
  147. display: flex;
  148. .navbar-brand {
  149. font-size: inherit;
  150. font-weight: $font-weight-bold;
  151. text-decoration: none;
  152. line-height: 1;
  153. padding: 0;
  154. @include media-breakpoint-up(md) {
  155. font-size: 1.3125rem;
  156. }
  157. }
  158. }
  159. .nav-list {
  160. margin-left: auto;
  161. margin-right: 1rem;
  162. ul {
  163. display: flex;
  164. padding: 0;
  165. margin: 0;
  166. list-style: none;
  167. }
  168. @include media-breakpoint-down(xs) {
  169. width: 100%;
  170. ul {
  171. flex-direction: column;
  172. width: 100%;
  173. }
  174. li {
  175. height: 22px;
  176. &:not(:last-child) {
  177. margin-bottom: 3px;
  178. }
  179. }
  180. a {
  181. height: 22px;
  182. width: 100%;
  183. text-align: left;
  184. }
  185. }
  186. @include media-breakpoint-up(sm) {
  187. ul {
  188. height: 26px;
  189. }
  190. li:not(:last-child) {
  191. margin-right: 7px;
  192. }
  193. }
  194. a:not(.active) {
  195. opacity: .25;
  196. }
  197. }
  198. .btn {
  199. font-size: inherit;
  200. @include media-breakpoint-up(md) {
  201. font-size: 1rem;
  202. }
  203. }
  204. }
  205. // #collapse-options {
  206. // @include media-breakpoint-down(sm) {
  207. // position: absolute;
  208. // z-index: 11;
  209. // width: 100%;
  210. // border-bottom: $line;
  211. // }
  212. // }
  213. </style>