Skip to content
Snippets Groups Projects
MessageInfo.vue 2.53 KiB
Newer Older
  <li
    :ref="'message-' + message.counter"
    :class="['list-container', { show }]"
Timothee P's avatar
Timothee P committed
  >
    <div :class="['list-item', { show}]">
      <div :class="['ui', message.level ? message.level : 'info', 'message']">
        <i
          class="close icon"
          aria-hidden="true"
          @click="removeListItem"
        />
        <div class="header">
            class="info circle icon"
          Informations
        <ul class="list">
          {{
            message.comment
          }}
        </ul>
      </div>
  </li>
</template>

<script>
import { mapState, mapMutations } from 'vuex';

export default {
  name: 'MessageInfo',

  props: {
    message: {
      type: Object,
      default: () => {},
    },
  },

Timothee P's avatar
Timothee P committed
  data() {
    return {
      listMessages: [],
      show: false,
Timothee P's avatar
Timothee P committed
    };
  },

  computed: {
    ...mapState(['messages']),
  },

  mounted() {
    setTimeout(() => {
      this.show = true;
    }, 15);
  },
Timothee P's avatar
Timothee P committed

  methods: {
    ...mapMutations(['DISCARD_MESSAGE']),
Timothee P's avatar
Timothee P committed

    removeListItem(){
      const container = this.$refs['message-' + this.message.counter];
Timothee P's avatar
Timothee P committed
      container.ontransitionend = () => {
        this.DISCARD_MESSAGE(this.message.counter);
Timothee P's avatar
Timothee P committed
      };
      this.show = false;
Timothee P's avatar
Timothee P committed
    },
Timothee P's avatar
Timothee P committed
<style scoped>
.list-container{
    list-style: none;
    width: 100%;
    height: 0;
    position: relative;
    cursor: pointer;
    overflow: hidden;
    transition: all 0.6s ease-out;
}
.list-container.show{
  height: 6em;
Timothee P's avatar
Timothee P committed
}
.list-container.show:not(:first-child){
  margin-top: 10px;
}
.list-container .list-item{
    padding: .5rem 0;
    width: 100%;
    position: absolute;
    opacity: 0;
    top: 0;
    left: 0;
    transition: all 0.6s ease-out;
}
.list-container .list-item.show{
    opacity: 1;
}

ul.list{
  height: 2.2em;
Timothee P's avatar
Timothee P committed
  margin-bottom: .5em !important;
}

.ui.message {
  overflow: hidden;
  padding-bottom: 0 !important;
}
.ui.message::after {
  content: "";
  position: absolute;
  bottom: 0;
Timothee P's avatar
Timothee P committed
  left: 1em;
  right: 0;
  width: calc(100% - 2em);
}
.ui.info.message::after {
  box-shadow: 0px -8px 5px 3px rgb(248, 255, 255);
Timothee P's avatar
Timothee P committed
}
.ui.positive.message::after {
  box-shadow: 0px -8px 5px 3px rgb(248, 255, 255);
Timothee P's avatar
Timothee P committed
}
.ui.negative.message::after {
  box-shadow: 0px -8px 5px 3px rgb(248, 255, 255);
Timothee P's avatar
Timothee P committed
}

.ui.message > .close.icon {
  cursor: pointer;
  position: absolute;
  margin: 0em;
  top: 0.78575em;
  right: 0.5em;
  opacity: 0.7;
  -webkit-transition: opacity 0.1s ease;
  transition: opacity 0.1s ease;
}
</style>