* Move avatar to new compound implementation * Make space avatars square * Remove reference to the avatar initial CSS class * remove references to mx_BaseAvatar_image * Fixe test suites * Fix accessbility violations * Add ConfirmUserActionDialog test * Fix tests * Add FacePile test * Fix items clipping in members list * Fix user info avatar sizing * Fix tests
56 lines
2.3 KiB
TypeScript
56 lines
2.3 KiB
TypeScript
/*
|
|
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 React, { ComponentProps } from "react";
|
|
import { IWidget } from "matrix-widget-api";
|
|
import classNames from "classnames";
|
|
|
|
import { IApp, isAppWidget } from "../../../stores/WidgetStore";
|
|
import BaseAvatar, { BaseAvatarType } from "./BaseAvatar";
|
|
import { mediaFromMxc } from "../../../customisations/Media";
|
|
|
|
interface IProps extends Omit<ComponentProps<BaseAvatarType>, "name" | "url" | "urls"> {
|
|
app: IApp | IWidget;
|
|
size: string;
|
|
}
|
|
|
|
const WidgetAvatar: React.FC<IProps> = ({ app, className, size = "20px", ...props }) => {
|
|
let iconUrls = [require("../../../../res/img/element-icons/room/default_app.svg").default];
|
|
// heuristics for some better icons until Widgets support their own icons
|
|
if (app.type.includes("jitsi")) {
|
|
iconUrls = [require("../../../../res/img/element-icons/room/default_video.svg").default];
|
|
} else if (app.type.includes("meeting") || app.type.includes("calendar")) {
|
|
iconUrls = [require("../../../../res/img/element-icons/room/default_cal.svg").default];
|
|
} else if (app.type.includes("pad") || app.type.includes("doc") || app.type.includes("calc")) {
|
|
iconUrls = [require("../../../../res/img/element-icons/room/default_doc.svg").default];
|
|
} else if (app.type.includes("clock")) {
|
|
iconUrls = [require("../../../../res/img/element-icons/room/default_clock.svg").default];
|
|
}
|
|
|
|
return (
|
|
<BaseAvatar
|
|
{...props}
|
|
name={app.id}
|
|
className={classNames("mx_WidgetAvatar", className)}
|
|
// MSC2765
|
|
url={isAppWidget(app) && app.avatar_url ? mediaFromMxc(app.avatar_url).getSquareThumbnailHttp(20) : null}
|
|
urls={iconUrls}
|
|
size={size}
|
|
/>
|
|
);
|
|
};
|
|
|
|
export default WidgetAvatar;
|