# All files / components Header.vue

100% Statements 1/1
100% Branches 0/0
100% Functions 0/0
100% Lines 1/1

Press n or j to go to the next uncovered block, b, p or k for the previous block.

    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
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106

    1x

     <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>