All files / components/Grid DeleteItem.vue

0% Statements 0/3
100% Branches 0/0
0% Functions 0/5
0% Lines 0/3

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                                                                                                                                                                                           
<template>
  <div>
    <button class="delete-btn" @click="showPrompt">
      🚮
    </button>
    <div v-if="openPrompt" :class="{ open: openPrompt }" class="prompt">
      <h3>You will delete '{{ item.name }}'?</h3>
      <div class="actions">
        <button class="btn btn-cancel" @click="openPrompt = false">No</button>
        <button class="btn btn-success" @click="removeFruit(item.id)">Yes</button>
      </div>
    </div>
  </div>
</template>
 
<script>
export default {
  name: "DeleteItem",
  props: {
    item: Object,
    redirect: {
      type: Function,
      default: () => {}
    }
  },
  data() {
    return {
      openPrompt: false
    };
  },
  methods: {
    showPrompt() {
      this.openPrompt = true;
    },
    removeFruit(id) {
      this.$store.dispatch("removeFruit", id).then(() => this.redirect());
    }
  }
};
</script>
 
<style scoped lang="less">
.prompt {
  position: absolute;
  top: 0;
  right: 0;
  z-index: 2;
  background: rgb(230, 107, 107);
  background: linear-gradient(90deg, rgba(230, 107, 107, 1) 0%, rgba(214, 48, 49, 1) 100%);
  width: 0;
  height: 0;
  transition: all 0.4s ease-in-out;
  color: @color-2;
  display: flex;
  flex-flow: column;
  align-items: center;
  justify-content: center;
 
  &.open {
    width: 100%;
    height: 100%;
  }
 
  .btn {
    border: none;
    border-radius: 4px;
    color: @color-2;
    padding: 0.5rem 1.35rem;
    margin: 0 0.5rem;
  }
 
  .btn-success {
    background-color: #2ecc71;
  }
 
  .btn-cancel {
    background-color: darken(#cecece, 15%);
  }
}
 
.delete-btn {
  position: absolute;
  z-index: 1;
  top: 0;
  right: 0;
  width: 55px;
  padding: 0.75rem 0.75rem 1.35rem 1.35rem;
  background: rgb(230, 107, 107);
  background: linear-gradient(180deg, rgba(230, 107, 107, 0.6) 0%, rgba(214, 48, 49, 1) 100%);
  border: none;
  border-bottom-left-radius: 100%;
}
</style>