<template>
  <svg :class="svgClass" aria-hidden="true">
    <use :xlink:href="iconName"></use>
  </svg>
</template>

<script>
  export default {
    name: "CmsSvgIcon",
    props: {
      iconClass: {
        type: String,
        required: true,
      },
    },
    data() {
      return {
        className: "icon",
      };
    },
    computed: {
      iconName() {
        return `#icon-${ this.iconClass }`;
      },
      svgClass() {
        if (this.className) {
          return "svg-icon " + this.className;
        } else {
          return "svg-icon";
        }
      },
    },
  };
</script>
<style scoped>
  .svg-icon {
    width: 1.4em;
    height: 1.4em;
    vertical-align: -0.25em;
    fill: currentColor;
    overflow: hidden;
  }
</style>
