Skip to content

Commit

Permalink
CardFooter: Use Btn component for actions
Browse files Browse the repository at this point in the history
  • Loading branch information
mks-h committed Jun 28, 2024
1 parent 27217d7 commit eb99938
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
14 changes: 12 additions & 2 deletions src/components/Btn.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<conditional-link :link="props" class="btn btn--primary">
<conditional-link :link="props" :class="classes">
<slot name="start" />
<span>
<slot />
Expand All @@ -11,5 +11,15 @@
<script setup lang="ts">
import type { LinkProps } from "./ConditionalLink.vue";
const props = defineProps<LinkProps>();
interface BtnPropsI {
type?: "primary" | "link"
}
export type BtnProps = BtnPropsI & LinkProps;
const props = defineProps<BtnProps>();
const classes = ["btn"];
if (props.type === "link") classes.push("btn--link")
else classes.push("btn--primary")
</script>
11 changes: 6 additions & 5 deletions src/components/CardFooter.vue
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
<template>
<div class="card-footer">
<div class="btn btn--link btn--inline btn--med" v-for="(action, index) in actions" :key="index"
<btn v-for="(action, index) in actions" :key="index" type="link" class="btn--inline btn--med"
@click="action.onClick">
<an-icon :icon="action.icon" :iconPack="action.iconPack" :iconAsImage="action.iconAsImage"
:altText="action.altText" />
<span v-if="action.title">{{ action.title }}</span>
</div>
<template #start>
<an-icon :icon="action.icon" :iconPack="action.iconPack" />
</template>
{{ action.title }}
</btn>
</div>
</template>

Expand Down

0 comments on commit eb99938

Please sign in to comment.