Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

replace all require(.svg) with esm import #7948

Merged
merged 1 commit into from
Mar 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/components/structures/FileDropTarget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ limitations under the License.
import React, { useEffect, useState } from "react";

import { _t } from "../../languageHandler";
import FileDropSvg from '../../../res/img/upload-big.svg';

interface IProps {
parent: HTMLElement;
Expand Down Expand Up @@ -109,7 +110,7 @@ const FileDropTarget: React.FC<IProps> = ({ parent, onFileDrop }) => {

if (state.dragging) {
return <div className="mx_FileDropTarget">
<img src={require("../../../res/img/upload-big.svg")} className="mx_FileDropTarget_image" alt="" />
<img src={FileDropSvg} className="mx_FileDropTarget_image" alt="" />
{ _t("Drop file here to upload") }
</div>;
}
Expand Down
22 changes: 14 additions & 8 deletions src/components/structures/GroupView.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@ import { createSpaceFromCommunity } from "../../utils/space";
import { Action } from "../../dispatcher/actions";
import { RightPanelPhases } from "../../stores/right-panel/RightPanelStorePhases";
import { UPDATE_EVENT } from "../../stores/AsyncStore";
import CreateRoomSvg from '../../../res/img/icons-create-room.svg';
import CancelSmallSvg from '../../../res/img/cancel-small.svg';
import CancelSvg from '../../../res/img/cancel.svg';
import ExternalLinkSvg from '../../../res/img/external-link.svg';
import AddRoomSvg from '../../../res/img/icons-room-add.svg';
import CameraSvg from '../../../res/img/camera.svg';

const LONG_DESC_PLACEHOLDER = _td(
`<h1>HTML for your community's page</h1>
Expand Down Expand Up @@ -135,7 +141,7 @@ class CategoryRoomList extends React.Component {
(<AccessibleButton className="mx_GroupView_featuredThings_addButton"
onClick={this.onAddRoomsToSummaryClicked}
>
<img src={require("../../../res/img/icons-create-room.svg")} width="64" height="64" />
<img src={CreateRoomSvg} width="64" height="64" />
<div className="mx_GroupView_featuredThings_addButton_label">
{ _t('Add a Room') }
</div>
Expand Down Expand Up @@ -235,7 +241,7 @@ class FeaturedRoom extends React.Component {
const deleteButton = this.props.editing ?
<img
className="mx_GroupView_featuredThing_deleteButton"
src={require("../../../res/img/cancel-small.svg")}
src={CancelSmallSvg}
width="14"
height="14"
alt="Delete"
Expand Down Expand Up @@ -306,7 +312,7 @@ class RoleUserList extends React.Component {
render() {
const addButton = this.props.editing ?
(<AccessibleButton className="mx_GroupView_featuredThings_addButton" onClick={this.onAddUsersClicked}>
<img src={require("../../../res/img/icons-create-room.svg")} width="64" height="64" />
<img src={CreateRoomSvg} width="64" height="64" />
<div className="mx_GroupView_featuredThings_addButton_label">
{ _t('Add a User') }
</div>
Expand Down Expand Up @@ -386,7 +392,7 @@ class FeaturedUser extends React.Component {
const deleteButton = this.props.editing ?
<img
className="mx_GroupView_featuredThing_deleteButton"
src={require("../../../res/img/cancel-small.svg")}
src={CancelSmallSvg}
width="14"
height="14"
alt="Delete"
Expand Down Expand Up @@ -844,7 +850,7 @@ export default class GroupView extends React.Component {
},
) }
<a href={hostingSignupLink} target="_blank" rel="noreferrer noopener">
<img src={require("../../../res/img/external-link.svg")} width="11" height="10" alt='' />
<img src={ExternalLinkSvg} width="11" height="10" alt='' />
</a>
</div>;
}
Expand Down Expand Up @@ -925,7 +931,7 @@ export default class GroupView extends React.Component {
onClick={this._onAddRoomsClick}
>
<div className="mx_GroupView_rooms_header_addRow_button">
<img src={require("../../../res/img/icons-room-add.svg")} width="24" height="24" />
<img src={AddRoomSvg} width="24" height="24" />
</div>
<div className="mx_GroupView_rooms_header_addRow_label">
{ _t('Add rooms to this community') }
Expand Down Expand Up @@ -1257,7 +1263,7 @@ export default class GroupView extends React.Component {
<div className="mx_GroupView_avatarPicker_edit">
<label htmlFor="avatarInput" className="mx_GroupView_avatarPicker_label">
<img
src={require("../../../res/img/camera.svg")}
src={CameraSvg}
alt={_t("Upload avatar")}
title={_t("Upload avatar")}
width="17"
Expand Down Expand Up @@ -1331,7 +1337,7 @@ export default class GroupView extends React.Component {
onClick={this._onCancelClick}
>
<img
src={require("../../../res/img/cancel.svg")}
src={CancelSvg}
className="mx_filterFlipColor"
width="18"
height="18"
Expand Down
3 changes: 2 additions & 1 deletion src/components/structures/MyGroups.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import AccessibleButton from '../views/elements/AccessibleButton';
import MatrixClientContext from "../../contexts/MatrixClientContext";
import AutoHideScrollbar from "./AutoHideScrollbar";
import { replaceableComponent } from "../../utils/replaceableComponent";
import GroupsSvg from '../../../res/img/icons-groups.svg';

@replaceableComponent("structures.MyGroups")
export default class MyGroups extends React.Component {
Expand Down Expand Up @@ -106,7 +107,7 @@ export default class MyGroups extends React.Component {
}

return <div className="mx_MyGroups">
<SimpleRoomHeader title={_t("Communities")} icon={require("../../../res/img/icons-groups.svg")} />
<SimpleRoomHeader title={_t("Communities")} icon={GroupsSvg} />
<div className='mx_MyGroups_header'>
<div className="mx_MyGroups_headerCard">
<AccessibleButton className='mx_MyGroups_headerCard_button' onClick={this._onCreateGroupClick} />
Expand Down
3 changes: 2 additions & 1 deletion src/components/structures/RoomStatusBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import { StaticNotificationState } from "../../stores/notifications/StaticNotifi
import AccessibleButton from "../views/elements/AccessibleButton";
import InlineSpinner from "../views/elements/InlineSpinner";
import MatrixClientContext from "../../contexts/MatrixClientContext";
import WarningTriangleSvg from '../../../res/img/feather-customised/warning-triangle.svg';

const STATUS_BAR_HIDDEN = 0;
const STATUS_BAR_EXPANDED = 1;
Expand Down Expand Up @@ -285,7 +286,7 @@ export default class RoomStatusBar extends React.PureComponent<IProps, IState> {
<div role="alert">
<div className="mx_RoomStatusBar_connectionLostBar">
<img
src={require("../../../res/img/feather-customised/warning-triangle.svg")}
src={WarningTriangleSvg}
width="24"
height="24"
title="/!\ "
Expand Down
3 changes: 2 additions & 1 deletion src/components/structures/UserMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ import { SettingUpdatedPayload } from "../../dispatcher/payloads/SettingUpdatedP
import UserIdentifierCustomisations from "../../customisations/UserIdentifier";
import PosthogTrackers from "../../PosthogTrackers";
import { ViewHomePagePayload } from "../../dispatcher/payloads/ViewHomePagePayload";
import SwitchThemeSvg from '../../../res/img/element-icons/roomlist/dark-light-mode.svg';

const CustomStatusSection = () => {
const cli = useContext(MatrixClientContext);
Expand Down Expand Up @@ -515,7 +516,7 @@ export default class UserMenu extends React.Component<IProps, IState> {
title={this.state.isDarkTheme ? _t("Switch to light mode") : _t("Switch to dark mode")}
>
<img
src={require("../../../res/img/element-icons/roomlist/dark-light-mode.svg")}
src={SwitchThemeSvg}
alt={_t("Switch theme")}
width={16}
/>
Expand Down
15 changes: 10 additions & 5 deletions src/components/views/avatars/WidgetAvatar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,27 @@ import classNames from 'classnames';
import { IApp } from "../../../stores/WidgetStore";
import BaseAvatar, { BaseAvatarType } from "./BaseAvatar";
import { mediaFromMxc } from "../../../customisations/Media";
import DefaultAppSvg from '../../../../res/img/element-icons/room/default_app.svg';
import DefaultVideoSvg from '../../../../res/img/element-icons/room/default_video.svg';
import DefaultCalSvg from '../../../../res/img/element-icons/room/default_cal.svg';
import DefaultDocSvg from '../../../../res/img/element-icons/room/default_doc.svg';
import DefaultClockSvg from '../../../../res/img/element-icons/room/default_clock.svg';

interface IProps extends Omit<ComponentProps<BaseAvatarType>, "name" | "url" | "urls"> {
app: IApp;
}

const WidgetAvatar: React.FC<IProps> = ({ app, className, width = 20, height = 20, ...props }) => {
let iconUrls = [require("../../../../res/img/element-icons/room/default_app.svg")];
let iconUrls = [DefaultAppSvg];
// 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")];
iconUrls = [DefaultVideoSvg];
} else if (app.type.includes("meeting") || app.type.includes("calendar")) {
iconUrls = [require("../../../../res/img/element-icons/room/default_cal.svg")];
iconUrls = [DefaultCalSvg];
} else if (app.type.includes("pad") || app.type.includes("doc") || app.type.includes("calc")) {
iconUrls = [require("../../../../res/img/element-icons/room/default_doc.svg")];
iconUrls = [DefaultDocSvg];
} else if (app.type.includes("clock")) {
iconUrls = [require("../../../../res/img/element-icons/room/default_clock.svg")];
iconUrls = [DefaultClockSvg];
}

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import Modal from '../../../Modal';
import GroupStore from "../../../stores/GroupStore";
import { MenuItem } from "../../structures/ContextMenu";
import { replaceableComponent } from "../../../utils/replaceableComponent";
import ContextDeleteSvg from '../../../../res/img/icon_context_delete.svg';

@replaceableComponent("views.context_menus.GroupInviteTileContextMenu")
export default class GroupInviteTileContextMenu extends React.Component {
Expand Down Expand Up @@ -85,7 +86,7 @@ export default class GroupInviteTileContextMenu extends React.Component {
render() {
return <div>
<MenuItem className="mx_RoomTileContextMenu_leave" onClick={this._onClickReject}>
<img className="mx_RoomTileContextMenu_tag_icon" src={require("../../../../res/img/icon_context_delete.svg")} width="15" height="15" alt="" />
<img className="mx_RoomTileContextMenu_tag_icon" src={ContextDeleteSvg} width="15" height="15" alt="" />
{ _t('Reject') }
</MenuItem>
</div>;
Expand Down
3 changes: 2 additions & 1 deletion src/components/views/dialogs/AddExistingToSpaceDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import ProgressBar from "../elements/ProgressBar";
import DecoratedRoomAvatar from "../avatars/DecoratedRoomAvatar";
import QueryMatcher from "../../../autocomplete/QueryMatcher";
import LazyRenderList from "../elements/LazyRenderList";
import WarningBadgeSvg from '../../../../res/img/element-icons/warning-badge.svg';

// These values match CSS
const ROW_HEIGHT = 32 + 12;
Expand Down Expand Up @@ -213,7 +214,7 @@ export const AddExistingToSpace: React.FC<IAddExistingToSpaceProps> = ({
if (error) {
footer = <>
<img
src={require("../../../../res/img/element-icons/warning-badge.svg")}
src={WarningBadgeSvg}
height="24"
width="24"
alt=""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ import { inviteUsersToRoom } from "../../../RoomInvite";
import ProgressBar from "../elements/ProgressBar";
import { ViewRoomPayload } from "../../../dispatcher/payloads/ViewRoomPayload";
import { CreateEventField, IGroupRoom, IGroupSummary } from "../../../@types/groups";
import WarningBadgeSvg from '../../../../res/img/element-icons/warning-badge.svg';

interface IProps {
matrixClient: MatrixClient;
Expand Down Expand Up @@ -241,7 +242,7 @@ const CreateSpaceFromCommunityDialog: React.FC<IProps> = ({ matrixClient: cli, g
let footer;
if (error) {
footer = <>
<img src={require("../../../../res/img/element-icons/warning-badge.svg")} height="24" width="24" alt="" />
<img src={WarningBadgeSvg} height="24" width="24" alt="" />

<span className="mx_CreateSpaceFromCommunityDialog_error">
<div className="mx_CreateSpaceFromCommunityDialog_errorHeading">{ _t("Failed to migrate community") }</div>
Expand Down
3 changes: 2 additions & 1 deletion src/components/views/dialogs/ForwardDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ import { roomContextDetailsText } from "../../../Rooms";
import { Action } from "../../../dispatcher/actions";
import { ViewRoomPayload } from "../../../dispatcher/payloads/ViewRoomPayload";
import { ButtonEvent } from "../elements/AccessibleButton";
import EllipsisSvg from '../../../../res/img/ellipsis.svg';

const AVATAR_SIZE = 30;

Expand Down Expand Up @@ -216,7 +217,7 @@ const ForwardDialog: React.FC<IProps> = ({ matrixClient: cli, event, permalinkCr
<EntityTile
className="mx_EntityTile_ellipsis"
avatarJsx={
<BaseAvatar url={require("../../../../res/img/ellipsis.svg")} name="..." width={36} height={36} />
<BaseAvatar url={EllipsisSvg} name="..." width={36} height={36} />
}
name={text}
presenceState="online"
Expand Down
11 changes: 7 additions & 4 deletions src/components/views/dialogs/InviteDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ import { ScreenName } from '../../../PosthogTrackers';
import { ViewRoomPayload } from "../../../dispatcher/payloads/ViewRoomPayload";
import { KeyBindingAction } from "../../../accessibility/KeyboardShortcuts";
import { getKeyBindingsManager } from "../../../KeyBindingsManager";
import EmailPillSvg from '../../../../res/img/icon-email-pill-avatar.svg';
import PillRemoveSvg from '../../../../res/img/icon-pill-remove.svg';
import InfoSvg from '../../../../res/img/element-icons/info.svg';

// we have a number of types defined from the Matrix spec which can't reasonably be altered here.
/* eslint-disable camelcase */
Expand Down Expand Up @@ -195,7 +198,7 @@ class DMUserTile extends React.PureComponent<IDMUserTileProps> {
const avatar = (this.props.member as ThreepidMember).isEmail
? <img
className='mx_InviteDialog_userTile_avatar mx_InviteDialog_userTile_threepidAvatar'
src={require("../../../../res/img/icon-email-pill-avatar.svg")}
src={EmailPillSvg}
width={avatarSize}
height={avatarSize}
/>
Expand All @@ -217,7 +220,7 @@ class DMUserTile extends React.PureComponent<IDMUserTileProps> {
onClick={this.onRemove}
>
<img
src={require("../../../../res/img/icon-pill-remove.svg")}
src={PillRemoveSvg}
alt={_t('Remove')}
width={8}
height={8}
Expand Down Expand Up @@ -301,7 +304,7 @@ class DMRoomTile extends React.PureComponent<IDMRoomTileProps> {
const avatarSize = 36;
const avatar = (this.props.member as ThreepidMember).isEmail
? <img
src={require("../../../../res/img/icon-email-pill-avatar.svg")}
src={EmailPillSvg}
width={avatarSize}
height={avatarSize}
/>
Expand Down Expand Up @@ -1472,7 +1475,7 @@ export default class InviteDialog extends React.PureComponent<IInviteDialogProps
keySharingWarning =
<p className='mx_InviteDialog_helpText'>
<img
src={require("../../../../res/img/element-icons/info.svg")}
src={InfoSvg}
width={14}
height={14} />
{ " " + _t("Invited people will be able to read old messages.") }
Expand Down
4 changes: 2 additions & 2 deletions src/components/views/dialogs/ModalWidgetDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ import { ElementWidget } from "../../../stores/widgets/StopGapWidget";
import { replaceableComponent } from "../../../utils/replaceableComponent";
import { ELEMENT_CLIENT_ID } from "../../../identifiers";
import SettingsStore from "../../../settings/SettingsStore";

import WarningBadgeSvg from '../../../../res/img/element-icons/warning-badge.svg';
interface IProps {
widgetDefinition: IModalWidgetOpenRequestData;
widgetRoomId?: string;
Expand Down Expand Up @@ -187,7 +187,7 @@ export default class ModalWidgetDialog extends React.PureComponent<IProps, IStat
>
<div className="mx_ModalWidgetDialog_warning">
<img
src={require("../../../../res/img/element-icons/warning-badge.svg")}
src={WarningBadgeSvg}
height="16"
width="16"
alt=""
Expand Down
3 changes: 2 additions & 1 deletion src/components/views/dialogs/UploadConfirmDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { replaceableComponent } from "../../../utils/replaceableComponent";
import { getBlobSafeMimeType } from '../../../utils/blobs';
import BaseDialog from "./BaseDialog";
import DialogButtons from "../elements/DialogButtons";
import FilesSvg from '../../../../res/img/feather-customised/files.svg';

interface IProps {
file: File;
Expand Down Expand Up @@ -94,7 +95,7 @@ export default class UploadConfirmDialog extends React.Component<IProps> {
preview = <div>
<div>
<img className="mx_UploadConfirmDialog_fileIcon"
src={require("../../../../res/img/feather-customised/files.svg")}
src={FilesSvg}
/>
{ this.props.file.name } ({ filesize(this.props.file.size) })
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,14 @@ import { _t } from '../../../../languageHandler';
import { SetupEncryptionStore, Phase } from '../../../../stores/SetupEncryptionStore';
import { replaceableComponent } from "../../../../utils/replaceableComponent";
import { IDialogProps } from "../IDialogProps";
import VerifiedSvg from '../../../../../res/img/e2e/verified.svg';
import WarningSvg from '../../../../../res/img/e2e/warning.svg';

function iconFromPhase(phase: Phase) {
if (phase === Phase.Done) {
return require("../../../../../res/img/e2e/verified.svg");
return VerifiedSvg;
} else {
return require("../../../../../res/img/e2e/warning.svg");
return WarningSvg;
}
}

Expand Down
3 changes: 2 additions & 1 deletion src/components/views/elements/AddressTile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import { mediaFromMxc } from "../../../customisations/Media";
import { IUserAddress } from '../../../UserAddress';
import BaseAvatar from '../avatars/BaseAvatar';
import EmailUserIcon from "../../../../res/img/icon-email-user.svg";
import AddressDeleteSvg from '../../../../res/img/icon-address-delete.svg';

interface IProps {
address: IUserAddress;
Expand Down Expand Up @@ -124,7 +125,7 @@ export default class AddressTile extends React.Component<IProps> {
if (this.props.canDismiss) {
dismiss = (
<div className="mx_AddressTile_dismiss" onClick={this.props.onDismissed}>
<img src={require("../../../../res/img/icon-address-delete.svg")} width="9" height="9" />
<img src={AddressDeleteSvg} width="9" height="9" />
</div>
);
}
Expand Down
4 changes: 3 additions & 1 deletion src/components/views/elements/AppWarning.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import React from 'react';

import WarningSvg from '../../../../res/img/warning.svg';

interface IProps {
errorMsg?: string;
}
Expand All @@ -8,7 +10,7 @@ const AppWarning: React.FC<IProps> = (props) => {
return (
<div className='mx_AppPermissionWarning'>
<div className='mx_AppPermissionWarningImage'>
<img src={require("../../../../res/img/warning.svg")} alt='' />
<img src={WarningSvg} alt='' />
</div>
<div className='mx_AppPermissionWarningText'>
<span className='mx_AppPermissionWarningTextLabel'>{ props.errorMsg || "Error" }</span>
Expand Down
Loading