MainHeader.vue 5.0 KB

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