mealie/frontend/components/global/BaseButtonGroup.vue
Michael Genson 693608d59f
feat: cook timer (#2508)
* updated base button group

* added kitchen timer

* added missing icon

* usability tweaks

* for for menu rendering over app bar

* clean up types

* fix for mp3 loading, maybe?

* spooky linter fixes

* for real this time

---------

Co-authored-by: Hayden <64056131+hay-kot@users.noreply.github.com>
2023-08-23 09:31:23 -08:00

83 lines
2.1 KiB
Vue

<template>
<v-item-group>
<template v-for="btn in buttons">
<v-menu v-if="btn.children" :key="'menu-' + btn.event" active-class="pa-0" offset-y top left :style="stretch ? 'width: 100%;' : ''">
<template #activator="{ on, attrs }">
<v-btn tile :large="large" icon v-bind="attrs" v-on="on">
<v-icon>
{{ btn.icon }}
</v-icon>
</v-btn>
</template>
<v-list dense>
<v-list-item v-for="(child, idx) in btn.children" :key="idx" dense @click="$emit(child.event)">
<v-list-item-title>{{ child.text }}</v-list-item-title>
</v-list-item>
</v-list>
</v-menu>
<v-tooltip
v-else
:key="'btn-' + btn.event"
open-delay="200"
transition="slide-y-reverse-transition"
dense
bottom
content-class="text-caption"
>
<template #activator="{ on, attrs }">
<v-btn
tile
icon
:color="btn.color"
:large="large"
:disabled="btn.disabled"
:style="stretch ? `width: ${maxButtonWidth};` : ''"
v-bind="attrs"
v-on="on"
@click="$emit(btn.event)"
>
<v-icon> {{ btn.icon }} </v-icon>
</v-btn>
</template>
<span>{{ btn.text }}</span>
</v-tooltip>
</template>
</v-item-group>
</template>
<script lang="ts">
import { computed, defineComponent } from "@nuxtjs/composition-api";
export interface ButtonOption {
icon?: string;
color?: string;
text: string;
event: string;
children?: ButtonOption[];
disabled?: boolean;
}
export default defineComponent({
props: {
buttons: {
type: Array as () => ButtonOption[],
required: true,
},
large: {
type: Boolean,
default: true,
},
stretch: {
type: Boolean,
default: false,
}
},
setup(props) {
const maxButtonWidth = computed(() => `${100 / props.buttons.length}%`);
return {
maxButtonWidth,
};
}
});
</script>