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

Commit

Permalink
Revert "replace all require(svgs) with esm import (#7948)"
Browse files Browse the repository at this point in the history
This reverts commit 61cd463.
  • Loading branch information
Kerry authored Mar 3, 2022
1 parent acd12c3 commit 6d303cc
Show file tree
Hide file tree
Showing 33 changed files with 54 additions and 104 deletions.
3 changes: 1 addition & 2 deletions src/components/structures/FileDropTarget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ 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 @@ -110,7 +109,7 @@ const FileDropTarget: React.FC<IProps> = ({ parent, onFileDrop }) => {

if (state.dragging) {
return <div className="mx_FileDropTarget">
<img src={FileDropSvg} className="mx_FileDropTarget_image" alt="" />
<img src={require("../../../res/img/upload-big.svg")} className="mx_FileDropTarget_image" alt="" />
{ _t("Drop file here to upload") }
</div>;
}
Expand Down
22 changes: 8 additions & 14 deletions src/components/structures/GroupView.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,6 @@ 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 @@ -141,7 +135,7 @@ class CategoryRoomList extends React.Component {
(<AccessibleButton className="mx_GroupView_featuredThings_addButton"
onClick={this.onAddRoomsToSummaryClicked}
>
<img src={CreateRoomSvg} width="64" height="64" />
<img src={require("../../../res/img/icons-create-room.svg")} width="64" height="64" />
<div className="mx_GroupView_featuredThings_addButton_label">
{ _t('Add a Room') }
</div>
Expand Down Expand Up @@ -241,7 +235,7 @@ class FeaturedRoom extends React.Component {
const deleteButton = this.props.editing ?
<img
className="mx_GroupView_featuredThing_deleteButton"
src={CancelSmallSvg}
src={require("../../../res/img/cancel-small.svg")}
width="14"
height="14"
alt="Delete"
Expand Down Expand Up @@ -312,7 +306,7 @@ class RoleUserList extends React.Component {
render() {
const addButton = this.props.editing ?
(<AccessibleButton className="mx_GroupView_featuredThings_addButton" onClick={this.onAddUsersClicked}>
<img src={CreateRoomSvg} width="64" height="64" />
<img src={require("../../../res/img/icons-create-room.svg")} width="64" height="64" />
<div className="mx_GroupView_featuredThings_addButton_label">
{ _t('Add a User') }
</div>
Expand Down Expand Up @@ -392,7 +386,7 @@ class FeaturedUser extends React.Component {
const deleteButton = this.props.editing ?
<img
className="mx_GroupView_featuredThing_deleteButton"
src={CancelSmallSvg}
src={require("../../../res/img/cancel-small.svg")}
width="14"
height="14"
alt="Delete"
Expand Down Expand Up @@ -850,7 +844,7 @@ export default class GroupView extends React.Component {
},
) }
<a href={hostingSignupLink} target="_blank" rel="noreferrer noopener">
<img src={ExternalLinkSvg} width="11" height="10" alt='' />
<img src={require("../../../res/img/external-link.svg")} width="11" height="10" alt='' />
</a>
</div>;
}
Expand Down Expand Up @@ -931,7 +925,7 @@ export default class GroupView extends React.Component {
onClick={this._onAddRoomsClick}
>
<div className="mx_GroupView_rooms_header_addRow_button">
<img src={AddRoomSvg} width="24" height="24" />
<img src={require("../../../res/img/icons-room-add.svg")} width="24" height="24" />
</div>
<div className="mx_GroupView_rooms_header_addRow_label">
{ _t('Add rooms to this community') }
Expand Down Expand Up @@ -1263,7 +1257,7 @@ export default class GroupView extends React.Component {
<div className="mx_GroupView_avatarPicker_edit">
<label htmlFor="avatarInput" className="mx_GroupView_avatarPicker_label">
<img
src={CameraSvg}
src={require("../../../res/img/camera.svg")}
alt={_t("Upload avatar")}
title={_t("Upload avatar")}
width="17"
Expand Down Expand Up @@ -1337,7 +1331,7 @@ export default class GroupView extends React.Component {
onClick={this._onCancelClick}
>
<img
src={CancelSvg}
src={require("../../../res/img/cancel.svg")}
className="mx_filterFlipColor"
width="18"
height="18"
Expand Down
3 changes: 1 addition & 2 deletions src/components/structures/MyGroups.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ 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 @@ -107,7 +106,7 @@ export default class MyGroups extends React.Component {
}

return <div className="mx_MyGroups">
<SimpleRoomHeader title={_t("Communities")} icon={GroupsSvg} />
<SimpleRoomHeader title={_t("Communities")} icon={require("../../../res/img/icons-groups.svg")} />
<div className='mx_MyGroups_header'>
<div className="mx_MyGroups_headerCard">
<AccessibleButton className='mx_MyGroups_headerCard_button' onClick={this._onCreateGroupClick} />
Expand Down
3 changes: 1 addition & 2 deletions src/components/structures/RoomStatusBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ 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 @@ -286,7 +285,7 @@ export default class RoomStatusBar extends React.PureComponent<IProps, IState> {
<div role="alert">
<div className="mx_RoomStatusBar_connectionLostBar">
<img
src={WarningTriangleSvg}
src={require("../../../res/img/feather-customised/warning-triangle.svg")}
width="24"
height="24"
title="/!\ "
Expand Down
3 changes: 1 addition & 2 deletions src/components/structures/UserMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ 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 @@ -516,7 +515,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={SwitchThemeSvg}
src={require("../../../res/img/element-icons/roomlist/dark-light-mode.svg")}
alt={_t("Switch theme")}
width={16}
/>
Expand Down
15 changes: 5 additions & 10 deletions src/components/views/avatars/WidgetAvatar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,27 +20,22 @@ 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 = [DefaultAppSvg];
let iconUrls = [require("../../../../res/img/element-icons/room/default_app.svg")];
// heuristics for some better icons until Widgets support their own icons
if (app.type.includes("jitsi")) {
iconUrls = [DefaultVideoSvg];
iconUrls = [require("../../../../res/img/element-icons/room/default_video.svg")];
} else if (app.type.includes("meeting") || app.type.includes("calendar")) {
iconUrls = [DefaultCalSvg];
iconUrls = [require("../../../../res/img/element-icons/room/default_cal.svg")];
} else if (app.type.includes("pad") || app.type.includes("doc") || app.type.includes("calc")) {
iconUrls = [DefaultDocSvg];
iconUrls = [require("../../../../res/img/element-icons/room/default_doc.svg")];
} else if (app.type.includes("clock")) {
iconUrls = [DefaultClockSvg];
iconUrls = [require("../../../../res/img/element-icons/room/default_clock.svg")];
}

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ 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 @@ -86,7 +85,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={ContextDeleteSvg} width="15" height="15" alt="" />
<img className="mx_RoomTileContextMenu_tag_icon" src={require("../../../../res/img/icon_context_delete.svg")} width="15" height="15" alt="" />
{ _t('Reject') }
</MenuItem>
</div>;
Expand Down
3 changes: 1 addition & 2 deletions src/components/views/dialogs/AddExistingToSpaceDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ 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 @@ -214,7 +213,7 @@ export const AddExistingToSpace: React.FC<IAddExistingToSpaceProps> = ({
if (error) {
footer = <>
<img
src={WarningBadgeSvg}
src={require("../../../../res/img/element-icons/warning-badge.svg")}
height="24"
width="24"
alt=""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ 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 @@ -242,7 +241,7 @@ const CreateSpaceFromCommunityDialog: React.FC<IProps> = ({ matrixClient: cli, g
let footer;
if (error) {
footer = <>
<img src={WarningBadgeSvg} height="24" width="24" alt="" />
<img src={require("../../../../res/img/element-icons/warning-badge.svg")} 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: 1 addition & 2 deletions src/components/views/dialogs/ForwardDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ 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 @@ -217,7 +216,7 @@ const ForwardDialog: React.FC<IProps> = ({ matrixClient: cli, event, permalinkCr
<EntityTile
className="mx_EntityTile_ellipsis"
avatarJsx={
<BaseAvatar url={EllipsisSvg} name="..." width={36} height={36} />
<BaseAvatar url={require("../../../../res/img/ellipsis.svg")} name="..." width={36} height={36} />
}
name={text}
presenceState="online"
Expand Down
11 changes: 4 additions & 7 deletions src/components/views/dialogs/InviteDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,6 @@ 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 @@ -198,7 +195,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={EmailPillSvg}
src={require("../../../../res/img/icon-email-pill-avatar.svg")}
width={avatarSize}
height={avatarSize}
/>
Expand All @@ -220,7 +217,7 @@ class DMUserTile extends React.PureComponent<IDMUserTileProps> {
onClick={this.onRemove}
>
<img
src={PillRemoveSvg}
src={require("../../../../res/img/icon-pill-remove.svg")}
alt={_t('Remove')}
width={8}
height={8}
Expand Down Expand Up @@ -304,7 +301,7 @@ class DMRoomTile extends React.PureComponent<IDMRoomTileProps> {
const avatarSize = 36;
const avatar = (this.props.member as ThreepidMember).isEmail
? <img
src={EmailPillSvg}
src={require("../../../../res/img/icon-email-pill-avatar.svg")}
width={avatarSize}
height={avatarSize}
/>
Expand Down Expand Up @@ -1475,7 +1472,7 @@ export default class InviteDialog extends React.PureComponent<IInviteDialogProps
keySharingWarning =
<p className='mx_InviteDialog_helpText'>
<img
src={InfoSvg}
src={require("../../../../res/img/element-icons/info.svg")}
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={WarningBadgeSvg}
src={require("../../../../res/img/element-icons/warning-badge.svg")}
height="16"
width="16"
alt=""
Expand Down
3 changes: 1 addition & 2 deletions src/components/views/dialogs/UploadConfirmDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ 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 @@ -95,7 +94,7 @@ export default class UploadConfirmDialog extends React.Component<IProps> {
preview = <div>
<div>
<img className="mx_UploadConfirmDialog_fileIcon"
src={FilesSvg}
src={require("../../../../res/img/feather-customised/files.svg")}
/>
{ 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,14 +22,12 @@ 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 VerifiedSvg;
return require("../../../../../res/img/e2e/verified.svg");
} else {
return WarningSvg;
return require("../../../../../res/img/e2e/warning.svg");
}
}

Expand Down
3 changes: 1 addition & 2 deletions src/components/views/elements/AddressTile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ 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 @@ -125,7 +124,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={AddressDeleteSvg} width="9" height="9" />
<img src={require("../../../../res/img/icon-address-delete.svg")} width="9" height="9" />
</div>
);
}
Expand Down
4 changes: 1 addition & 3 deletions src/components/views/elements/AppWarning.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import React from 'react';

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

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

0 comments on commit 6d303cc

Please sign in to comment.