Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

web: import svg assets as url to exclude them from main bundle

Abdullah Attab3d6fd7f5b95
diff --git a/apps/web/src/dialogs/buy-dialog/buy-dialog.tsx b/apps/web/src/dialogs/buy-dialog/buy-dialog.tsx
index e5d9493c0..259efd5c5 100644
--- a/apps/web/src/dialogs/buy-dialog/buy-dialog.tsx
+++ b/apps/web/src/dialogs/buy-dialog/buy-dialog.tsx
@@ -18,13 +18,13 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import { useCallback, useEffect, useRef, useState } from "react";
-import { Text, Flex, Button, Link, Box } from "@theme-ui/components";
+import { Text, Flex, Button, Link, Box, Image } from "@theme-ui/components";
import { Cross, Check, Loading } from "../../components/icons";
import { useStore as useUserStore } from "../../stores/user-store";
import { useStore as useThemeStore } from "../../stores/theme-store";
-import Rocket from "../../assets/rocket.svg?react";
-import WorkAnywhere from "../../assets/workanywhere.svg?react";
-import WorkLate from "../../assets/worklate.svg?react";
+import Rocket from "../../assets/rocket.svg?url";
+import WorkAnywhere from "../../assets/workanywhere.svg?url";
+import WorkLate from "../../assets/worklate.svg?url";
import Field from "../../components/field";
import { hardNavigate } from "../../navigation";
import { Features } from "./features";
@@ -258,7 +258,7 @@ function TrialOrUpgrade(props: TrialOrUpgradeProps) {
return (
<>
- <Rocket style={{ flexShrink: 0, width: 200, height: 200 }} />
+ <Image src={Rocket} style={{ flexShrink: 0, width: 200, height: 200 }} />
<Text variant="heading" mt={4} sx={{ textAlign: "center" }}>
Notesnook Pro
</Text>
@@ -345,7 +345,7 @@ function AlreadyPremium(props: AlreadyPremiumProps) {
const { isCanceled, onShowPlans } = props;
return (
<>
- <Rocket style={{ flexShrink: 0, width: 200, height: 200 }} />
+ <Image src={Rocket} style={{ flexShrink: 0, width: 200, height: 200 }} />
<Text variant="heading" mt={4} sx={{ textAlign: "center" }}>
Notesnook Pro
</Text>
@@ -382,7 +382,7 @@ export function CheckoutCompleted(props: {
return (
<>
- <Rocket style={{ flexShrink: 0, width: 200, height: 200 }} />
+ <Image src={Rocket} style={{ flexShrink: 0, width: 200, height: 200 }} />
<Text variant="heading" mt={4} sx={{ textAlign: "center" }}>
You are awesome!
</Text>
@@ -449,9 +449,15 @@ function SelectedPlan(props: SelectedPlanProps) {
return (
<>
{plan.period === "monthly" ? (
- <WorkAnywhere style={{ flexShrink: 0, width: 180, height: 180 }} />
+ <Image
+ src={WorkAnywhere}
+ style={{ flexShrink: 0, width: 180, height: 180 }}
+ />
) : (
- <WorkLate style={{ flexShrink: 0, width: 180, height: 180 }} />
+ <Image
+ src={WorkLate}
+ style={{ flexShrink: 0, width: 180, height: 180 }}
+ />
)}
<Text variant="heading" mt={4} sx={{ textAlign: "center" }}>
Notesnook Pro
diff --git a/apps/web/src/dialogs/buy-dialog/plan-list.tsx b/apps/web/src/dialogs/buy-dialog/plan-list.tsx
index 7debd11d2..c47d1007d 100644
--- a/apps/web/src/dialogs/buy-dialog/plan-list.tsx
+++ b/apps/web/src/dialogs/buy-dialog/plan-list.tsx
@@ -17,9 +17,9 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-import { Text, Flex, Button } from "@theme-ui/components";
+import { Text, Flex, Button, Image } from "@theme-ui/components";
import { Loading } from "../../components/icons";
-import Nomad from "../../assets/nomad.svg?react";
+import Nomad from "../../assets/nomad.svg?url";
import { Period, Plan } from "./types";
import { PLAN_METADATA, usePlans } from "./plans";
import { useEffect } from "react";
@@ -40,7 +40,7 @@ export function PlansList(props: PlansListProps) {
return (
<>
- <Nomad style={{ flexShrink: 0, width: 200, height: 200 }} />
+ <Image src={Nomad} style={{ flexShrink: 0, width: 200, height: 200 }} />
<Text variant="heading" mt={4} sx={{ textAlign: "center" }}>
Choose a plan
</Text>
diff --git a/apps/web/src/dialogs/mfa/steps.tsx b/apps/web/src/dialogs/mfa/steps.tsx
index c43b333d5..ac988961f 100644
--- a/apps/web/src/dialogs/mfa/steps.tsx
+++ b/apps/web/src/dialogs/mfa/steps.tsx
@@ -26,7 +26,7 @@ import React, {
useRef,
useState
} from "react";
-import { Text, Flex, Button, Box } from "@theme-ui/components";
+import { Text, Flex, Button, Box, Image } from "@theme-ui/components";
import { useSessionState } from "../../hooks/use-session-state";
import {
Loading,
@@ -46,8 +46,8 @@ import { phone } from "phone";
import { db } from "../../common/db";
import FileSaver from "file-saver";
import { writeText } from "clipboard-polyfill";
-import MFA from "../../assets/mfa.svg?react";
-import Fallback2FA from "../../assets/fallback2fa.svg?react";
+import MFA from "../../assets/mfa.svg?url";
+import Fallback2FA from "../../assets/fallback2fa.svg?url";
import {
Authenticator,
StepComponent,
@@ -687,7 +687,7 @@ function TwoFactorEnabled(props: TwoFactorEnabledProps) {
justifyContent: "center"
}}
>
- <MFA style={{ flexShrink: 0, width: 120, height: 120 }} />
+ <Image src={MFA} style={{ flexShrink: 0, width: 120, height: 120 }} />
<Text
variant={"heading"}
mt={2}
@@ -743,7 +743,10 @@ function Fallback2FAEnabled(props: Fallback2FAEnabledProps) {
justifyContent: "center"
}}
>
- <Fallback2FA style={{ flexShrink: 0, width: 200, height: 200 }} />
+ <Image
+ src={Fallback2FA}
+ style={{ flexShrink: 0, width: 200, height: 200 }}
+ />
<Text
variant={"heading"}
mt={2}
diff --git a/apps/web/src/dialogs/onboarding-dialog.tsx b/apps/web/src/dialogs/onboarding-dialog.tsx
index 7ccfb88e7..f1a5b7c67 100644
--- a/apps/web/src/dialogs/onboarding-dialog.tsx
+++ b/apps/web/src/dialogs/onboarding-dialog.tsx
@@ -27,15 +27,15 @@ import {
Github,
Loading
} from "../components/icons";
-import E2E from "../assets/e2e.svg?react";
-import Note from "../assets/note2.svg?react";
-import Nomad from "../assets/nomad.svg?react";
-import WorkAnywhere from "../assets/workanywhere.svg?react";
-import Friends from "../assets/cause.svg?react";
-import LightUI from "../assets/light1.png";
-import DarkUI from "../assets/dark1.png";
-import GooglePlay from "../assets/play.png";
-import AppleStore from "../assets/apple.png";
+import E2E from "../assets/e2e.svg?url";
+import Note from "../assets/note2.svg?url";
+import Nomad from "../assets/nomad.svg?url";
+import WorkAnywhere from "../assets/workanywhere.svg?url";
+import Friends from "../assets/cause.svg?url";
+import LightUI from "../assets/light1.png?url";
+import DarkUI from "../assets/dark1.png?url";
+import GooglePlay from "../assets/play.png?url";
+import AppleStore from "../assets/apple.png?url";
import { useStore as useThemeStore } from "../stores/theme-store";
import { Features } from "../components/announcements/body";
import { TaskManager } from "../common/task-manager";
@@ -65,7 +65,9 @@ const newUserSteps: Step[] = [
title: strings.safeEncryptedNotes(),
subtitle: strings.writeWithFreedom(),
buttonText: strings.getStarted(),
- image: <Note style={{ flexShrink: 0, width: 120, height: 120 }} />
+ image: (
+ <Image src={Note} style={{ flexShrink: 0, width: 120, height: 120 }} />
+ )
},
{
title: strings.chooseYourStyle(),
@@ -74,7 +76,9 @@ const newUserSteps: Step[] = [
component: ThemeSelector
},
{
- image: <E2E style={{ flexShrink: 0, width: 180, height: 180 }} />,
+ image: (
+ <Image src={E2E} style={{ flexShrink: 0, width: 180, height: 180 }} />
+ ),
title: strings.crossPlatformEncrypted(),
subtitle: strings.encryptsEverything(),
component: CrossPlatform,
@@ -84,7 +88,9 @@ const newUserSteps: Step[] = [
title: strings.joinTheCause(),
subtitle: strings.meetPrivacyMinded(),
component: JoinCause,
- image: <Friends style={{ flexShrink: 0, width: 140, height: 140 }} />
+ image: (
+ <Image src={Friends} style={{ flexShrink: 0, width: 140, height: 140 }} />
+ )
},
{
image: <Pro size={60} color="accent" />,
@@ -99,7 +105,9 @@ const proUserSteps: Step[] = [
title: strings.welcomeToNotesnookPro(),
subtitle: strings.thankYouPrivacy(),
buttonText: strings.next(),
- image: <Nomad style={{ flexShrink: 0, width: 120, height: 120 }} />
+ image: (
+ <Image src={Nomad} style={{ flexShrink: 0, width: 120, height: 120 }} />
+ )
},
{
title: strings.weAreAlwaysListening(),
@@ -119,7 +127,12 @@ const trialUserSteps: Step[] = [
title: strings.congratulations(),
subtitle: strings.trialStarted(),
buttonText: strings.continue(),
- image: <WorkAnywhere style={{ flexShrink: 0, width: 160, height: 160 }} />
+ image: (
+ <Image
+ src={WorkAnywhere}
+ style={{ flexShrink: 0, width: 160, height: 160 }}
+ />
+ )
}
];