<script lang='ts'>
  import { createEventDispatcher } from "svelte";
  export let items;
  export let activeItem;

  const dispatch = createEventDispatcher();

</script>

<!-- svelte-ignore a11y-click-events-have-key-events -->
<div class="tabs">
  <!-- creates a list, can be done other ways -->
  <ul>
    {#each items as item}
      <li on:click={() => dispatch('tabChange', item)}>
        <!-- the class active is attributed if the condition is met -->
        <div class:active={activeItem === item}>{item}</div>
      </li>
    {/each}
  </ul>
</div>

<style>
  .tabs{
    margin-bottom: 40px;
  }
  ul{
    display: flex;
    justify-content: center;
    padding: 0;
    list-style-type: none;
  }
  li{
    margin: 0 16px;
    font-size: 18px;
    color: #555;
    cursor: pointer;
  }
  .active{
    color: #d91b42;
    border-bottom: 2px solid #d91b42;
    padding-bottom: 8px;
  }
</style>