<template>
  <aside class="student-sidebar" :style="{ backgroundImage: `url(${bgPattern})` }">
    <div class="student-sidebar__logo">
      <img :src="logo" alt="مدرسه بانو" />
    </div>
    <nav class="student-sidebar__nav">
      <ul>
        <li v-for="item in menuItems" :key="item.title">
          <component
            :is="item.to ? 'RouterLink' : 'div'"
            :to="item.to"
            class="student-sidebar__link"
            :class="{ 'student-sidebar__link--active': item.active }"
          >
            <SvgIcon v-if="item.icon" :name="item.icon" :size="22" color="currentColor" />
            <span>{{ item.title }}</span>
          </component>
        </li>
      </ul>
    </nav>
    <SidebarLogout color="#fff" />
  </aside>
</template>

<script setup>
import { gallery } from '@/utils/gallery'
import SvgIcon from '@/components/icons/SvgIcon.vue'
import SidebarLogout from '@/layouts/sidebars/SidebarLogout.vue'

defineProps({
  menuItems: { type: Array, default: () => [] },
})

const logo = gallery.logoWhite
const bgPattern = gallery.studentSidebarPattern
</script>

<style lang="scss" scoped>
.student-sidebar {
  height: 100vh;
  width: 100%;
  padding: 1.5rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  border-radius: 0;
  border-top-left-radius: 2rem;
  border-bottom-left-radius: 2rem;
  background-color: var(--color-primary);
  background-position: center;
  background-size: cover;
  background-repeat: no-repeat;

  &__logo {
    display: flex;
    justify-content: center;

    img {
      height: 100px;
      object-fit: contain;
    }
  }

  &__nav {
    flex: 1;
    overflow-y: auto;

    ul {
      list-style: none;
      margin: 0;
      padding: 0;
      display: flex;
      flex-direction: column;
      gap: 0.25rem;
    }
  }

  &__link {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.625rem 0.875rem;
    border-radius: 9999px;
    font-family: var(--font-family-fa);
    font-size: 0.875rem;
    color: #fff;
    text-decoration: none;
    transition: background-color 0.15s;
    cursor: pointer;

    &:hover {
      background: rgba(255, 255, 255, 10%);
    }

    &--active {
      background: rgba(255, 255, 255, 10%);
    }
  }
}
</style>
