<template>
  <div class="card border-secondary" :class="[borderClass]">
    <div class="card-header" :class="[bgClass, textClass]">
      <h5 class="card-title">{{ title }}</h5>
    </div>
    <div class="card-body">
      <h5 v-if="heading">{{ heading }}</h5>
      <p class="card-text">
        <slot />
      </p>
    </div>
  </div>
</template>

<script>
export default {
  props: {
    title: String,
    heading: String,
    type: { type: String, default: "primary" },
  },
  computed: {
    textClass: function() {
      const vm = this;
      if (
        ["primary", "secondary", "success", "danger", "dark"].some(
          (x) => x === vm.type
        )
      )
        return "text-white";
      return "text-dark";
    },
    borderClass: function() {
      return "border-" + this.type;
    },
    bgClass: function() {
      return "bg-" + this.type;
    },
  },
};
</script>

<style></style>