Skip to content

Commit 1ad0e3e

Browse files
committed
CardFooter: Define FooterAction, move conditional rendering outside
1 parent d0933ff commit 1ad0e3e

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

src/components/Card.vue

+3-7
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,12 @@
1818
>
1919
<card-header :item :altText />
2020
<card-content :item :altText />
21-
<card-footer :item />
21+
<card-footer v-if="item.footerActions" :actions="item.footerActions" />
2222
</conditional-link>
2323
</template>
2424

2525
<script setup lang="ts">
26+
import type { CardFooterAction } from "./CardFooter.vue";
2627
import type { LinkProps } from "./ConditionalLink.vue";
2728
2829
interface CardItemI {
@@ -40,12 +41,7 @@ interface CardItemI {
4041
}[];
4142
btn?: string;
4243
html?: string;
43-
footerActions?: {
44-
title?: string;
45-
onClick: (event: MouseEvent) => void;
46-
icon: string;
47-
iconPack: "mdi" | "fa";
48-
}[];
44+
footerActions?: CardFooterAction[];
4945
}
5046
5147
export type CardItem = CardItemI & LinkProps;

src/components/CardFooter.vue

+9-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<template>
2-
<div class="card-footer" v-if="item.footerActions">
2+
<div class="card-footer">
33
<div
44
class="btn btn--link btn--inline btn--med"
5-
v-for="(action, index) in item.footerActions"
5+
v-for="(action, index) in actions"
66
:key="index"
77
@click="action.onClick"
88
>
@@ -18,7 +18,12 @@
1818
</template>
1919

2020
<script setup lang="ts">
21-
import type { CardItem } from "./Card.vue";
21+
export interface CardFooterAction {
22+
title?: string;
23+
onClick: (event: MouseEvent) => void;
24+
icon: string;
25+
iconPack: "mdi" | "fa";
26+
}
2227
23-
defineProps<{ item: CardItem }>();
28+
defineProps<{ actions: CardFooterAction[] }>();
2429
</script>

0 commit comments

Comments
 (0)