-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathskeleton-chat.js
More file actions
123 lines (116 loc) · 2.78 KB
/
skeleton-chat.js
File metadata and controls
123 lines (116 loc) · 2.78 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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
/**
@license
Copyright (c) 2018 FabricElements. All rights reserved.
@group Skeleton Chat
@demo demo/index.html
*/
import {html, PolymerElement} from '@polymer/polymer/polymer-element.js';
import '@polymer/iron-flex-layout/iron-flex-layout.js';
import '@polymer/app-route/app-location.js';
import '@polymer/app-route/app-route.js';
import './chat-mixin/chat-mixin.js';
import './skeleton-chat-groups/skeleton-chat-groups.js';
import './skeleton-chat-box/skeleton-chat-box.js';
/**
* `skeleton-chat`
*
*
* @customElement
* @polymer
* @appliesMixin Fabric.ChatMixin
* @demo demo/index.html
*/
class SkeletonChat extends Fabric.ChatMixin(PolymerElement) {
/**
* @return {!HTMLTemplateElement}
*/
static get template() {
return html`
<style>
:host {
display: block;
position: relative;
height: 100%;
overflow: hidden;
@apply --layout-fit;
}
skeleton-chat-box {
z-index: 100;
transition: all ease-in-out 300ms;
transform: translateY(120%);
top: 100%;
}
skeleton-chat-box[opened] {
transform: translateY(0);
height: 100%;
top: 0;
}
</style>
<app-location route="{{route}}"></app-location>
<app-route route="{{route}}" pattern$="/[[routeChat]]" tail="{{chatRouteTail}}"></app-route>
<app-route route="{{chatRouteTail}}" pattern="/:id" active="{{chatBoxActive}}" data="{{subrouteData}}"></app-route>
<skeleton-chat-groups link-back$="[[linkBack]]"></skeleton-chat-groups>
<skeleton-chat-box fullbleed group$="[[subrouteData.id]]" opened$="[[chatBoxActive]]"></skeleton-chat-box>
`;
}
/**
* @return {string}
*/
static get is() {
return 'skeleton-chat';
}
/**
* @return {object}
*/
static get properties() {
return {
/** Route */
route: {
type: Object,
},
/** Route data */
routeData: {
type: Object,
value: {
page: null,
},
},
subrouteData: {
type: Object,
value: {
id: null,
},
},
chatBoxActive: {
type: Boolean,
value: false,
notify: true,
},
linkBack: {
type: String,
value: '/',
},
routeChat: {
type: String,
value: 'chat',
},
routeLeave: {
type: String,
value: null,
},
};
}
/**
* Connected callback
*/
connectedCallback() {
super.connectedCallback();
this.addEventListener('close-chat', () => {
this.routeData.page = this.routeLeave ? this.routeLeave : this.routeChat;
this.notifyPath('routeData');
this.notifyPath('routeData.page');
this.chatBoxActive = false;
}, true);
}
}
window.customElements.define(SkeletonChat.is, SkeletonChat);