<template>
  <div class="tip-wrapper">
    <div class="icon">
      <img src="./tip-icon.svg" alt="">
    </div>
    <div class="text text-tip-2 text-primary-50-clor">
      <div v-if="ellipsis" :title="tipText" class="one-line-ellipsis">{{ tipText }}</div>
      <div v-else>{{ tipText }}</div>
    </div>
  </div>
</template>

<script setup>
import { computed } from 'vue'

const props = defineProps({
  text: {
    type: String,
    default: ''
  },
  dataSource: {
    type: String,
    default: '美国国会官网'
  },
  dataTime: {
    type: String,
    default: '2023.1至2025.12'
  },
  ellipsis: {
    type: Boolean,
    default: false
  }
})

const tipText = computed(() => props.text || `数据来源：${props.dataSource},数据时间：${props.dataTime}`)

</script>

<style lang="scss" scoped>
.tip-wrapper {
  width: 100%;
  display: flex;
  gap: 8px;
  justify-content: flex-start;
  align-items: center;
  height: 22px;

  .icon {
    width: 16px;
    height: 16px;

    img {
      width: 100%;
      height: 100%;
    }
  }
  .text {
    width: 20px;
    flex: auto;
  }
}
</style>