2020-11-30 04:57:39 -05:00
|
|
|
/*
|
|
|
|
Copyright 2020 The Matrix.org Foundation C.I.C.
|
|
|
|
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
you may not use this file except in compliance with the License.
|
|
|
|
You may obtain a copy of the License at
|
|
|
|
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
See the License for the specific language governing permissions and
|
|
|
|
limitations under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
import {TemplateView} from "../utils/TemplateView.js";
|
2020-12-02 09:36:54 -05:00
|
|
|
import {ClientListView} from "../open/ClientListView.js";
|
|
|
|
import {ClientView} from "../open/ClientView.js";
|
2020-11-30 04:57:39 -05:00
|
|
|
|
|
|
|
export class PreviewView extends TemplateView {
|
2020-12-03 11:11:46 -05:00
|
|
|
render(t, vm) {
|
2020-12-04 09:59:50 -05:00
|
|
|
return t.div({className: "PreviewView"}, t.mapView(vm => vm.loading, loading => {
|
|
|
|
return loading ? new LoadingPreviewView(vm) : new LoadedPreviewView(vm);
|
|
|
|
}));
|
2020-12-03 11:11:46 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class LoadingPreviewView extends TemplateView {
|
|
|
|
render(t, vm) {
|
2020-12-04 09:59:50 -05:00
|
|
|
return t.div([
|
2020-12-03 11:11:46 -05:00
|
|
|
t.div({className: "avatarContainer"}, t.div({className: "avatar loading"}, t.div({className: "spinner"}))),
|
2020-12-03 11:42:46 -05:00
|
|
|
t.h1(vm => vm.name),
|
2020-12-03 11:11:46 -05:00
|
|
|
t.p({className: "identifier placeholder"}),
|
|
|
|
t.div({className: {memberCount: true, loading: true, hidden: !vm.hasMemberCount}}, t.p({className: "placeholder"})),
|
|
|
|
t.p({className: {topic: true, loading: true, hidden: !vm.hasTopic}}, [
|
|
|
|
t.div({className: "placeholder"}),
|
|
|
|
t.div({className: "placeholder"}),
|
|
|
|
t.div({className: "placeholder"}),
|
|
|
|
]),
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class LoadedPreviewView extends TemplateView {
|
2020-11-30 04:57:39 -05:00
|
|
|
render(t, vm) {
|
2021-04-12 09:10:02 -04:00
|
|
|
const avatar = t.map(vm => vm.avatarUrl, (avatarUrl, t) => {
|
2020-12-07 11:47:08 -05:00
|
|
|
if (avatarUrl) {
|
2021-04-12 09:10:02 -04:00
|
|
|
return t.img({className: "avatar", src: avatarUrl});
|
2020-12-07 11:47:08 -05:00
|
|
|
} else {
|
2021-04-12 09:10:02 -04:00
|
|
|
return t.div({className: "defaultAvatar"});
|
2020-12-07 11:47:08 -05:00
|
|
|
}
|
|
|
|
});
|
2020-12-04 09:59:50 -05:00
|
|
|
return t.div([
|
2020-12-07 11:47:08 -05:00
|
|
|
t.div({className: "avatarContainer"}, avatar),
|
2020-12-03 11:11:46 -05:00
|
|
|
t.h1(vm => vm.name),
|
|
|
|
t.p({className: {identifier: true, hidden: vm => !vm.identifier}}, vm => vm.identifier),
|
|
|
|
t.div({className: {memberCount: true, hidden: vm => !vm.memberCount}}, t.p([vm => vm.memberCount, " members"])),
|
|
|
|
t.p({className: {topic: true, hidden: vm => !vm.topic}}, [vm => vm.topic]),
|
2020-11-30 04:57:39 -05:00
|
|
|
]);
|
|
|
|
}
|
2020-12-01 06:04:11 -05:00
|
|
|
}
|