widget-topic.vue 1.21 KB
<template>
  <div v-if="topic" class="topic-wrap" @click="onClick">
    <div class="topic-icon">
      <span>#</span>
    </div>
    <span class="topic-text">{{topic}}</span>
  </div>
</template>

<script>
export default {
  name: 'WidgetTopic',
  props: {
    topic: String,
  },
  methods: {
    onClick() {
      this.$emit('click');
    }
  }
};
</script>

<style type="scss">
  .topic-wrap {
    display: inline-block;
    vertical-align: middle;
    height: 48px;
    line-height: 48px;
    background-color: #f0f0f0;
    border-radius: 22px;
    box-sizing: border-box;

    > * {
      display: inline-block;
      vertical-align: top;
    }

    .topic-icon {
      width: 28px;
      height: 28px;
      line-height: 28px;
      border-radius: 50%;
      margin: 10px;
      text-align: center;
      background-color: #222;

      > span {
        font-size: 24px;
        color: #fff;
        transform: scale(0.8, 0.8);
        display: inline-block;
      }
    }

    .topic-text {
      font-size: 26px;
      font-weight: 500;
      color: #222;
      margin-left: -4px;
      margin-right: 16px;
      max-width: 310px;
      overflow: hidden;
      text-overflow:ellipsis;
      white-space: nowrap;
    }
  }
</style>