{" "}
+ >
+ );
+ if (location.hash) {
+ console.log(location.hash);
+ if (location.hash.startsWith("#/")) {
+ page = ;
+ } else {
+ console.log("asdfadf");
+ page = (
+
+ Links should be in the format {location.host}/#/{"<"}
+ matrix-resource-identifier{">"}
+
+ );
+ }
+ }
+
return (
-
-
+ {page}
diff --git a/src/clients/Element.io.ts b/src/clients/Element.io.ts
new file mode 100644
index 0000000..015c31d
--- /dev/null
+++ b/src/clients/Element.io.ts
@@ -0,0 +1,53 @@
+/*
+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 { LinkedClient, Maturity, ClientKind } from "./types";
+import { LinkKind } from "../parser/types";
+import logo from "./element.svg";
+
+const Element: LinkedClient = {
+ kind: ClientKind.LINKED_CLIENT,
+ name: "Element",
+ author: "Element",
+ logo: logo,
+ homepage: "https://element.io",
+ maturity: Maturity.STABLE,
+ description: "Fully-featured Matrix client for the Web",
+ tags: [],
+ toUrl: (link) => {
+ switch (link.kind) {
+ case LinkKind.Alias:
+ case LinkKind.RoomId:
+ return new URL(
+ `https://app.element.io/#/room/${link.identifier}`
+ );
+ case LinkKind.UserId:
+ return new URL(
+ `https://app.element.io/#/user/${link.identifier}`
+ );
+ case LinkKind.Permalink:
+ return new URL(
+ `https://app.element.io/#/room/${link.identifier}`
+ );
+ case LinkKind.GroupId:
+ return new URL(
+ `https://app.element.io/#/group/${link.identifier}`
+ );
+ }
+ },
+};
+
+export default Element;
diff --git a/src/clients/element.svg b/src/clients/element.svg
new file mode 100644
index 0000000..95ecfa1
--- /dev/null
+++ b/src/clients/element.svg
@@ -0,0 +1,6 @@
+
diff --git a/src/clients/index.ts b/src/clients/index.ts
new file mode 100644
index 0000000..ac67755
--- /dev/null
+++ b/src/clients/index.ts
@@ -0,0 +1,29 @@
+/*
+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 { Client } from "./types";
+
+import Element from "./Element.io";
+
+/*
+ * All the supported clients of matrix.to
+ */
+const clients: Client[] = [Element];
+
+/*
+ * All the supported clients of matrix.to
+ */
+export default clients;
diff --git a/src/clients/types.ts b/src/clients/types.ts
new file mode 100644
index 0000000..4d21ac4
--- /dev/null
+++ b/src/clients/types.ts
@@ -0,0 +1,82 @@
+/*
+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 { SafeLink } from "../parser/types";
+
+/*
+ * A collection of descriptive tags that can be added to
+ * a clients description.
+ */
+export enum Tag {
+ IOS = "IOS",
+ ANDROID = "ANDROID",
+ DESKTOP = "DESKTOP",
+}
+
+/*
+ * A collection of states used for describing a clients maturity.
+ */
+export enum Maturity {
+ ALPHA = "ALPHA",
+ LATE_ALPHA = "LATE ALPHA",
+ BETA = "BETA",
+ LATE_BETA = "LATE_BETA",
+ STABLE = "STABLE",
+}
+
+/*
+ * Used for constructing the discriminated union of all client types.
+ */
+export enum ClientKind {
+ LINKED_CLIENT = "LINKED_CLIENT",
+ TEXT_CLIENT = "TEXT_CLIENT",
+}
+
+/*
+ * The descriptive details of a client
+ */
+export interface ClientDescription {
+ name: string;
+ author: string;
+ homepage: string;
+ logo: string;
+ description: string;
+ tags: Tag[];
+ maturity: Maturity;
+}
+
+/*
+ * A client which can be opened using a link with the matrix resource.
+ */
+export interface LinkedClient extends ClientDescription {
+ kind: ClientKind.LINKED_CLIENT;
+ toUrl(parsedLink: SafeLink): URL;
+}
+
+/*
+ * A client which provides isntructions for how to access the descired
+ * resource.
+ */
+export interface TextClient extends ClientDescription {
+ kind: ClientKind.TEXT_CLIENT;
+ toInviteString(parsedLink: SafeLink): string;
+}
+
+/*
+ * A description for a client as well as a method for converting matrix.to
+ * links to the client's specific representation.
+ */
+export type Client = LinkedClient | TextClient;
diff --git a/src/components/Avatar.stories.tsx b/src/components/Avatar.stories.tsx
index d586c6f..2a8de36 100644
--- a/src/components/Avatar.stories.tsx
+++ b/src/components/Avatar.stories.tsx
@@ -35,5 +35,6 @@ export const Default: React.FC<{}> = () => (
avatar_url: "mxc://matrix.org/EqMZYbAYhREvHXvYFyfxOlkf",
displayname: "Jorik Schellekens",
}}
+ userId="@jorik:matrix.org"
/>
);
diff --git a/src/components/Avatar.tsx b/src/components/Avatar.tsx
index 1a73b9f..5651cc6 100644
--- a/src/components/Avatar.tsx
+++ b/src/components/Avatar.tsx
@@ -16,9 +16,9 @@ limitations under the License.
import React, { useEffect, useState } from "react";
import classNames from "classnames";
-import { convertMXCtoMediaQuery } from "cypher";
-import { Room } from "cypher/src/schemas/PublicRoomsSchema";
-import { User } from "cypher/src/schemas/UserSchema";
+import { Room, User } from "matrix-cypher";
+
+import { convertMXCtoMediaQuery } from "../utils/cypher-wrapper";
import logo from "../imgs/matrix-logo.svg";
import "./Avatar.scss";
@@ -38,7 +38,7 @@ const Avatar: React.FC = ({ className, avatarUrl, label }: IProps) => {
return (
setSrc(logo)}
+ onError={(): void => setSrc(logo)}
alt={label}
className={classNames("avatar", className)}
/>
@@ -47,18 +47,24 @@ const Avatar: React.FC = ({ className, avatarUrl, label }: IProps) => {
interface IPropsUserAvatar {
user: User;
+ userId: string;
}
export const UserAvatar: React.FC = ({
user,
+ userId,
}: IPropsUserAvatar) => (
);
@@ -74,7 +80,7 @@ export const RoomAvatar: React.FC = ({
room.avatar_url
? convertMXCtoMediaQuery(
// TODO: replace with correct client
- "matrix.org",
+ "https://matrix.org",
room.avatar_url
)
: ""
diff --git a/src/components/Button.stories.tsx b/src/components/Button.stories.tsx
index 2699e27..2514b6d 100644
--- a/src/components/Button.stories.tsx
+++ b/src/components/Button.stories.tsx
@@ -22,7 +22,7 @@ import Button from "./Button";
export default { title: "Button" };
-export const WithText = () => (
+export const WithText: React.FC = () => (
diff --git a/src/components/CreateLinkTile.stories.tsx b/src/components/CreateLinkTile.stories.tsx
index cc71fc3..f247506 100644
--- a/src/components/CreateLinkTile.stories.tsx
+++ b/src/components/CreateLinkTile.stories.tsx
@@ -29,4 +29,4 @@ export default {
},
};
-export const Default = () => ;
+export const Default: React.FC = () => ;
diff --git a/src/components/CreateLinkTile.tsx b/src/components/CreateLinkTile.tsx
index aed0f60..4d557e7 100644
--- a/src/components/CreateLinkTile.tsx
+++ b/src/components/CreateLinkTile.tsx
@@ -28,7 +28,9 @@ interface ILinkNotCreatedTileProps {
setLink: React.Dispatch>;
}
-const LinkNotCreatedTile = (props: ILinkNotCreatedTileProps) => {
+const LinkNotCreatedTile: React.FC = (
+ props: ILinkNotCreatedTileProps
+) => {
return (