Skip to content

Commit

Permalink
fix(Alert): improve config options
Browse files Browse the repository at this point in the history
Resolves #760
  • Loading branch information
benjamincanac committed Nov 14, 2023
1 parent f323379 commit 91511b9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
13 changes: 7 additions & 6 deletions src/runtime/components/elements/Alert.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template>
<div :class="alertClass" v-bind="attrs">
<div class="flex gap-3" :class="{ 'items-start': (description || $slots.description), 'items-center': !description && !$slots.description }">
<div class="flex" :class="[ui.gap, { 'items-start': (description || $slots.description), 'items-center': !description && !$slots.description }]">
<UIcon v-if="icon" :name="icon" :class="ui.icon.base" />
<UAvatar v-if="avatar" v-bind="{ size: ui.avatar.size, ...avatar }" :class="ui.avatar.base" />

Expand All @@ -16,14 +16,14 @@
</slot>
</p>

<div v-if="(description || $slots.description) && actions.length" class="mt-3 flex items-center gap-2">
<div v-if="(description || $slots.description) && actions.length" :class="ui.actions">
<UButton v-for="(action, index) of actions" :key="index" v-bind="{ ...ui.default.actionButton, ...action }" @click.stop="action.click" />
</div>
</div>
<div v-if="closeButton || (!description && !$slots.description && actions.length)" class="flex-shrink-0 flex items-center gap-3">
<div v-if="!description && !$slots.description && actions.length" class="flex items-center gap-2">
<div v-if="closeButton || (!description && !$slots.description && actions.length)" :class="twMerge(ui.actions, 'mt-0')">
<template v-if="!description && !$slots.description && actions.length">
<UButton v-for="(action, index) of actions" :key="index" v-bind="{ ...ui.default.actionButton, ...action }" @click.stop="action.click" />
</div>
</template>

<UButton v-if="closeButton" aria-label="Close" v-bind="{ ...ui.default.closeButton, ...closeButton }" @click.stop="$emit('close')" />
</div>
Expand Down Expand Up @@ -126,7 +126,8 @@ export default defineComponent({
// eslint-disable-next-line vue/no-dupe-keys
ui,
attrs,
alertClass
alertClass,
twMerge
}
}
})
Expand Down
4 changes: 3 additions & 1 deletion src/runtime/ui.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -333,9 +333,11 @@ export const alert = {
wrapper: 'w-full relative overflow-hidden',
title: 'text-sm font-medium',
description: 'mt-1 text-sm leading-4 opacity-90',
actions: 'flex items-center gap-2 mt-3 flex-shrink-0',
shadow: '',
rounded: 'rounded-lg',
padding: 'p-3',
padding: 'p-4',
gap: 'gap-3',
icon: {
base: 'flex-shrink-0 w-5 h-5'
},
Expand Down

0 comments on commit 91511b9

Please sign in to comment.