<template>
  <div class="content-box">

    <div class="flex between-xs middle-xs" @click.prevent=" isMobile ? showContent = !showContent : ''">
      <h4 class="footer-title text-small text-bold vertical-margin-x-small">{{ language.text_information }}</h4>
      <i class="fas hidden-md-up" :class="showContent && isMobile ? 'fa-angle-up' : 'fa-angle-down'"></i>
    </div>

    <transition name="information-transition">
      <div v-if="showContent"> 

        <template v-if="informations.data">
          <div v-for="(data, key) in informations.data" :key="key">
            <a :href="data.link" class="text-small visible-block vertical-padding-x-small" :title="data.text">{{ data.text }}</a>
          </div>
        </template>

      </div>
    </transition>

  </div>
</template>

<script>
import store from "@components/TheFooter/storeFooter.js";

export default {
  name: 'DynamicInformation',
  data() {
    return {
      informations: store.state.dynamicInformations,
      language: store.state.languages,
      showContent: true, 
      isMobile: false,
    };
  },
  computed: {
    setColor() {
      return {
        'color': this.informations.color,
      }  
    },
  },
  methods: {
    resize() {
      this.isMobile =  window.innerWidth < 992 ?? false;
      this.showContent = !this.isMobile ?? true;

      window.addEventListener('resize', () => {
        this.isMobile =  window.innerWidth < 992 ?? false;
        this.showContent = !this.isMobile ?? true;
      });
    },
  },
  created() {
    this.resize();
  },
}
</script>

<style scoped>
.information-transition-enter-active {
transition: all .3s ease;
}
.information-transition-leave-active {
  transition: all .3s cubic-bezier(1.0, 0.5, 0.8, 1.0);
}
.information-transition-enter, .information-transition-leave-to {
  transform: translateY(-20px);
  opacity: 0;
}
</style>