UserRibbon.vue 999 Bytes
Newer Older
1 2 3 4
<template>
  <div class="vue-user-ribon--wrap" aria-hidden="true">
    <p>Vous êtres connecté <strong>{{username}}</strong>.</p>
    <avatar :username="this.username" :src="this.pathToImage"/>
5 6 7 8
    <button class="logout-button" v-on:click="logout">
      <img src="icons/logout.svg" height="40"/>
    </button>
    
9 10 11 12 13 14 15 16 17
  </div>
</template>


<script>
// @ is an alias to /src
import Avatar from '@/components/Avatar.vue'

export default {
18
  name: 'UserRibbon',
19 20 21 22 23 24 25 26 27 28 29
  props: {
    username: {
      type: String
    },
    
    pathToImage: {
      type: String
    }
  },
  components: {
    Avatar
30 31 32
  },
  methods: {
    logout: function() {
33
      localStorage.removeItem('user');
34 35
      this.$router.push('/')
    }
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
  }
}
</script>

<style>
.vue-user-ribon--wrap{
    display: flex;
}

.vue-user-ribon--wrap *{
    align-self: center;
    margin: 5px;
}
.vue-user-ribon--wrap strong{
    margin: 0;
}
p{
    
    color: white;
}
56 57 58 59 60
.logout-button{
  
    background: transparent;
    border: none;
}
61
</style>