mirror of
https://github.com/ArthurDanjou/ui.git
synced 2026-02-05 22:53:52 +01:00
feat(Alert): add icon & avatar slots (#1401)
Co-authored-by: gangan <44604921+shinGangan@users.noreply.github.com> Co-authored-by: Benjamin Canac <canacb1@gmail.com> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
This commit is contained in:
20
docs/components/content/examples/AlertExampleAvatar.vue
Normal file
20
docs/components/content/examples/AlertExampleAvatar.vue
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
<template>
|
||||||
|
<UAlert
|
||||||
|
title="Customize Alert Avatar"
|
||||||
|
description="Insert custom content into the avatar slot!"
|
||||||
|
:avatar="{
|
||||||
|
src: 'https://avatars.githubusercontent.com/u/739984?v=4',
|
||||||
|
alt: 'Avatar'
|
||||||
|
}"
|
||||||
|
>
|
||||||
|
<template #avatar="{ avatar }">
|
||||||
|
<UAvatar
|
||||||
|
v-bind="avatar"
|
||||||
|
chip-color="primary"
|
||||||
|
chip-text=""
|
||||||
|
chip-position="top-right"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
</UAlert>
|
||||||
|
</template>
|
||||||
|
|
||||||
10
docs/components/content/examples/AlertExampleIcon.vue
Normal file
10
docs/components/content/examples/AlertExampleIcon.vue
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
<template>
|
||||||
|
<UAlert title="Customize Alert Icon" description="Insert custom content into the icon slot!" icon="i-heroicons-command-line">
|
||||||
|
<template #icon="{ icon }">
|
||||||
|
<UBadge size="sm">
|
||||||
|
<UIcon :name="icon" />
|
||||||
|
</UBadge>
|
||||||
|
</template>
|
||||||
|
</UAlert>
|
||||||
|
</template>
|
||||||
|
|
||||||
@@ -163,6 +163,18 @@ This can be handy when you want to display HTML content. To achieve this, you ca
|
|||||||
|
|
||||||
:component-example{component="alert-example-html"}
|
:component-example{component="alert-example-html"}
|
||||||
|
|
||||||
|
### `icon`
|
||||||
|
|
||||||
|
Use the `#icon` slot to customize the displayed icon.
|
||||||
|
|
||||||
|
:component-example{component="alert-example-icon"}
|
||||||
|
|
||||||
|
### `avatar`
|
||||||
|
|
||||||
|
Use the `#avatar` slot to customize the displayable avatar.
|
||||||
|
|
||||||
|
:component-example{component="alert-example-avatar"}
|
||||||
|
|
||||||
## Props
|
## Props
|
||||||
|
|
||||||
:component-props
|
:component-props
|
||||||
|
|||||||
@@ -1,8 +1,12 @@
|
|||||||
<template>
|
<template>
|
||||||
<div :class="alertClass" v-bind="attrs">
|
<div :class="alertClass" v-bind="attrs">
|
||||||
<div class="flex" :class="[ui.gap, { '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" />
|
<slot name="icon" :icon="icon">
|
||||||
<UAvatar v-if="avatar" v-bind="{ size: ui.avatar.size, ...avatar }" :class="ui.avatar.base" />
|
<UIcon v-if="icon" :name="icon" :ui="ui.icon.base" />
|
||||||
|
</slot>
|
||||||
|
<slot name="avatar" :avatar="avatar">
|
||||||
|
<UAvatar v-if="avatar" v-bind="{ size: ui.avatar.size, ...avatar }" :class="ui.avatar.base" />
|
||||||
|
</slot>
|
||||||
|
|
||||||
<div :class="ui.inner">
|
<div :class="ui.inner">
|
||||||
<p v-if="(title || $slots.title)" :class="ui.title">
|
<p v-if="(title || $slots.title)" :class="ui.title">
|
||||||
|
|||||||
Reference in New Issue
Block a user