<script setup>
defineProps({
    count: { type: Number, default: 0 },
    hasWarning: { type: Boolean, default: false },
})

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

<template>
    <button
        v-if="count > 0"
        data-testid="macro-icon"
        class="relative flex items-center justify-center rounded-lg bg-amber-100 px-2 py-1 text-xs font-medium text-amber-700 transition-colors hover:bg-amber-200"
        :aria-label="`${count} Makro-Zuweisungen`"
        @click="$emit('click')"
    >
        <svg class="h-3.5 w-3.5 shrink-0" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2">
            <path stroke-linecap="round" stroke-linejoin="round" d="M13 10V3L4 14h7v7l9-11h-7z" />
        </svg>
        <span class="ml-1">{{ count }}</span>
        <span
            v-if="hasWarning"
            class="absolute -right-1 -top-1 flex h-3 w-3 items-center justify-center rounded-full bg-red-500"
            aria-label="Warnung: deaktiviertes Makro"
        />
    </button>
</template>
