mirror of
https://github.com/element-plus/element-plus.git
synced 2025-12-19 09:09:40 +08:00
* feat(components): [message] add `placement` option & method * fix: resolve test hanging issue caused by reactive circular dependency * test: add test * feat: add placement `top-left/top-right/bottom-left/bottom-right` * refactor: split large normalizeOptions function * docs: adjust description text * chore: remove unused height expose * refactor: simpify code * style: opt-in center style & simplified animations * style: replace :not(.center) with :is(.left,.right) for more explicit * feat: add `placement` to `config-provider` * fix: fix test warning when placement is undefined * refactor: remove useless style & simpify types * fix: avoid circular dependency * chore: types related * Update docs/examples/config-provider/message.vue Co-authored-by: Noblet Ouways <91417411+Dsaquel@users.noreply.github.com> * Update packages/components/config-provider/__tests__/config-provider.test.tsx Co-authored-by: Noblet Ouways <91417411+Dsaquel@users.noreply.github.com> * chore: make typecheck happy & format * style: add top/bottom transition * chore: format --------- Co-authored-by: zhixiaotong <947803089@qq.com> Co-authored-by: Noblet Ouways <91417411+Dsaquel@users.noreply.github.com> Co-authored-by: Dsaquel <291874700n@gmail.com>
72 lines
1.7 KiB
Vue
72 lines
1.7 KiB
Vue
<template>
|
|
<div class="flex flex-wrap gap-1">
|
|
<el-button class="!ml-0" :plain="true" @click="openMsg()"> Top </el-button>
|
|
<el-button class="!ml-0" :plain="true" @click="openMsg('top-left')">
|
|
Top Left
|
|
</el-button>
|
|
<el-button class="!ml-0" :plain="true" @click="openMsg('top-right')">
|
|
Top Right
|
|
</el-button>
|
|
<el-button class="!ml-0" :plain="true" @click="openMsg('bottom')">
|
|
Bottom
|
|
</el-button>
|
|
<el-button class="!ml-0" :plain="true" @click="openMsg('bottom-left')">
|
|
Bottom Left
|
|
</el-button>
|
|
<el-button class="!ml-0" :plain="true" @click="openMsg('bottom-right')">
|
|
Bottom Right
|
|
</el-button>
|
|
</div>
|
|
</template>
|
|
|
|
<script lang="ts" setup>
|
|
import { ElMessage } from 'element-plus'
|
|
|
|
import type { MessagePlacement, MessageType } from 'element-plus'
|
|
|
|
let topCount = 0
|
|
let bottomCount = 0
|
|
let topLeftCount = 0
|
|
let topRightCount = 0
|
|
let bottomLeftCount = 0
|
|
let bottomRightCount = 0
|
|
|
|
const openMsg = (placement: MessagePlacement = 'top') => {
|
|
let count = 0
|
|
let type: MessageType = 'success'
|
|
|
|
switch (placement) {
|
|
case 'top':
|
|
count = ++topCount
|
|
type = 'success'
|
|
break
|
|
case 'bottom':
|
|
count = ++bottomCount
|
|
type = 'warning'
|
|
break
|
|
case 'top-left':
|
|
count = ++topLeftCount
|
|
type = 'info'
|
|
break
|
|
case 'top-right':
|
|
count = ++topRightCount
|
|
type = 'primary'
|
|
break
|
|
case 'bottom-left':
|
|
count = ++bottomLeftCount
|
|
type = 'warning'
|
|
break
|
|
case 'bottom-right':
|
|
count = ++bottomRightCount
|
|
type = 'error'
|
|
break
|
|
}
|
|
|
|
ElMessage({
|
|
message: `This is a message from the ${placement} ${count}`,
|
|
type,
|
|
placement,
|
|
})
|
|
}
|
|
</script>
|