MainHeader.vue 4.8 KB

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