<template>
  <div @click="onPress" class="code-fun-flex-row code-fun-items-center code-fun-relative folder-item">
    <img class="folder-icon" :src="iconSrc" />
    <span class="folder-name">{{ name }}</span>
    <span class="folder-count">{{ noteCount }}</span>
  </div>
</template>

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

const props = defineProps({
  id: {
    type: String,
    required: true,
  },
  name: {
    type: String,
    required: true,
  },
  noteCount: {
    type: Number,
    required: true,
  },
  onPress: {
    type: Function,
    required: true,
  },
  isSelected: {
    type: Boolean,
    default: false,
  },
})

const iconSrc = computed(() => {
  switch (props.id) {
    case 'all':
      return 'assets/icons/drawable-xxhdpi/icon_folder_all.png'
    case 'starred':
      return 'assets/icons/drawable-xxhdpi/icon_folder_favorite.png'
    case 'trash':
      return 'assets/icons/drawable-xxhdpi/icon_folder_trash.png'
    case 'archive':
      return 'assets/icons/drawable-xxhdpi/icon_folder_document.png'
    default:
      return 'assets/icons/drawable-xxhdpi/icon_folder_document.png'
  }
})
</script>

<style scoped>
.folder-item {
  padding: 0.3rem 0;
  background-color: #00000000;
}

.folder-icon {
  width: 1.8rem;
  height: 1.8rem;
  flex-shrink: 0;
  margin-inline: 0.3rem;
}

.folder-name {
  font-size: 0.9rem;
  line-height: 1.52rem;
  color: #9b9b9b;
}

.folder-count {
  font-size: 0.8rem;
  line-height: 1.16rem;
  margin-left: 0.7rem;
  margin-top: 0.2rem;
  color: #b8b8b8;
}
</style>
