forked from youzan/vant
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNotify.tsx
More file actions
67 lines (60 loc) · 1.38 KB
/
Notify.tsx
File metadata and controls
67 lines (60 loc) · 1.38 KB
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import { createNamespace } from '../utils';
import { RED, WHITE } from '../utils/constant';
import { inherit } from '../utils/functional';
import { PopupMixin } from '../mixins/popup';
import Popup from '../popup';
// Types
import { CreateElement, RenderContext } from 'vue/types';
import { DefaultSlots } from '../utils/types';
import { PopupMixinProps } from '../mixins/popup/type';
export type NotifyProps = PopupMixinProps & {
color: string;
message: string | number;
duration: number;
className?: any;
background: string;
};
const [createComponent, bem] = createNamespace('notify');
function Notify(
h: CreateElement,
props: NotifyProps,
slots: DefaultSlots,
ctx: RenderContext<NotifyProps>
) {
const style = {
color: props.color,
background: props.background
};
return (
<Popup
value={props.value}
style={style}
position="top"
overlay={false}
lockScroll={false}
class={[bem(), props.className]}
{...inherit(ctx, true)}
>
{props.message}
</Popup>
);
}
Notify.props = {
...PopupMixin.props,
className: null as any,
message: [Number, String],
getContainer: [String, Function],
color: {
type: String,
default: WHITE
},
background: {
type: String,
default: RED
},
duration: {
type: Number,
default: 3000
}
};
export default createComponent<NotifyProps>(Notify);