mirror of
https://github.com/element-plus/element-plus.git
synced 2025-02-11 11:39:43 +08:00
refactor(components): [alert] introduce hasDesc helper (#19085)
refactor: introduce hasDesc helper
This commit is contained in:
parent
e9f3fdd529
commit
ea3cfc97c7
@ -5,18 +5,21 @@
|
||||
:class="[ns.b(), ns.m(type), ns.is('center', center), ns.is(effect)]"
|
||||
role="alert"
|
||||
>
|
||||
<el-icon v-if="showIcon && iconComponent" :class="iconClass">
|
||||
<el-icon
|
||||
v-if="showIcon && iconComponent"
|
||||
:class="[ns.e('icon'), { [ns.is('big')]: hasDesc }]"
|
||||
>
|
||||
<component :is="iconComponent" />
|
||||
</el-icon>
|
||||
|
||||
<div :class="ns.e('content')">
|
||||
<span
|
||||
v-if="title || $slots.title"
|
||||
:class="[ns.e('title'), withDescription]"
|
||||
:class="[ns.e('title'), { 'with-description': hasDesc }]"
|
||||
>
|
||||
<slot name="title">{{ title }}</slot>
|
||||
</span>
|
||||
<p v-if="$slots.default || description" :class="ns.e('description')">
|
||||
<p v-if="hasDesc" :class="ns.e('description')">
|
||||
<slot>
|
||||
{{ description }}
|
||||
</slot>
|
||||
@ -60,14 +63,7 @@ const visible = ref(true)
|
||||
|
||||
const iconComponent = computed(() => TypeComponentsMap[props.type])
|
||||
|
||||
const iconClass = computed(() => [
|
||||
ns.e('icon'),
|
||||
{ [ns.is('big')]: !!props.description || !!slots.default },
|
||||
])
|
||||
|
||||
const withDescription = computed(() => {
|
||||
return { 'with-description': props.description || slots.default }
|
||||
})
|
||||
const hasDesc = computed(() => !!(props.description || slots.default))
|
||||
|
||||
const close = (evt: MouseEvent) => {
|
||||
visible.value = false
|
||||
|
Loading…
Reference in New Issue
Block a user