MainHeader.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  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 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="{ name: 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="$route.name === 'library'"
  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="{ collapsed: !optionsVisible }">></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', '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. .dropdown-item {
  103. padding: .25rem $header-spacer-sm;
  104. @include media-breakpoint-up($layout-bp) {
  105. padding: .25rem $header-spacer;
  106. }
  107. }
  108. @include media-breakpoint-down($size-bp-down) {
  109. width: 100vw;
  110. }
  111. @each $variant in 'dark', 'kit', 'creation' {
  112. .dropdown-item-#{$variant} {
  113. background-color: theme-color($variant);
  114. a:not(:hover):not(:focus) {
  115. color: if($variant == 'dark', $white, $black);
  116. }
  117. }
  118. }
  119. }
  120. }
  121. .burger-icon {
  122. width: 10px;
  123. height: 10px;
  124. display: block;
  125. path {
  126. stroke: $black;
  127. stroke-width: 2px;
  128. stroke-linecap: round;
  129. }
  130. @include media-breakpoint-up(md) {
  131. width: 16px;
  132. height: 16px;
  133. path {
  134. stroke-width: 2.5px;
  135. }
  136. }
  137. }
  138. &-brand {
  139. display: flex;
  140. .navbar-brand {
  141. font-size: inherit;
  142. font-weight: $font-weight-bold;
  143. text-decoration: none;
  144. line-height: 1;
  145. padding: 0;
  146. @include media-breakpoint-up(md) {
  147. font-size: 1.3125rem;
  148. }
  149. }
  150. }
  151. .nav-list {
  152. margin-left: auto;
  153. margin-right: 1rem;
  154. ul {
  155. display: flex;
  156. padding: 0;
  157. margin: 0;
  158. list-style: none;
  159. }
  160. @include media-breakpoint-down(xs) {
  161. width: 100%;
  162. ul {
  163. flex-direction: column;
  164. width: 100%;
  165. }
  166. li {
  167. height: 22px;
  168. &:not(:last-child) {
  169. margin-bottom: 3px;
  170. }
  171. }
  172. a {
  173. height: 22px;
  174. width: 100%;
  175. text-align: left;
  176. }
  177. }
  178. @include media-breakpoint-up(sm) {
  179. ul {
  180. height: 26px;
  181. }
  182. li:not(:last-child) {
  183. margin-right: 7px;
  184. }
  185. }
  186. a:not(.active) {
  187. opacity: .25;
  188. }
  189. }
  190. .btn {
  191. font-size: inherit;
  192. @include media-breakpoint-up(md) {
  193. font-size: 1rem;
  194. }
  195. }
  196. }
  197. // #collapse-options {
  198. // @include media-breakpoint-down(sm) {
  199. // position: absolute;
  200. // z-index: 11;
  201. // width: 100%;
  202. // border-bottom: $line;
  203. // }
  204. // }
  205. </style>