-
Notifications
You must be signed in to change notification settings - Fork 289
/
Copy pathnotification-image.tsx
33 lines (31 loc) · 1 KB
/
notification-image.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import { computed, defineComponent, toRefs } from 'vue';
import type { PropType } from 'vue';
import { NotificationType } from './notification-types';
import { SuccessIcon, WarningIcon, InfoIcon, ErrorIcon } from './notification-icons';
import { useNamespace } from '@devui/shared/utils';
export default defineComponent({
props: {
type: {
type: String as PropType<NotificationType>,
default: 'normal',
},
},
setup(props) {
const { type } = toRefs(props);
const ns = useNamespace('notification');
const classes = computed(() => ({
[ns.e('image')]: true,
[ns.em('image', type.value)]: true,
}));
return () => (
<span class={classes.value}>
{type.value &&
type.value !== 'normal' &&
((type.value === 'success' && <SuccessIcon />) ||
(type.value === 'info' && <InfoIcon />) ||
(type.value === 'warning' && <WarningIcon />) ||
(type.value === 'error' && <ErrorIcon />))}
</span>
);
},
});