Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
E
Element
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
CI / CD Analytics
Repository Analytics
Value Stream Analytics
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
林焕东
Element
Commits
2719667f
Commit
2719667f
authored
Jan 04, 2017
by
qingwei.li
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Notification: supports VNode, #1885
parent
661dc090
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
73 additions
and
26 deletions
+73
-26
examples/docs/en-US/notification.md
examples/docs/en-US/notification.md
+9
-5
examples/docs/zh-CN/notification.md
examples/docs/zh-CN/notification.md
+8
-4
packages/message-box/src/main.vue
packages/message-box/src/main.vue
+1
-1
packages/notification/src/main.js
packages/notification/src/main.js
+7
-1
packages/notification/src/main.vue
packages/notification/src/main.vue
+2
-2
packages/theme-default/src/notification.css
packages/theme-default/src/notification.css
+13
-11
src/utils/vdom.js
src/utils/vdom.js
+6
-0
test/unit/specs/notification.spec.js
test/unit/specs/notification.spec.js
+27
-2
No files found.
examples/docs/en-US/notification.md
View file @
2719667f
...
...
@@ -2,9 +2,11 @@
module.exports = {
methods: {
open() {
const h = this.$createElement;
this.$notify({
title: 'Title',
message:
'This is a reminder'
message:
h('p', { style: 'color: red' }, 'This is a reminder')
});
},
...
...
@@ -87,9 +89,11 @@ Displays a global notification message at the upper right corner of the page.
export
default
{
methods
:
{
open
()
{
const
h
=
this
.
$createElement
;
this
.
$notify
({
title
:
'
Title
'
,
message
:
'
This is a reminder
'
message
:
h
(
'
p
'
,
{
style
:
'
color: red
'
},
'
This is a reminder
'
)
});
},
...
...
@@ -220,7 +224,7 @@ In this case you should call `Notification(options)`. We have also registered me
| Attribute | Description | Type | Accepted Values | Default |
|---------- |-------------- |---------- |-------------------------------- |-------- |
| title | title | string | — | — |
| message | description text | string | — | — |
| message | description text | string
/Vue.VNode
| — | — |
| type | notification type | string | success/warning/info/error | — |
| iconClass | custom icon's class. It will be overridden by
`type`
| string | — | — |
| customClass | custom class name for Notification | string | — | — |
...
...
examples/docs/zh-CN/notification.md
View file @
2719667f
...
...
@@ -2,9 +2,11 @@
module.exports = {
methods: {
open() {
const h = this.$createElement;
this.$notify({
title: '标题名称',
message:
'这是提示文案这是提示文案这是提示文案这是提示文案这是提示文案这是提示文案这是提示文案这是提示文案'
message:
h('p', { style: 'color: red'}, '这是提示文案这是提示文案这是提示文案这是提示文案这是提示文案这是提示文案这是提示文案这是提示文案')
});
},
...
...
@@ -88,9 +90,11 @@
export
default
{
methods
:
{
open
()
{
const
h
=
this
.
$createElement
;
this
.
$notify
({
title
:
'
标题名称
'
,
message
:
'
这是提示文案这是提示文案这是提示文案这是提示文案这是提示文案这是提示文案这是提示文案这是提示文案
'
message
:
h
(
'
p
'
,
{
style
:
'
color: red
'
},
'
这是提示文案这是提示文案这是提示文案这是提示文案这是提示文案这是提示文案这是提示文案这是提示文案
'
)
});
},
...
...
@@ -222,7 +226,7 @@ import { Notification } from 'element-ui';
| 参数 | 说明 | 类型 | 可选值 | 默认值 |
|---------- |-------------- |---------- |-------------------------------- |-------- |
| title | 标题 | string | — | — |
| message | 说明文字 | string | — | — |
| message | 说明文字 | string
/Vue.VNode
| — | — |
| type | 主题样式,如果不在可选值内将被忽略 | string | success/warning/info/error | — |
| iconClass | 自定义图标的类名。若设置了
`type`
,则
`iconClass`
会被覆盖 | string | — | — |
| customClass | 自定义类名 | string | — | — |
...
...
packages/message-box/src/main.vue
View file @
2719667f
...
...
@@ -8,7 +8,7 @@
</div>
<div
class=
"el-message-box__content"
v-if=
"message !== ''"
>
<div
class=
"el-message-box__status"
:class=
"[ typeClass ]"
></div>
<div
class=
"el-message-box__message"
:style=
"
{ 'margin-left': typeClass ? '50px' : '0' }">
<p>
{{
message
}}
</p>
</div>
<div
class=
"el-message-box__message"
:style=
"
{ 'margin-left': typeClass ? '50px' : '0' }">
{{
message
}}
</div>
<div
class=
"el-message-box__input"
v-show=
"showInput"
>
<el-input
v-model=
"inputValue"
:placeholder=
"inputPlaceholder"
ref=
"input"
></el-input>
<div
class=
"el-message-box__errormsg"
:style=
"
{ visibility: !!editorErrorMessage ? 'visible' : 'hidden' }">
{{
editorErrorMessage
}}
</div>
...
...
packages/notification/src/main.js
View file @
2719667f
import
Vue
from
'
vue
'
;
import
{
PopupManager
}
from
'
element-ui/src/utils/popup
'
;
import
{
isVNode
}
from
'
element-ui/src/utils/vdom
'
;
let
NotificationConstructor
=
Vue
.
extend
(
require
(
'
./main.vue
'
));
let
instance
;
...
...
@@ -19,6 +20,11 @@ var Notification = function(options) {
instance
=
new
NotificationConstructor
({
data
:
options
});
if
(
isVNode
(
options
.
message
))
{
instance
.
$slots
.
default
=
[
options
.
message
];
options
.
message
=
''
;
}
instance
.
id
=
id
;
instance
.
vm
=
instance
.
$mount
();
document
.
body
.
appendChild
(
instance
.
vm
.
$el
);
...
...
@@ -39,7 +45,7 @@ var Notification = function(options) {
[
'
success
'
,
'
warning
'
,
'
info
'
,
'
error
'
].
forEach
(
type
=>
{
Notification
[
type
]
=
options
=>
{
if
(
typeof
options
===
'
string
'
)
{
if
(
typeof
options
===
'
string
'
||
isVNode
(
options
)
)
{
options
=
{
message
:
options
};
...
...
packages/notification/src/main.vue
View file @
2719667f
...
...
@@ -13,8 +13,8 @@
v-if=
"type || iconClass"
>
</i>
<div
class=
"el-notification__group"
:class=
"
{ 'is-with-icon': typeClass || iconClass }">
<
span>
{{
title
}}
</span
>
<
p>
{{
message
}}
</p
>
<
h2
class=
"el-notification__title"
v-text=
"title"
></h2
>
<
div
class=
"el-notification__content"
><slot>
{{
message
}}
</slot></div
>
<div
class=
"el-notification__closeBtn el-icon-close"
@
click=
"close"
></div>
</div>
</div>
...
...
packages/theme-default/src/notification.css
View file @
2719667f
...
...
@@ -20,19 +20,21 @@
@when
with-icon
{
margin-left
:
55px
;
}
&
span
{
}
@e
title
{
font-weight
:
normal
;
font-size
:
var
(
--notification-title-font-size
);
color
:
var
(
--notification-title-color
);
}
&
p
{
@e
content
{
font-size
:
var
(
--notification-font-size
);
line-height
:
21px
;
margin
:
10px
0
0
0
;
color
:
var
(
--notification-color
);
text-align
:
justify
;
}
}
@e
icon
{
size
:
var
(
--notification-icon-size
);
...
...
src/utils/vdom.js
0 → 100644
View file @
2719667f
import
Vue
from
'
vue
'
;
export
function
isVNode
(
node
)
{
if
(
!
node
||
typeof
node
!==
'
object
'
)
return
false
;
return
Vue
.
util
.
hasOwn
(
node
,
'
tag
'
)
&&
Vue
.
util
.
hasOwn
(
node
,
'
componentOptions
'
);
};
test/unit/specs/notification.spec.js
View file @
2719667f
import
Vue
from
'
vue
'
;
import
{
triggerEvent
}
from
'
../util
'
;
import
Notification
from
'
packages/notification
'
;
...
...
@@ -45,13 +46,37 @@ describe('Notification', () => {
duration
:
0
});
const
group
=
document
.
querySelector
(
'
.el-notification__group
'
);
const
title
=
group
.
querySelector
(
'
span
'
);
const
message
=
group
.
querySelector
(
'
p
'
);
const
title
=
group
.
querySelector
(
'
.el-notification__title
'
);
const
message
=
group
.
querySelector
(
'
.el-notification__content
'
);
expect
(
document
.
querySelector
(
'
.el-notification
'
)).
to
.
exist
;
expect
(
title
.
textContent
).
to
.
equal
(
'
狮子
'
);
expect
(
message
.
textContent
).
to
.
equal
(
'
狮鹫
'
);
});
it
(
'
create by vnode
'
,
()
=>
{
const
fakeVM
=
new
Vue
();
const
h
=
fakeVM
.
$createElement
;
Notification
({
message
:
h
(
'
p
'
,
{
style
:
{
color
:
'
red
'
}
},
'
大美兴,川普王
'
)
});
const
group
=
document
.
querySelector
(
'
.el-notification__group
'
);
const
message
=
group
.
querySelector
(
'
.el-notification__content
'
);
expect
(
message
.
innerHTML
).
to
.
equal
(
'
<p style="color: red;">大美兴,川普王</p>
'
);
});
it
(
'
alias by vnode
'
,
()
=>
{
const
fakeVM
=
new
Vue
();
const
h
=
fakeVM
.
$createElement
;
Notification
.
error
(
h
(
'
p
'
,
{
style
:
{
color
:
'
green
'
}
},
'
+1s
'
));
const
group
=
document
.
querySelector
(
'
.el-notification__group
'
);
const
message
=
group
.
querySelector
(
'
.el-notification__content
'
);
expect
(
message
.
innerHTML
).
to
.
equal
(
'
<p style="color: green;">+1s</p>
'
);
});
it
(
'
invoke with type
'
,
()
=>
{
Notification
.
success
(
'
太阳之子
'
);
expect
(
document
.
querySelector
(
'
.el-notification
'
).
__vue__
.
type
).
to
.
equal
(
'
success
'
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment