import { computed, ref } from "vue";
import { getId } from "../handlers.js";

const html = (v) => { return v[0] };

export default {
  props: ["icon", "text", "withshortkey"],
  setup(props) {
    const el = ref(null);
    const suffix = computed(() => props.withshortkey ? ` (${getId(el.value)})`: "");
    return { suffix, el }
  },
  template: html`
      <div class="square element" ref="el">
        <div class="icon">
          <inject-svg v-if="icon.endsWith('.svg')" :src="icon"></inject-svg>
          <img v-if="!icon.endsWith('.svg')" :src="icon">
        </div>
        <h2>{{ text }}{{ suffix }}</h2>
      </div>
  `
}
