<template>
    <button @click="() => click()" class="base-shape button pointer center" :class="{ loading: loading, reverse: reverse, disabled: disabled }"><slot></slot><UiIcon v-if="icon">{{icon}}</UiIcon></button>
</template>

<script setup lang="ts">
function click() {
    if(!props.disabled) {
        if(props.onclick != null) {
            props.onclick() 
        }
        if(props.to != null) {
            useRouter().push(props.to);
        }
    }
}

const props = defineProps<{
    icon?: string,
    reverse?: boolean,
    loading?: boolean | undefined,
    disabled?: boolean,
    onclick?: () => void
    to?: string
}>();
</script>

<style>
.button {
    background-color: black;
    color: white;
    border: none;
    outline: none;
    gap: 0.5rem;
    white-space: nowrap;
    border-radius: 0.25rem;
    padding: 0.5rem;
    font-weight: 500;
    font-size: 1rem;
}
.button * {
    color: white;
    fill: white;
}
</style>