aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/components/Navbar.vue
blob: fd571565c1ad648af759d170df74027ea3e71631 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
<template>
  <div v-cloak v-if="links" class="container-fluid">
    <nav class="navbar" role="navigation" aria-label="main navigation">
      <div class="container">
        <div class="navbar-brand">
          <SearchInput
            class="search-bar search-bar-mobile is-hidden-desktop"
            @input="filterServices"
            @search:open="navigateToFirstService"
            @search:cancel="filterServices"
          />
          <a
            role="button"
            aria-label="menu"
            aria-expanded="false"
            class="navbar-burger"
            :class="{ 'is-active': showMenu }"
            v-on:click="$emit('navbar:toggle')"
          >
            <span aria-hidden="true"></span>
            <span aria-hidden="true"></span>
            <span aria-hidden="true"></span>
          </a>
        </div>
        <div class="navbar-menu" :class="{ 'is-active': showMenu }">
          <div class="navbar-start">
            <a
              class="navbar-item"
              rel="noreferrer"
              v-for="link in links"
              :key="link.url"
              :href="link.url"
              :target="link.target"
            >
              <i
                v-if="link.icon"
                style="margin-right: 6px;"
                :class="link.icon"
              ></i>
              {{ link.name }}
            </a>
          </div>
          <div class="navbar-end">
            <slot></slot>

            <SearchInput
              class="navbar-item is-inline-block-mobile is-hidden-touch"
              @input="filterServices"
              @search:open="navigateToFirstService"
              @search:cancel="filterServices"
            />
          </div>
        </div>
      </div>
    </nav>
  </div>
</template>

<script>
import SearchInput from "./SearchInput.vue";

export default {
  name: "Navbar",
  components: {
    SearchInput,
  },
  props: {
    open: {
      type: Boolean,
      default: false,
    },
    links: Array,
    navigateToFirstService: { type: Function },
    filterServices: { type: Function },
  },
  computed: {
    showMenu: function () {
      return this.open && this.isSmallScreen();
    },
  },
  methods: {
    isSmallScreen: function () {
      return window.matchMedia("screen and (max-width: 1023px)").matches;
    },
  },
};
</script>