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 May 20, 2024
1 parent 3f2adf5 commit 591e68d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 16 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 /></span>
<slot name="end" />
Expand All @@ -9,5 +9,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>
21 changes: 7 additions & 14 deletions src/components/CardFooter.vue
Original file line number Diff line number Diff line change
@@ -1,19 +1,12 @@
<template>
<div class="card-footer">
<div
class="btn btn--link btn--inline btn--med"
v-for="(action, index) in actions"
:key="index"
@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>
<btn v-for="(action, index) in actions" :key="index" type="link" class="btn--inline btn--med"
@click="action.onClick">
<template #start>
<an-icon :icon="action.icon" :iconPack="action.iconPack" />
</template>
{{ action.title }}
</btn>
</div>
</template>

Expand Down

0 comments on commit 591e68d

Please sign in to comment.