Hangar/frontend/components/dropdown.vue

55 lines
1.4 KiB
Vue
Raw Normal View History

<template>
<v-list dense>
<v-list-item
v-for="control in controls"
:key="control.title"
link
:to="isRouterLink(control) ? control.link : null"
2021-01-22 11:11:24 +08:00
:nuxt="isRouterLink(control)"
:href="isRouterLink(control) ? null : control.link"
2021-01-22 11:11:24 +08:00
@click="control.action ? control.action() : null"
>
<v-list-item-icon>
<v-icon color="white">{{ control.icon }}</v-icon>
</v-list-item-icon>
<v-list-item-content>
<v-list-item-title>{{ control.title }}</v-list-item-title>
</v-list-item-content>
</v-list-item>
</v-list>
</template>
<script lang="ts">
import { Component, Vue } from 'nuxt-property-decorator';
import { Prop } from 'vue-property-decorator';
import { PropType } from 'vue';
export interface Control {
icon: String;
title: String;
2021-01-22 11:11:24 +08:00
link?: String;
action?: Function;
}
@Component
export default class Card extends Vue {
@Prop({ type: Array as PropType<Control[]>, required: true })
2021-01-22 07:08:06 +08:00
controls!: Control[];
isRouterLink(control: Control): Boolean {
2021-01-22 11:11:24 +08:00
return !!control.link && control.link.startsWith('/');
}
}
</script>
<style lang="scss" scoped>
.announcement {
text-align: center;
margin-bottom: 1rem;
}
.announcement-text {
padding: 0.25rem 0;
}
</style>