<script setup>
    import CloseIcon from '../assets/icons/close.svg'
</script>

<template>
    <div id="linkPannel" class="windowStyle" ref="linkPannel" @mousedown="$emit('focus')" @touchstart="$emit('focus')">
      <Moveable
          className="moveable"
          :target="target"
          :draggable="true"
          @drag="onDrag"
      />
      <div class="windowTitle">
        <p>
          Liens utiles
        </p>
        <!-- touchstart.capture pour passer en prio sur déplacement fenêtre/ .stop si pas de method-->
        <button type="button" class="closeBtn" @mousedown.capture="$emit('close')" @touchstart.capture="$emit('close')" data-tooltip="fermer">
          <CloseIcon name="close" class="icon"/>
        </button>
      </div>
      <div class="windowContent" id="linkContent">
        <a id="linkItem" v-for="item of displayedLinks" :href="item.href" class="textBtnStyle">
          <p><strong>{{item.title}}</strong><br>{{item.desc}}</p>
        </a>
      </div>
    </div>
</template>

<style scoped>
  /*================= Mise en page:
    => Mobile First : par défaut, moins de 500px
    => Tablette et PC format haut : de 500 à 1000px
    => PC large : à partir de 1000px
  */

  /*+++++++++++++++++ COPYBOX
      ================ PC HAUT/IPAD
      @media(min-width:650px){}
      ================ PC LARGE
      @media(min-width:1300px){}
  */

  #linkPannel{
    position: fixed;
    width: 222px;
    height: 333px;
    top: 222px;
    left: 117px;
  }

  #linkContent{
    height: 100%;
    overflow-y: scroll;
    overflow-x: hidden;
  }

  #linkItem{
    width: 100%;
    padding-right: 13.12px;
    padding-left: 13.12px;
    font-family: 'velvelyne';
    font-size: 13.12px;
    border-radius: 0;
    border-width: 0 0 1.61px 0;
    text-align: left;
    justify-content: flex-start;
    box-sizing: border-box;

    strong{
      text-transform: uppercase;
      font-family: 'karrik';
      font-weight: normal;
      font-size: 16.1px;
    }
  }

  /*================ PC LARGE*/
  @media(min-width:650px){
    #linkPannel{
      left: 477px;
    }
  }
</style>

<script>
  import Moveable from 'vue3-moveable';
  import { lolLinkList } from '../lolLinks.js'

  export default {
    name : 'LinkPannel',
    components:{
      Moveable
    },
    data(){
      return{
        target: null
      }
    },
    emits: ['close','focus'],
    computed: {
      displayedLinks(){
        return lolLinkList
      }
    },
    methods:{
      onDrag({ target, transform }) {
        target.style.transform = transform;
      }
    },
    mounted(){
      this.target = this.$refs.linkPannel;
      console.log("Link pannel is loaded!");
    }
  };
</script>
