Skip to content

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

web: migrate icon component to typescript

Abdullah Attac8423333f1b7
diff --git a/apps/web/src/components/dialogs/buy-dialog/features.tsx b/apps/web/src/components/dialogs/buy-dialog/features.tsx
index ff70be9cb..00b0efcca 100644
--- a/apps/web/src/components/dialogs/buy-dialog/features.tsx
+++ b/apps/web/src/components/dialogs/buy-dialog/features.tsx
@@ -17,13 +17,53 @@ 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, Box, BoxProps } from "@theme-ui/components";
-import * as Icon from "../../icons";
+import { Text, Flex, Box } from "@theme-ui/components";
+import {
+ Accent,
+ Android,
+ Anonymous,
+ Backup,
+ Billboard,
+ Cellphone,
+ CellphoneLock,
+ CheckCircleOutline,
+ Chrome,
+ CloudLock,
+ EncryptedBackup,
+ Export,
+ FileCabinet,
+ Firefox,
+ Harddisk,
+ Home,
+ HTML,
+ Icon,
+ ImageMultiple,
+ Ios,
+ Linux,
+ Markdown,
+ Notebook2,
+ Palette,
+ PDF,
+ Pin,
+ Pro,
+ Safari,
+ ShieldLock,
+ Shortcut,
+ Table,
+ Timebomb,
+ Windows,
+ Lock,
+ MacOs,
+ File,
+ Embed,
+ Text as TextIcon,
+ ThemeIcon
+} from "../../icons";
type Feature = {
id: string;
title?: string;
- icon?: (props: BoxProps & { size: number }) => JSX.Element;
+ icon?: Icon;
pro?: boolean;
};
@@ -45,27 +85,27 @@ const sections: Section[] = [
{
id: "zero-ads",
title: "Zero ads & zero trackers",
- icon: Icon.Billboard
+ icon: Billboard
},
{
id: "on-device-encryption",
title: "On device encryption",
- icon: Icon.Cellphone
+ icon: Cellphone
},
{
id: "secure-app-lock",
title: "Secure app lock for all",
- icon: Icon.CellphoneLock
+ icon: CellphoneLock
},
{
id: "end-to-end-encrypted",
title: "100% end-to-end encrypted",
- icon: Icon.Lock
+ icon: Lock
},
{
id: "private-vault",
title: "Private vault for notes",
- icon: Icon.ShieldLock,
+ icon: ShieldLock,
pro: true
}
]
@@ -83,35 +123,35 @@ const sections: Section[] = [
features: [
{
id: "ios",
- icon: Icon.iOS
+ icon: Ios
},
{
id: "android",
- icon: Icon.Android
+ icon: Android
},
{
id: "windows",
- icon: Icon.Windows
+ icon: Windows
},
{
id: "linux",
- icon: Icon.Linux
+ icon: Linux
},
{
id: "macos",
- icon: Icon.MacOS
+ icon: MacOs
},
{
id: "chrome",
- icon: Icon.Chrome
+ icon: Chrome
},
{
id: "firefox",
- icon: Icon.Firefox
+ icon: Firefox
},
{
id: "safari",
- icon: Icon.Safari
+ icon: Safari
}
]
},
@@ -124,27 +164,27 @@ const sections: Section[] = [
{
id: "bulletproof-encryption",
title: "Bulletproof encryption",
- icon: Icon.Lock
+ icon: Lock
},
{
id: "4k-images",
title: "High quality 4K images",
- icon: Icon.ImageMultiple
+ icon: ImageMultiple
},
{
id: "unlimited-storage",
title: "Unlimited storage",
- icon: Icon.Harddisk
+ icon: Harddisk
},
{
id: "500-mb-files",
title: "Upto 500 MB per file",
- icon: Icon.FileCabinet
+ icon: FileCabinet
},
{
id: "file-types",
title: "All file types supported",
- icon: Icon.File
+ icon: File
}
]
},
@@ -161,17 +201,17 @@ const sections: Section[] = [
{
id: "anon-publishing",
title: "Anonymous publishing",
- icon: Icon.Anonymous
+ icon: Anonymous
},
{
id: "password-protected-publishing",
title: "Password protection",
- icon: Icon.CloudLock
+ icon: CloudLock
},
{
id: "self-destructive-notes",
title: "Self destructable notes",
- icon: Icon.Timebomb
+ icon: Timebomb
}
]
},
@@ -183,24 +223,24 @@ const sections: Section[] = [
{
id: "unlimited-notebooks",
title: "Unlimited notebooks*",
- icon: Icon.Notebook2,
+ icon: Notebook2,
pro: true
},
{
id: "colors-tags",
title: "Colors & tags*",
- icon: Icon.Palette,
+ icon: Palette,
pro: true
},
{
id: "side-menu-shortcuts",
title: "Side menu shortcuts",
- icon: Icon.Shortcut
+ icon: Shortcut
},
{
id: "pins-favorites",
title: "Pins & favorites",
- icon: Icon.Pin
+ icon: Pin
}
],
info: "* Free users can only create 3 notebooks (no limit on topics) and 5 tags."
@@ -215,22 +255,22 @@ const sections: Section[] = [
{
id: "lists-tables",
title: "Lists & tables",
- icon: Icon.Table
+ icon: Table
},
{
id: "image-embeds",
title: "Images & embeds",
- icon: Icon.Embed
+ icon: Embed
},
{
id: "checklists",
title: "Checklists",
- icon: Icon.CheckCircleOutline
+ icon: CheckCircleOutline
},
{
id: "md-shortcuts",
title: "Markdown shortcuts",
- icon: Icon.Markdown
+ icon: Markdown
}
]
},
@@ -243,30 +283,30 @@ const sections: Section[] = [
{
id: "export-markdown",
title: "Export as Markdown",
- icon: Icon.Markdown,
+ icon: Markdown,
pro: true
},
{
id: "export-pdf",
title: "Export as PDF",
- icon: Icon.PDF,
+ icon: PDF,
pro: true
},
{
id: "export-html",
title: "Export as HTML",
- icon: Icon.HTML,
+ icon: HTML,
pro: true
},
{
id: "export-txt",
title: "Export as text",
- icon: Icon.Text
+ icon: TextIcon
},
{
id: "bulk-exports",
title: "Bulk exports",
- icon: Icon.Export
+ icon: Export
}
]
},
@@ -278,13 +318,13 @@ const sections: Section[] = [
{
id: "auto-backups",
title: "Automatic monthly, weekly & daily backups",
- icon: Icon.Backup,
+ icon: Backup,
pro: true
},
{
id: "backup-encryption",
title: "Backup encryption",
- icon: Icon.EncryptedBackup,
+ icon: EncryptedBackup,
pro: true
}
]
@@ -298,17 +338,17 @@ const sections: Section[] = [
{
id: "10-themes",
title: "10+ themes",
- icon: Icon.Accent
+ icon: Accent
},
{
id: "dark-mode",
title: "Automatic dark mode",
- icon: Icon.Theme
+ icon: ThemeIcon
},
{
id: "default-home-page",
title: "Change default home page",
- icon: Icon.Home
+ icon: Home
}
]
}
@@ -342,7 +382,7 @@ export function Features() {
sx={{ borderRadius: 50, alignSelf: "start" }}
mb={1}
>
- <Icon.Pro color="primary" size={16} />
+ <Pro color="primary" size={16} />
<Text variant="body" ml={"2px"} sx={{ color: "primary" }}>
Pro
</Text>
@@ -381,7 +421,7 @@ export function Features() {
<Flex
sx={{ alignItems: "center", justifyContent: "center" }}
>
- <Icon.Pro color="primary" size={14} />
+ <Pro color="primary" size={14} />
<Text
variant="subBody"
ml={"2px"}
diff --git a/apps/web/src/components/dialogs/feature-dialog.tsx b/apps/web/src/components/dialogs/feature-dialog.tsx
index 7de89c59e..d69639470 100644
--- a/apps/web/src/components/dialogs/feature-dialog.tsx
+++ b/apps/web/src/components/dialogs/feature-dialog.tsx
@@ -17,23 +17,23 @@ 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, BoxProps } from "@theme-ui/components";
+import { Text, Flex } from "@theme-ui/components";
import Dialog from "./dialog";
-import * as Icon from "../icons";
import { getHomeRoute, hardNavigate } from "../../navigation";
import { appVersion } from "../../utils/version";
import Config from "../../utils/config";
import { isTesting } from "../../utils/platform";
import { useEffect } from "react";
+import { ArrowRight, Checkmark, Icon, Warn, Date } from "../icons";
type CallToAction = {
title: string;
- icon?: (props: BoxProps & { size: number }) => JSX.Element;
+ icon?: Icon;
action?: () => void;
};
type SubFeature = {
title: string;
- icon?: (props: BoxProps & { size: number }) => JSX.Element;
+ icon?: Icon;
subtitle?: string | JSX.Element;
};
type Feature = {
@@ -51,7 +51,7 @@ const features: Record<FeatureKeys, Feature> = {
subtitle: "You can now sync your notes to unlimited devices.",
cta: {
title: "Continue",
- icon: Icon.ArrowRight,
+ icon: ArrowRight,
action: () => hardNavigate(getHomeRoute())
}
},
@@ -65,7 +65,7 @@ const features: Record<FeatureKeys, Feature> = {
subFeatures: appVersion.isBeta
? [
{
- icon: Icon.Warn,
+ icon: Warn,
title: "Notice",
subtitle: (
<>
@@ -77,7 +77,7 @@ const features: Record<FeatureKeys, Feature> = {
)
},
{
- icon: Icon.Warn,
+ icon: Warn,
title: "Notice 2",
subtitle: (
<>
@@ -91,7 +91,7 @@ const features: Record<FeatureKeys, Feature> = {
]
: [
{
- icon: Icon.Date,
+ icon: Date,
title: "Shortcuts for adding current date in a note",
subtitle: (
<>
@@ -109,7 +109,7 @@ const features: Record<FeatureKeys, Feature> = {
],
cta: {
title: "Got it",
- icon: Icon.Checkmark,
+ icon: Checkmark,
action: () => {
Config.set(`${appVersion.numerical}:highlights`, true);
}
diff --git a/apps/web/src/components/dialogs/mfa/steps.tsx b/apps/web/src/components/dialogs/mfa/steps.tsx
index 99fe7baa1..57bf8a7f4 100644
--- a/apps/web/src/components/dialogs/mfa/steps.tsx
+++ b/apps/web/src/components/dialogs/mfa/steps.tsx
@@ -30,9 +30,9 @@ import { Text, Flex, Button, Box } from "@theme-ui/components";
import { useSessionState } from "../../../hooks/use-session-state";
import {
Loading,
- MFAAuthenticator,
- MFAEmail,
- MFASMS,
+ MfaAuthenticator,
+ MfaEmail,
+ MfaSms,
Download,
Print,
Copy,
@@ -104,20 +104,20 @@ const Authenticators: Authenticator[] = [
title: "Set up using an Authenticator app",
subtitle:
"Use an authenticator app like Aegis or Raivo Authenticator to get the authentication codes.",
- icon: MFAAuthenticator,
+ icon: MfaAuthenticator,
recommended: true
},
{
type: "sms",
title: "Set up using SMS",
subtitle: "Notesnook will send you an SMS text with the 2FA code at login.",
- icon: MFASMS
+ icon: MfaSms
},
{
type: "email",
title: "Set up using Email",
subtitle: "Notesnook will send you the 2FA code on your email at login.",
- icon: MFAEmail
+ icon: MfaEmail
}
];
export type AuthenticatorOnNext = (authenticator: Authenticator) => void;
diff --git a/apps/web/src/components/dialogs/mfa/types.ts b/apps/web/src/components/dialogs/mfa/types.ts
index e0182d9d0..3c55507db 100644
--- a/apps/web/src/components/dialogs/mfa/types.ts
+++ b/apps/web/src/components/dialogs/mfa/types.ts
@@ -17,8 +17,8 @@ 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 { BoxProps } from "@theme-ui/components";
import { Perform } from "../../../common/dialog-controller";
+import { Icon } from "../../icons";
export type AuthenticatorType = "app" | "sms" | "email";
@@ -26,7 +26,7 @@ export type Authenticator = {
type: AuthenticatorType;
title: string;
subtitle: string;
- icon: React.FunctionComponent<BoxProps & { size: number }>;
+ icon: Icon;
recommended?: boolean;
};
diff --git a/apps/web/src/components/icons/index.js b/apps/web/src/components/icons/index.tsx
similarity index 88%
rename from apps/web/src/components/icons/index.js
rename to apps/web/src/components/icons/index.tsx
index 43e497258..47a16dd25 100644
--- a/apps/web/src/components/icons/index.js
+++ b/apps/web/src/components/icons/index.tsx
@@ -179,41 +179,71 @@ import {
} from "@mdi/js";
import { useTheme } from "@emotion/react";
import { AnimatedFlex } from "../animated";
+import { Theme } from "@notesnook/theme";
+import { FlexProps } from "@theme-ui/components";
+import { MotionProps } from "framer-motion";
-function Icon({ title, name, size = 24, color = "icon", stroke, rotate }) {
- const theme = useTheme();
+type MDIIconWrapperProps = {
+ title?: string;
+ path: string;
+ size?: keyof Theme["iconSizes"] | number;
+ color?: keyof Theme["colors"];
+ rotate?: boolean;
+};
+function MDIIconWrapper({
+ title,
+ path,
+ size = 24,
+ color = "icon",
+ rotate
+}: MDIIconWrapperProps) {
+ const theme = useTheme() as Theme;
+
+ const themedColor: string = theme?.colors
+ ? (theme.colors[color] as string)
+ : color;
return (
<MDIIcon
+ className="icon"
title={title}
- path={name}
- size={size + "px"}
+ path={path}
+ size={
+ typeof size === "string"
+ ? `${theme?.iconSizes[size] || 24}px`
+ : `${size}px`
+ }
style={{
- strokeWidth: stroke || "0px",
- stroke: theme.colors[color] || color
+ stroke: themedColor
}}
- color={theme.colors[color] || color}
+ color={themedColor}
spin={rotate}
/>
);
}
-function createIcon(name, rotate = false) {
- const NNIcon = function NNIcon(props) {
- const [isHovering, setIsHovering] = useState();
+type IconProps = FlexProps &
+ MotionProps &
+ Omit<MDIIconWrapperProps, "path"> & {
+ hoverColor?: keyof Theme["colors"];
+ };
+
+export type Icon = {
+ (props: IconProps): JSX.Element;
+ isReactComponent: boolean;
+};
+
+function createIcon(path: string, rotate = false) {
+ const NNIcon: Icon = function Icon(props) {
+ const [isHovering, setIsHovering] = useState(false);
+ const { sx, rotate: _rotate = rotate, size, ...restProps } = props;
return (
<AnimatedFlex
- id={props.id}
- className={props.className}
- title={props.title}
- variant={props.variant}
+ {...restProps}
whileHover={{ scale: 1.1 }}
transition={{ duration: 0.3, ease: "easeOut" }}
- animate={props.animation}
- onClick={props.onClick}
- data-test-id={props["data-test-id"]}
sx={{
- ...props.sx,
+ ...sx,
justifyContent: "center",
alignItems: "center",
flexShrink: 0
@@ -221,14 +251,14 @@ function createIcon(name, rotate = false) {
onMouseEnter={() => setIsHovering(true)}
onMouseLeave={() => setIsHovering(false)}
>
- <Icon
+ <MDIIconWrapper
title={props.title}
- name={name}
- rotate={rotate}
+ path={path}
+ rotate={_rotate}
+ size={size}
color={
props.hoverColor && isHovering ? props.hoverColor : props.color
}
- {...props}
/>
</AnimatedFlex>
);
@@ -290,7 +320,7 @@ export const PinFilled = createIcon(mdiPin);
export const User = createIcon(mdiAccountOutline);
export const DarkMode = createIcon(mdiWeatherNight);
export const LightMode = createIcon(mdiWeatherSunny);
-export const Theme = createIcon(mdiThemeLightDark);
+export const ThemeIcon = createIcon(mdiThemeLightDark);
export const Checkmark = createIcon(mdiCheck);
export const DoubleCheckmark = createIcon(mdiCheckAll);
export const CheckCircle = createIcon(mdiCheckCircle);
@@ -366,11 +396,11 @@ export const Pro = createIcon(mdiCrownOutline);
export const EncryptedBackup = createIcon(mdiDatabaseLockOutline);
export const Accent = createIcon(mdiPaletteSwatchOutline);
-export const iOS = createIcon(mdiAppleIos);
+export const Ios = createIcon(mdiAppleIos);
export const Android = createIcon(mdiAndroid);
export const Windows = createIcon(mdiMicrosoftWindows);
export const Linux = createIcon(mdiLinux);
-export const MacOS = createIcon(mdiApple);
+export const MacOs = createIcon(mdiApple);
export const Chrome = createIcon(mdiGoogleChrome);
export const Firefox = createIcon(mdiFirefox);
export const Safari = createIcon(mdiAppleSafari);
@@ -395,11 +425,11 @@ export const OrderNewestOldest = createIcon(mdiOrderNumericAscending);
export const Saved = createIcon(mdiContentSaveCheckOutline);
export const NotSaved = createIcon(mdiContentSaveAlertOutline);
-export const MFAAuthenticator = createIcon(mdiCellphoneKey);
-export const MFAEmail = createIcon(mdiEmailOutline);
-export const MFARecoveryCode = createIcon(mdiRestore);
-export const MFASMS = createIcon(mdiMessageLockOutline);
-export const MFAEnabled = createIcon(mdiShieldCheckOutline);
+export const MfaAuthenticator = createIcon(mdiCellphoneKey);
+export const MfaEmail = createIcon(mdiEmailOutline);
+export const MfaRecoveryCode = createIcon(mdiRestore);
+export const MfaSms = createIcon(mdiMessageLockOutline);
+export const MfaEnabled = createIcon(mdiShieldCheckOutline);
export const Reupload = createIcon(mdiProgressUpload);
export const Rename = createIcon(mdiFormTextbox);
export const Upload = createIcon(mdiCloudOffOutline);
diff --git a/apps/web/src/components/icons/resolver.js b/apps/web/src/components/icons/resolver.ts
similarity index 76%
rename from apps/web/src/components/icons/resolver.js
rename to apps/web/src/components/icons/resolver.ts
index df0a605a7..0084c515d 100644
--- a/apps/web/src/components/icons/resolver.js
+++ b/apps/web/src/components/icons/resolver.ts
@@ -17,12 +17,13 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-const { toTitleCase, toCamelCase } = require("../../utils/string");
+import { toTitleCase, toCamelCase, KebabCase } from "../../utils/string";
+import * as Icons from "./index";
-var icons = undefined;
-export function getIconFromAlias(alias) {
+export function getIconFromAlias<T extends KebabCase<keyof typeof Icons>>(
+ alias: T
+) {
if (!alias) return;
const iconName = toTitleCase(toCamelCase(alias));
- if (!icons) icons = require("./index");
- return icons[iconName];
+ return Icons[iconName as keyof typeof Icons];
}
diff --git a/apps/web/src/utils/string.js b/apps/web/src/utils/string.js
deleted file mode 100644
index d57eed72a..000000000
--- a/apps/web/src/utils/string.js
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
-This file is part of the Notesnook project (https://notesnook.com/)
-
-Copyright (C) 2022 Streetwriters (Private) Limited
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-export function toTitleCase(str) {
- if (!str || !str[0]) {
- return "";
- }
- return str[0].toUpperCase() + str.substring(1);
-}
-
-export function toCamelCase(str) {
- return str.replaceAll(/-(.{1})/gm, (_str, letter) => {
- return letter.toUpperCase();
- });
-}
-
-/**
- *
- * @param {String} str
- */
-export function countWords(str) {
- str = str.trim();
- if (!str.length) return 0;
- return str.split(/\W+\S/).length;
-}
-
-/**
- *
- * @param {string} count
- * @param {string} singular
- * @param {string} plural
- */
-export function pluralize(count, singular, plural) {
- return !count || count > 1 ? `${count} ${plural}` : `${count} ${singular}`;
-}
diff --git a/apps/web/src/utils/string.ts b/apps/web/src/utils/string.ts
new file mode 100644
index 000000000..3f484a656
--- /dev/null
+++ b/apps/web/src/utils/string.ts
@@ -0,0 +1,72 @@
+/*
+This file is part of the Notesnook project (https://notesnook.com/)
+
+Copyright (C) 2022 Streetwriters (Private) Limited
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+type TitleCase<T extends string, D extends string = " "> = string extends T
+ ? never
+ : T extends `${infer F}${D}${infer R}`
+ ? `${Capitalize<F>}${D}${TitleCase<R, D>}`
+ : Capitalize<T>;
+
+type Separator = " " | "-" | "_";
+
+type CamelCase<T extends string> = T extends `${Separator}${infer Suffix}`
+ ? CamelCase<Suffix>
+ : T extends `${infer Prefix}${Separator}`
+ ? CamelCase<Prefix>
+ : T extends `${infer Prefix}${Separator}${infer Suffix}`
+ ? CamelCase<`${Prefix}${Capitalize<Suffix>}`>
+ : T;
+
+type KebabCaseHelper<
+ S,
+ Acc extends string = ""
+> = S extends `${infer C}${infer T}`
+ ? KebabCaseHelper<
+ T extends Uncapitalize<T> ? T : Uncapitalize<T>,
+ `${Acc}${Lowercase<C>}${T extends Uncapitalize<T> ? "" : "-"}`
+ >
+ : Acc;
+export type KebabCase<S extends string> = KebabCaseHelper<S>;
+
+export function toTitleCase<T extends string>(str: T): TitleCase<T> | "" {
+ if (!str || !str[0]) {
+ return "";
+ }
+ return (str[0].toUpperCase() + str.substring(1)) as TitleCase<T>;
+}
+
+export function toCamelCase<T extends string>(str: T): CamelCase<T> {
+ return str.replaceAll(/-(.{1})/gm, (_str, letter) => {
+ return letter.toUpperCase();
+ }) as CamelCase<T>;
+}
+
+export function countWords(str: string): number {
+ str = str.trim();
+ if (!str.length) return 0;
+ return str.split(/\W+\S/).length;
+}
+
+export function pluralize(
+ count: number,
+ singular: string,
+ plural: string
+): string {
+ return !count || count > 1 ? `${count} ${plural}` : `${count} ${singular}`;
+}
diff --git a/apps/web/src/utils/toast.tsx b/apps/web/src/utils/toast.tsx
index 6a33eafcc..5d2aefd3b 100644
--- a/apps/web/src/utils/toast.tsx
+++ b/apps/web/src/utils/toast.tsx
@@ -22,6 +22,7 @@ import ThemeProvider from "../components/theme-provider";
import { Error, Warn, Success } from "../components/icons";
import { store as appstore } from "../stores/app-store";
import toast from "react-hot-toast";
+import { Theme } from "@notesnook/theme";
type ToastType = "success" | "error" | "warn" | "info";
type ToastAction = {
@@ -41,7 +42,9 @@ function showToast(
const IconComponent =
type === "error" ? Error : type === "success" ? Success : Warn;
- const RenderedIcon = () => <IconComponent size={28} color={type} />;
+ const RenderedIcon = () => (
+ <IconComponent size={28} color={type as keyof Theme["colors"]} />
+ );
const id = toast(<ToastContainer message={message} actions={actions} />, {
duration: hideAfter || Infinity,
diff --git a/apps/web/src/views/auth.tsx b/apps/web/src/views/auth.tsx
index 55eaf40f7..314915ed1 100644
--- a/apps/web/src/views/auth.tsx
+++ b/apps/web/src/views/auth.tsx
@@ -18,17 +18,18 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
-import { BoxProps, Button, Flex, Link, Text } from "@theme-ui/components";
+import { Button, Flex, Link, Text } from "@theme-ui/components";
import {
CheckCircle,
Loading,
Error as ErrorIcon,
- MFAAuthenticator,
- MFASMS,
- MFAEmail,
- MFARecoveryCode,
+ MfaAuthenticator,
+ MfaSms,
+ MfaEmail,
+ MfaRecoveryCode,
ArrowRight,
- Logout
+ Logout,
+ Icon
} from "../components/icons";
import Field from "../components/field";
import { getQueryParams, hardNavigate, makeURL } from "../navigation";
@@ -667,13 +668,13 @@ type MFAMethodType = AuthenticatorType | "recoveryCode";
type MFAMethod = {
type: MFAMethodType;
title: string;
- icon: (props: BoxProps & { size: number }) => JSX.Element;
+ icon: Icon;
};
const MFAMethods: MFAMethod[] = [
- { type: "app", title: "Use an authenticator app", icon: MFAAuthenticator },
- { type: "sms", title: "Send code to your phone number", icon: MFASMS },
- { type: "email", title: "Send code to your email address", icon: MFAEmail },
- { type: "recoveryCode", title: "Use a recovery code", icon: MFARecoveryCode }
+ { type: "app", title: "Use an authenticator app", icon: MfaAuthenticator },
+ { type: "sms", title: "Send code to your phone number", icon: MfaSms },
+ { type: "email", title: "Send code to your email address", icon: MfaEmail },
+ { type: "recoveryCode", title: "Use a recovery code", icon: MfaRecoveryCode }
];
function MFASelector(props: BaseAuthComponentProps<"mfa:select">) {
const { navigate, formData } = props;