<!-- src/views/Ranking/WeeklyStar/components/topUser.vue -->
<template>
  <div style="width: 100%">
    <div style="position: relative" :style="{ minHeight: isTopOne ? '62.23vw' : '45.85vw' }">
      <img
        v-smart-img
        :src="BorderImgUrl"
        alt=""
        width="100%"
        style="display: block; position: relative; z-index: 2"
      />
      <!-- 头像 -->
      <div
        style="
          position: absolute;
          top: 0;
          left: 0;
          right: 0;
          height: 65%;
          z-index: 1;
          display: flex;
          justify-content: center;
          align-items: center;
        "
      >
        <div :style="{ width: isTopOne ? '50%' : '80%' }">
          <img
            :src="avatarUrl || ''"
            alt=""
            width="100%"
            style="border-radius: 50%; aspect-ratio: 1/1; object-fit: cover"
            @error="handleAvatarImageError"
          />
        </div>
      </div>
      <!-- 用户名和贡献值 -->
      <div
        style="
          position: absolute;
          bottom: 0;
          left: 0;
          right: 0;
          height: 35%;
          z-index: 3;

          display: flex;
          flex-direction: column;
          align-items: center;
        "
      >
        <div
          style="height: 28%; display: flex; justify-content: center; align-items: center"
          :style="{ width: isTopOne ? '35%' : '50%' }"
        >
          <div style="font-weight: 860" class="showText" :class="isTopOne ? 'top1Text' : 'text'">
            {{ name }}
          </div>
        </div>
        <div
          style="height: 40%; display: flex; justify-content: center; align-items: center"
          :style="{ width: isTopOne ? '30%' : '40%' }"
        >
          <div
            style="font-weight: 700; color: #642624"
            class="showText"
            :class="isTopOne ? 'top1Text' : 'text'"
          >
            {{ distributionValue }}
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup>
import { handleAvatarImageError } from '@/utils/image/imageHandler.js'

const props = defineProps({
  isTopOne: {
    type: Boolean,
    default: true,
  },

  avatarUrl: {
    type: String,
    default: '/src/assets/icon/Aslan/defaultAvatar.png',
  },

  BorderImgUrl: {
    type: String,
    required: true,
  },

  name: {
    type: String,
    default: '',
  },

  distributionValue: {
    type: String,
    default: '',
  },
})
</script>

<style lang="scss" scoped>
* {
  color: black;
}

.showText {
  color: #fff;
  text-align: center;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.top1Text {
  font-size: 0.9em;
}

.text {
  font-size: 0.8em;
}

@media screen and (max-width: 360px) {
  * {
    font-size: 10px;
  }
}

@media screen and (min-width: 360px) {
  * {
    font-size: 12px;
  }
}

@media screen and (min-width: 768px) {
  * {
    font-size: 24px;
  }
}

@media screen and (min-width: 1024px) {
  * {
    font-size: 32px;
  }
}
</style>
