<template>
  <div style="background-color: rgb(250 249 248);padding:20px">
    <div class="title">
      <div class="arrow">
        <i class="el-icon-back" />
      </div>
      <div class="title-content" @click="$emit('modify','title')">
        {{ email.title }}

        <i class="btn el-icon-paperclip" />
        <i class="btn el-icon-edit" />
        <i class="btn el-icon-folder" />
      </div>
    </div>
    <div class="content">
      <div class="senderAvatar">
        <div class="avatar">{{ senderName }}</div>
      </div>
      <div class="email-info">
        <div class="item" @click="$emit('modify','from')">{{ email.from }}   <i class="btn el-icon-user" /></div>
        <div class="item" @click="$emit('modify','sent')">{{ email.sent }}</div>
        <div class="item" @click="$emit('modify','to')">to:{{ email.to }}</div>
        <div class="item" style="white-space:pre-wrap;color:black;margin-top:20px" @click="$emit('modify','message')" v-html="email.message" />
        <div class="sign">
          {{ email.from }}
        </div>
      </div>

    </div>
  </div>
</template>

<script>
export default {
  name: 'Email3',
  props: {
    email: {
      type: Object
    }
  },
  computed: {
    senderName: function() {
      return this.email.from?.substring(0, 1).toUpperCase()
    }
  }
}
</script>

<style scoped>
.title {
  height: 60px;
  display: flex;
  align-items: center;
}

.arrow {
    margin:0 20px;
  font-size: 30px;
  color: #999;
}
.title-content {
  color: black;
  font-weight: bold;
  font-size: 24px;
}

.content{
    display: flex;
    margin: 10px;
    padding: 20px;
    border:1px solid #ccc;
    height: 600px;
    background-color: white;
}
.senderAvatar{
    height: 100%;
}

.avatar{
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 26px;
    font-weight: bold;
    color: white;
    background-color: rgb(50, 156, 206);
}

.email-info{
    font-size: 14px;
    color: #999;
    padding-left: 20px;
}

.email-body{
    color:black;
    margin-top:20px;
}

.sign{
    margin-top:50px;
    font-weight: bold;
}

.item{
    margin:5px 0
}

.btn{
    margin:0 5px;
    font-size: 20px;
    color: rgb(95, 181, 214);
}
</style>
