<template>
    <li>
        <RouterLink v-if="to" :to="to" class="block hover:text-green-600" role="menuitem">
            {{ text }}
        </RouterLink>
        <button v-else @click="$emit('click')" class="w-full text-left hover:text-green-600" role="menuitem">
            {{ text }}
        </button>
    </li>
</template>

<script setup>
    defineProps({
        text: {
            type: String,
            required: true
        },
        to: {
            type: String,
            default: null
        }
    });

    defineEmits(['click']);
</script>

<style lang="postcss" scoped>
    .router-link-exact-active {
        @apply text-green-600;
    }
</style>
