<script setup lang="ts">
export interface Props {
  icon: object
  title: string
  href?: string
  color?: string
  tags?: string[]
}

defineProps<Props>()
</script>

<template>
  <li class="icon-link">
    <a class="icon-link__link" :href="href" target="_blank">
      <component class="icon-link__icon" :is="icon" />
      <span class="icon-link__title">
        {{ title }}
      </span>
      <span class="icon-link__tags">
        <span class="icon-link__tag" v-for="tag in tags">
          {{ tag }}
        </span>
      </span>
    </a>
  </li>
</template>

<style lang="scss">
.icon-link {
  margin: 0.75em 0;

  &__link {
    position: relative;
    display: flex;
    flex-flow: row nowrap;
    justify-content: flex-start;
    align-items: center;

    background-color: var(--clr-page-black);
    text-decoration: none;

    border: 0.125em solid var(--clr-page-black-light);
    border-radius: 0.5em;

    transition: background-color 0.3s linear;

    @media (hover: hover) {
      &:hover {
        background-color: var(--clr-page-black-light);
      }
    }
  }

  @media (hover: hover) {
    &__link:hover &__tag {
      background-color: var(--clr-page-black);
    }
  }

  &__icon {
    flex: 0 0 2.5em;
    width: 2.5em;
    height: 2.5em;
    fill: var(--color);
    transition: 0.5s;
    margin: 0.5em;
    padding: 0.25em;
  }

  &__title {
    flex: 1 1 100%;
    text-align: left;

    @media (min-width: 25em) {
      text-align: center;
    }
  }

  &__tags {
    position: absolute;
    inset: 0.25em 0.25em auto auto;
    display: block;
    font-size: 0.625em;
  }

  &__tag {
    background-color: var(--clr-page-black-light);
    border-radius: 0.25rem;
    padding: 0.125em 0.25em;
    transition: background-color 0.3s linear;

    & + & {
      margin: 0 0 0 0.25em;
    }
  }
}
</style>
