<!-- Мини-карточка канала: логотип слева, название, счётчик видео (горизонтальная) -->
<template>
  <div class="card-channel-mini">
    <img
      v-if="card.avatarUrl && !imageError"
      :src="card.avatarUrl"
      :alt="card.name"
      class="card-channel-mini__logo"
      width="64"
      height="64"
      @error="imageError = true"
    >
    <span
      v-else
      class="card-channel-mini__logo --placeholder"
    >
      {{ card.name.charAt(0) }}
    </span>
    <div class="card-channel-mini__wrapper">
      <p class="card-channel-mini__name">{{ card.name }}</p>
      <div class="card-channel-mini__info">
        <span class="card-channel-mini__detail">
          <UiIcon
            name="video-camera"
            size="14"
          />
          {{ card.videosCount }}
        </span>
        <span
          v-if="featureFlags.FeatureFollowEnabled"
          class="card-channel-mini__detail"
        >{{ $n(8400, 'compact') }}</span>
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
import type { IChannelCard } from '../../types';

defineProps<{
  card: IChannelCard
}>();

const featureFlags = useRuntimeConfig().public.featureFlags;
const imageError = ref(false);
</script>

<style lang="scss">
.card-channel-mini {
  display: grid;
  grid-template-columns: auto 1fr;
  column-gap: 16px;
  align-items: center;
}

.card-channel-mini__logo {
  width: 64px;
  height: 64px;
  border-radius: $radius-full;
  object-fit: cover;
}

.card-channel-mini__logo.--placeholder {
  @include font-lg;

  display: grid;
  place-content: center;
  text-transform: uppercase;
  font-weight: 700;
  color: $channel-card-mini-placeholder-text;
  background-color: $channel-card-mini-placeholder-bg;
}

.card-channel-mini__name {
  @include font-base;

  font-weight: 600;
  color: $channel-card-mini-name;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-channel-mini__info {
  @include font-sm;

  display: flex;
  align-items: center;
  column-gap: 12px;
  margin-top: 4px;
  color: $channel-card-mini-info;
}

.card-channel-mini__detail {
  display: flex;
  align-items: center;
  column-gap: 4px;
}
</style>
