PluginProbe
The Innovative Form Builder – IvyForms / 0.3
The Innovative Form Builder – IvyForms v0.3
1.5.1 1.5 1.4.1 1.4 trunk 0.1.2 0.2 0.2.1 0.3 0.3.1 0.4 0.5 0.6 0.6.1 0.6.1-backup 0.6.1.1 0.7 0.8 0.8.1 0.8.2 0.9 0.9.1 1.0 1.1 1.1.1 All 27 releases
ivyforms / frontend / src / views / _components / message / ivyMessage.ts

ivyMessage.ts in The Innovative Form Builder – IvyForms 0.3, at frontend/src/views/_components/message/ivyMessage.ts

65 lines 1.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import { ElMessage } from 'element-plus'
2 import 'element-plus/es/components/message/style/css'
3 import { h } from 'vue'
4 import IvyIcon from '@/views/_components/icon/IvyIcon.vue'
5
6 const IvyMessage = (options) => {
7 const messageColors = {
8 success: 'var(--map-status-success-fill-0)',
9 warning: 'var(--map-status-warning-fill-0)',
10 error: 'var(--map-status-error-fill-0)',
11 info: 'var(--map-base-purple-fill-0)',
12 default: 'var(--map-base-dusk-fill-4)',
13 }
14
15 const messageTextColors = {
16 success: 'var(--primitive-white)',
17 warning: 'var(--primitive-white)',
18 error: 'var(--primitive-white)',
19 info: 'var(--primitive-white)',
20 default: 'var(--map-base-dusk-fill--4)',
21 }
22
23 const iconNames = {
24 success: 'check-circle',
25 warning: 'danger',
26 error: 'danger',
27 info: 'danger',
28 default: 'sticker',
29 }
30
31 const mergedOptions = {
32 ...options,
33 class: 'ivyforms-message regular-14 ivyforms-pr-8',
34 offset: 48,
35 icon: h(IvyIcon, {
36 name: iconNames[options.type] || 'sticker',
37 size: 's',
38 outerSize: '24px',
39 type: 'fill-duo',
40 color: 'var(--map-base-dusk-fill--4)',
41 }),
42 style: {
43 backgroundColor: messageColors[options.type] || messageColors.default,
44 borderColor: messageColors[options.type] || messageColors.default,
45 },
46 }
47
48 ElMessage(mergedOptions)
49
50 const style = document.createElement('style')
51 style.textContent = `
52 .ivyforms-message.el-message .el-message__content {
53 color: ${messageTextColors[options.type]};
54 }
55 .ivyforms-message .el-message__icon .ivyforms-icon svg {
56 width: 24px;
57 height: 24px;
58 fill: ${messageTextColors[options.type]};
59 }
60 `
61 document.head.appendChild(style)
62 }
63
64 export default IvyMessage
65