<template>
  <v-navigation-drawer
    :mini-variant.sync="miniVariant"
    clipped
    class="ot_dark_grey ot_menu_color--text"
    fixed
    app
  >
    <v-list>
      <div v-for="(item, i) in properties.menu" :key="i">
        <v-list-item
          v-if="!item.children"
          :href="item.isExternalLink ? item.to : undefined"
          :to="!item.isExternalLink ? item.to : undefined"
          router
          exact
        >
          <v-list-item-action>
            <v-icon class="ot_menu_color--text" small>{{ item.icon }}</v-icon>
          </v-list-item-action>
          <v-list-item-content>
            <v-list-item-title class="ot_menu_color--text" v-text="$t(item.title)"/>
          </v-list-item-content>
        </v-list-item>

        <v-list-group
          v-else
          v-model="item.active"
          no-action
        >
          <template v-slot:activator>
            <v-list-item-action>
              <v-icon class="ot_menu_color--text" small>{{ item.icon }}</v-icon>
            </v-list-item-action>
            <v-list-item-content>
              <v-list-item-title class="ot_menu_color--text" v-text="$t(item.title)"/>
            </v-list-item-content>
          </template>

          <v-list-item
            v-for="child in item.children"
            :key="child.title"
            :href="child.isExternalLink ? child.to : undefined"
            :to="!child.isExternalLink ? child.to : undefined"
            router
            exact
          >
            <v-list-item-action>
              <v-icon class="ot_menu_color--text" small>{{ child.icon }}</v-icon>
            </v-list-item-action>
            <v-list-item-content>
              <v-list-item-title class="ot_menu_color--text" v-text="$t(child.title)"/>
            </v-list-item-content>
          </v-list-item>
        </v-list-group>
      </div>

    </v-list>

  </v-navigation-drawer>
</template>

<script lang="ts">
  import {$useMenu} from '@/use/layout/menu'
  import {defineComponent, reactive} from '@nuxtjs/composition-api'

  export default defineComponent({
    props: {
      miniVariant: {
        type: Boolean,
        required: true
      }
    },
    setup() {
      const properties = reactive({
        menu: $useMenu.setUpContext().useLateralMenuConstruct()
      })

      return {
        properties
      }
    }
  })
</script>

<style scoped>
  .v-list-item__action, .v-list-group__header__prepend-icon {
    margin-right: 10px !important;
  }

  .v-application--is-ltr .v-list-group--no-action > .v-list-group__items > .v-list-item {
    padding-left: 30px;
  }

  .v-list-item__title {
    font-size: 14px;
  }

  .v-list-item {
    min-height: 10px !important;
  }

  .v-list-item__action {
    margin: 10px 0;
  }

  .v-list-item__content {
    padding: 8px 0;
  }

  .home_menu {
    font-size: 23px;
  }
</style>
