<template>
  <div class="list-card w-100 rounded-3 d-flex align-items-center" :class="[this.invalid]">
    <input type="checkbox" :id="buttonID" :name="groupName" :value="buttonLabel" :aria-required="isRequired" />
    <label :for="buttonID" class="d-flex flex-column w-100 align-items-center pt-4 pb-2" tabindex="1">
      <img v-bind:src="require(`@/assets/img/icons/${buttonImage}`)" v-bind:alt="altText" />
      <p class="m-0 order-3">{{buttonLabel}}</p>
    </label>
  </div>
</template>

<script>
export default {
  name: "listCard",
  props: {
    buttonImage: String,
    buttonLabel: String,
    altText: String,
    buttonID: String,
    groupName: String
  }
};
</script>

<style lang="scss">
.list-card {
  border: 1px solid $gray-500;
  &.invalid { //Red border if invalid
    border: 1px solid $red;
  }
  img {
    height: 46px;
    width: auto;
    order: 1;
    margin-bottom: 3rem;
  }
  &:hover {
    box-shadow: 0px 0px 0px 6px $blue-100;
    border: 1px solid transparent;
  }
  input[type='checkbox'] {
    position: absolute !important;
    height: 1px;
    width: 1px;
    overflow: hidden;
    clip: rect(1px, 1px, 1px, 1px);
    + label {
     display: block;
     position: relative;
     &:hover {
       cursor: pointer;
     }
   }
   &:focus + label {
     box-shadow: 0 0 0 2.5px $blue;
     border-radius: .5rem;
   }
   &:checked + label {
     background: $blue-100;
     box-shadow: 0 0 0 1px $blue;
     border-radius: .5rem;
   }
   + label::before {
     content: "";
      position: absolute;
      display: flex;
      margin: 0 auto;
      width: 1rem;
      height: 1rem;
      margin: 4rem 0 0 0;
      background: white;
      border: 1px solid $gray-500;
      border-radius: 2px;
      order: 2;
   }
   &:checked + label::before {
     background: $blue;
   }
   &:checked + label::after {
     content: '';
     position: absolute;
     margin: 4.2rem 0 0 0;
     border-left: 2px solid $white;
     border-bottom: 2px solid $white;
     height: 6px;
     width: 11px;
     transform: rotate(-45deg);
   }
   &:disabled + label {
     color: #575757;
   }
   &:disabled + label::before {
     background: #ddd;
   }
  }
}
</style>
