widget-topic.vue 1.88 KB
<template>
  <div v-if="topic" class="topic-wrap" @click="onClick">
    <div class="topic-icon"></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-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACoAAAAqCAQAAABvygHQAAACGklEQVRIx7WXsUvDQBTGM/U/6NrhLlBKSRcXnYRuTi7SSQRx7GBxbRBEhbZLwcFVq3YRdXOoiB1aoatuXUIdBKHgkqGC1PPlJTnbNHdNY3IflHy95tfL3bt3L4oibUSjZdKkbdKnJjXhsw2uTDQlXCOaWicGYQIZ0LsYmqRog4yFQFdj+FUqEDCbUCv0ay7Q1UitZBNzkGqSdAIDXXXUpASZzpHBwkhLg3ROiIT1ZeFETV8sPPggLNIe7cwkZBMh5nJmbj1LRqv/RoLUylRcklEUUKD8xS0EMYtGtME3pHz3bDOrnXK/gf5SsMuczQu7WPrvJwjZ4f4I/Z5oXuv2SA05tIuQJe7v0eeFqcbeRfJZYiYgjIlv3sF/Su6AbUB1OXQNx3XD/TL6J9kwdIU0/bsOHN0hpMX9FfouXguwTQVyuW9XkCYYaVsh/aihpK+IMlMRVWI/PrCh0yvKWIo83a0jpMd9Hv3DnDQofHxb+wg55v4QfU2+WfvChbJ16wn0Z/Sb8pG2hSG1hXrzXaCi0ysOKT3ykCpbOSrqkNKECaUG6uGt13htqeWsveuFCUWW+h4RssL9OfqC/Eipz0nSQ0B8TPgX8N8sIy2FeIXlf5ysOqnE9RkAMvYa7DjBgsynetr1BHoB/UXQg8//iD7zBHoVfSnoER1TMRFL2RNTgRZTKRlT0RtTeR7Ti0RsrzxTEaHPvJzp0mWB9gvPWcQH0DXIXAAAAABJRU5ErkJggg==');
      background-size: 100% 100%;
    }

    .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>