<template>
  <header class="header-bar">
    <router-link :to="$withBase('/')" class="logo" tag="h1">
      <Logo v-if="$themeConfig.logo"></Logo>
      <span class="logotype" v-else>{{ $siteTitle }}</span>
    </router-link>
    <div class="menu">
      <div class="item">
        <Icon @click="handleClickSearch" name="search"></Icon>
      </div>
      <div class="item">
        <Theme />
      </div>
    </div>
  </header>
</template>

<script>
import Theme from './Theme.vue';
import store from '@theme/store';

export default {
  name: 'HeaderBar',
  components: {
    Theme,
  },
  methods: {
    handleClickSearch() {
      store.showSearch = true;
    },
  },
};
</script>

<style lang="stylus" scoped>
@import '~@theme/styles/_mixins.styl';

.header-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 100%;

  .logo {
    display: flex;
    align-items: center;
    cursor: pointer;

    .logo-img {
      display: block;
      margin-right: space(2);
      max-height: 36px;
    }
  }

  .menu {
    display: flex;
    align-items: center;
    margin-left: auto;

    .item {
      display: flex;
      justify-content: center;
      align-items: center;
      width: 32px;
      height: 32px;
      font('xl');
      cursor: pointer;
      rounded();

      &:hover {
        background: var(--bg-hover);
      }
    }
  }
}
</style>
