widget-topic.vue 1.71 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,iVBORw0KGgoAAAANSUhEUgAAACoAAAAqCAMAAADyHTlpAAAAWlBMVEUAAAAiIiIiIiIjIyMnJyciIiIiIiIiIiIiIiIjIyMkJCQjIyMiIiIkJCQrKysjIyMjIyMiIiL///+QkJCgoKCAgIDf39+/v79hYWFBQUHv7+/AwMCvr69gYGDJAUDtAAAAEXRSTlMA36PzLi342cO/j4geFQZ8e771dgcAAAEVSURBVDjLlZXJrsMgDEUNhBKSZrCTTm/4/98sUh0JkybAWdzVXcARNpBgZ+2dMc7r2cIJtlMYobqj9lXjDn2FPWN/wS9c+hEShhYPaAcQNAoPUY1oGjzBRN1B4SlqAGZsMUO73a3HLD37TCwty8IZOfv4Tcy/iO6cERoCFiVPogdnjA3VDiU3opUzpgvVVNRKdOMUwoJ9TPgl+ucUNDCJuwd+iFZOIWES96cdwoEvrXpwyQH+glBOeQAHJudqw4DJu9qqDiUPoienxIFHyZ3oxSnxNbKm0uoMtrRqAVSZKyUfYeoqfYS2zJWFgC5xpeUYpjMoxrB8uCtWRv0iyq+3+qWZX8XlC77m26j/jFKaafvipgYkb9BQXEZhgbcaAAAAAElFTkSuQmCC");
      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>