<template>
  <header id="header" class="main-nav">
    <router-link to="/">
      <img src="https://www.cycloid.io/themes/cycloid/images/owl_logo.png" alt="Cycloid.io" />
      <h1>Fruits</h1>
    </router-link>

    <div class="actions">
      <button
        :disabled="modalIsOpen"
        class="action-btn action-btn--delete"
        @click="() => $store.commit('toggleDeleteMode')"
      >
        {{ deleteMode ? "&#x1F6AB;" : "&#x1f5d1;" }}
      </button>
      <button
        :disabled="deleteMode"
        class="action-btn action-btn--add"
        @click="() => $store.commit('toggleModal')"
      >
        {{ modalIsOpen ? "&#x1F6AB;" : "&#x2795;" }}
      </button>
    </div>
  </header>
</template>

<script>
import { mapState } from "vuex";

export default {
  name: "Header",
  computed: {
    ...mapState(["deleteMode", "modalIsOpen"])
  }
};
</script>

<style lang="less">
header {
  background-color: @color-2;
  box-shadow: 0 0px 14px 0px #cecece;

  h1 {
    margin: 0;
    font-size: 28px;
    font-weight: lighter;
  }

  &.main-nav {
    position: sticky;
    top: 0;
    left: 0;
    right: 0;
    z-index: 15;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1rem;
    height: @headerHeight;
    transition: all 0.3s ease-in-out;

    a {
      display: flex;
      align-items: center;

      img {
        width: 35px;
        height: 35px;
        margin-right: 1rem;
      }
    }

    .actions {
      display: flex;
      align-items: center;

      .action-btn {
        width: 42px;
        height: 42px;
        border: none;
        border-radius: 50%;
        color: @color-2;
        font-size: 24px;
        font-weight: lighter;
        text-align: center;
        margin-left: 1rem;
        padding-top: 2px;
        background: lighten(#cecece, 10%);

        &:disabled {
          opacity: 0.4;
        }

        &--delete {
          border: 1px solid @text-error;
        }

        &--add {
          border: 1px solid @color-1;
        }
      }
    }
  }
}
</style>
