<template>
  <div
      :class="getClass"
      v-on="$listeners"
  >
    <div v-if="count" class="fl-chess-item-room__count">{{ count }}</div>
    <div v-if="chessPlus" class="fl-chess-item-room__area">{{ area }}</div>
  </div>
</template>

<script>
export default {
  name: 'FlChessItem',
  props: {
    count: {
      type: [String, Number]
    },

    area: {
      type: Number,
      default: 0
    },

    type: {
      type: String,
      default: 'inaccessible'
    },

    chessPlus: {
      type: Boolean,
      default: false
    },

    active: {
      type: Boolean,
      default: false
    }
  },

  computed: {
    getClass () {
      return `fl-chess-item ${this.chessPlus ? 'chess-plus' : ''} ${this.type} ${this.active ? 'active' : ''}`
    }
  }
}
</script>
<style lang="scss" scoped>
.fl-chess-item {
  box-sizing: border-box;
  width: 32px;
  height: 32px;
  margin: 2px 2px;
  font-size: 14px;
  background: $light-01;
  border-radius: 2px;
  cursor: pointer;
  transition: 0.2s;

  @include flex-center;
}

.fl-chess-item.chess-plus {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  width: 48px;
  height: 48px;
  padding: 4.5px 4px;
  color: $light-01;

  .fl-chess-item-room__count {
    margin-bottom: 5px;
    font-size: 14px;
  }

  .fl-chess-item-room__area {
    color: rgba($light-01, 0.5);
    font-size: 13px;
  }

  &.RESERVATION .fl-chess-item-room__area {
      color: rgba($yellow, 0.7);
  }

  &.FREE {
    .fl-chess-item-room__count {
      color: $green;
    }

    .fl-chess-item-room__area {
      color: rgba($green, 0.5);
    }

    &.active {
      background: $green;
      border: initial;

      .fl-chess-item-room__count {
        color: $light-01;
      }

      .fl-chess-item-room__area {
        color: rgba($light-01, 0.7);
      }
    }
  }

  &.RESERVATION {
    &.active {
      .fl-chess-item-room__area {
        color: rgba($light-01, 0.7);
      }
    }

    &:hover {
      @extend .active;
    }
  }
}

.fl-chess-item.FREE {
  &:hover {
    @extend .active;
  }
}

.fl-chess-item.active {
  color: $light-01;
  background: $green;
  border: initial;
}

.FREE {
  color: $green;
  border: 1px solid $green;
}

.fl-chess-item.RESERVATION {
  color: $yellow;
  border: 1px solid $yellow;

  &.active {
    color: $light-01;
    background: $yellow;
    border: initial;
  }

  &:hover {
    @extend .active;
  }
}

.inaccessible {
  color: $grey-04;
  background: $grey-03;
  cursor: default;
  pointer-events: none;
}

.SOLD {
  color: $light-01;
  background: $grey-04;
}
</style>
