From 63091e7b66eb2d1f50ccaecd1c1f819226f082bb Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Thu, 24 Mar 2022 23:56:09 -0600 Subject: [PATCH] Step 10.2: Move matrix logo replacement into react-sdk --- res/img/matrix.svg | 153 ++++++++++++++++++ src/components/structures/EmbeddedPage.tsx | 3 +- src/components/structures/static-page-vars.ts | 26 +++ src/components/views/auth/Welcome.tsx | 2 + 4 files changed, 182 insertions(+), 2 deletions(-) create mode 100644 res/img/matrix.svg create mode 100644 src/components/structures/static-page-vars.ts diff --git a/res/img/matrix.svg b/res/img/matrix.svg new file mode 100644 index 0000000000..13adcab25a --- /dev/null +++ b/res/img/matrix.svg @@ -0,0 +1,153 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/components/structures/EmbeddedPage.tsx b/src/components/structures/EmbeddedPage.tsx index 9ba250c985..2053140ba4 100644 --- a/src/components/structures/EmbeddedPage.tsx +++ b/src/components/structures/EmbeddedPage.tsx @@ -57,8 +57,7 @@ export default class EmbeddedPage extends React.PureComponent { }; } - protected translate(s: string): string { - // default implementation - skins may wish to extend this + private translate(s: string): string { return sanitizeHtml(_t(s)); } diff --git a/src/components/structures/static-page-vars.ts b/src/components/structures/static-page-vars.ts new file mode 100644 index 0000000000..801eeb155a --- /dev/null +++ b/src/components/structures/static-page-vars.ts @@ -0,0 +1,26 @@ +/* +Copyright 2022 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. +*/ + +// We're importing via require specifically so the svg becomes a URI rather than a DOM element. +// eslint-disable-next-line @typescript-eslint/no-var-requires +const matrixSvg = require('../../../res/img/matrix.svg').default; + +/** + * Intended to replace $matrixLogo in the welcome page. + */ +export const MATRIX_LOGO_HTML = ` + Matrix +`; diff --git a/src/components/views/auth/Welcome.tsx b/src/components/views/auth/Welcome.tsx index e76dabb4db..dfe2c10782 100644 --- a/src/components/views/auth/Welcome.tsx +++ b/src/components/views/auth/Welcome.tsx @@ -24,6 +24,7 @@ import SettingsStore from "../../../settings/SettingsStore"; import { UIFeature } from "../../../settings/UIFeature"; import LanguageSelector from "./LanguageSelector"; import EmbeddedPage from "../../structures/EmbeddedPage"; +import { MATRIX_LOGO_HTML } from "../../structures/static-page-vars"; // translatable strings for Welcome pages _td("Sign in with SSO"); @@ -54,6 +55,7 @@ export default class Welcome extends React.PureComponent { replaceMap={{ "$riot:ssoUrl": "#/start_sso", "$riot:casUrl": "#/start_cas", + "$matrixLogo": MATRIX_LOGO_HTML, }} />