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

<template>
    <div id="instaPannel" class="windowStyle" ref="instaPannel" @mousedown="$emit('focus')" @touchstart="$emit('focus')">
      <Moveable
          className="moveable"
          :target="target"
          :draggable="true"
          @drag="onDrag"
      />
      <div class="windowTitle">
        <p>
          ATTENTION!
        </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="warnContent">
        <div id="warnText">
          <p>Vous allez quiter le site<br>pour aller sur <strong>Instragram!</strong></p>
        </div>
        <a href="https://www.instagram.com/drags_nerds/?utm_source=ig_web_button_share_sheet" class="textBtnStyle" @mousedown.stop @touchstart.stop target="_blank" @click="$emit('close')">
          OK !
        </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){}
  */

  #instaPannel{
    position: fixed;
    width: 333px;
    height: 161px;
    top: 333px;
    left: 33px;
  }

  #warnContent{
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    height: 100%;
    width: 100%;
  }

  #warnText{
    height:100%;
    width: 66.6%;
    font-family: 'velvelyne';
    font-size: 16.1px;
    color: var(--main-color);
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: space-around;
  }

  #warnText strong{
    font-family: 'lineal';
    font-weight: normal;
  }



  #warnContent .textBtnStyle{
    height:33px;
    width: 77px;
  }
  /*================ PC LARGE*/
  @media(min-width:1300px){
    #instaPannel{
      left:333px;
    }
  }
</style>

<script>
  import Moveable from 'vue3-moveable';

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