<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.column_type == 'dynamic'">
          <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>

        <template v-else>
          <div class="content-box html-content" :style="setColor" v-html="informations.footer_logo"></div>
        </template>

      </div>
    </transition>

  </div>
</template>

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

export default {
  name: 'CustomInformation',
  data() {
    return {
      informations: store.state.customInformations,
      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>