π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
[web] Use Hugeicons directly in notifications
AswinAsok7526f90fe4c4
diff --git a/web/apps/photos/tests/notification-icons.test.tsx b/web/apps/photos/tests/notification-icons.test.tsxindex 7b9b555031..5dc7e45f19 100644--- a/web/apps/photos/tests/notification-icons.test.tsx+++ b/web/apps/photos/tests/notification-icons.test.tsx@@ -1,5 +1,4 @@import { Copy01Icon, ReloadIcon, Tick02Icon } from "@hugeicons/core-free-icons";-import { HugeiconsIcon } from "@hugeicons/react";import { ThemeProvider } from "@mui/material";import {Notification,@@ -56,26 +55,6 @@ describe("notification icons", () => {}});- test("preserves custom icon elements and their sizing", () => {- const markup = renderNotification({- startIcon: null,- endIcon: (- <span data-testid="custom-copy">- <HugeiconsIcon- icon={Copy01Icon}- size={18}- strokeWidth={2}- />- </span>- ),- });- expect(markup).toContain('data-testid="custom-copy"');- const icons = markup.match(/<svg\b[^>]*>/g) ?? [];- expect(icons).toHaveLength(2);- expect(icons[0]).toContain('width="18"');- expect(icons[0]).toContain('stroke-width="2"');- });-test("keeps the default leading icon and allows explicitly omitting it", () => {const defaultMarkup = renderNotification({});const noLeadingIconMarkup = renderNotification({ startIcon: null });diff --git a/web/packages/base/components/Notification.tsx b/web/packages/base/components/Notification.tsxindex 7ff934e58b..af49a9ee48 100644--- a/web/packages/base/components/Notification.tsx+++ b/web/packages/base/components/Notification.tsx@@ -23,16 +23,13 @@ import { isSxArray } from "ente-base/components/utils/sx";import { t } from "i18next";import React from "react";-type NotificationIcon = IconSvgElement | React.ReactElement | null;-export interface NotificationAttributes {color: ButtonProps["color"];- // Set to null to omit the leading icon.- startIcon?: NotificationIcon;+ startIcon?: IconSvgElement | null;title: React.ReactNode;caption?: React.ReactNode;onClick?: () => void;- endIcon?: NotificationIcon;+ endIcon?: IconSvgElement;endIconLabel?: string;onEndIconClick?: () => void;}@@ -42,18 +39,10 @@ type NotificationProps = ModalVisibilityProps & {keepOpenOnClick?: boolean;horizontal?: "left" | "right";vertical?: "top" | "bottom";- // Set to null to keep the notification open until dismissed.autoHideDuration?: number | null;sx?: SxProps<Theme>;};-const renderIcon = (icon: NotificationIcon | undefined, size: number) =>- React.isValidElement(icon) || icon == null ? (- icon- ) : (- <HugeiconsIcon icon={icon} size={size} strokeWidth={1.8} />- );-const actionButtonSx = {width: 38,height: 38,@@ -133,7 +122,11 @@ export const Notification: React.FC<NotificationProps> = ({svg: { width: 24, height: 24, fontSize: 24 },}}>- {renderIcon(startIcon ?? InformationCircleIcon, 24)}+ <HugeiconsIcon+ icon={startIcon ?? InformationCircleIcon}+ size={24}+ strokeWidth={1.8}+ /></Stack>)}<Stack@@ -250,7 +243,11 @@ export const Notification: React.FC<NotificationProps> = ({}}sx={buttonSx}>- {renderIcon(endIcon, 22)}+ <HugeiconsIcon+ icon={endIcon}+ size={22}+ strokeWidth={1.8}+ /></IconButton>)}<IconButton@@ -261,7 +258,11 @@ export const Notification: React.FC<NotificationProps> = ({}}sx={buttonSx}>- {renderIcon(Cancel01Icon, 22)}+ <HugeiconsIcon+ icon={Cancel01Icon}+ size={22}+ strokeWidth={1.8}+ /></IconButton></Stack></Paper>diff --git a/web/packages/gallery/components/DownloadStatusNotifications.tsx b/web/packages/gallery/components/DownloadStatusNotifications.tsxindex ce6bed3862..23e6ee1bcc 100644--- a/web/packages/gallery/components/DownloadStatusNotifications.tsx+++ b/web/packages/gallery/components/DownloadStatusNotifications.tsx@@ -5,15 +5,7 @@ import {ReloadIcon,Tick02Icon,} from "@hugeicons/core-free-icons";-import { HugeiconsIcon } from "@hugeicons/react";-import {- Box,- Button,- Dialog,- keyframes,- styled,- Typography,-} from "@mui/material";+import { Box, Button, Dialog, styled, Typography } from "@mui/material";import {Notification,type NotificationAttributes,@@ -186,22 +178,14 @@ export const DownloadStatusNotifications: React.FC<if (hasErrors) {startIcon = AlertCircleIcon;} else if (isComplete) {- startIcon = (- <GlowingIconWrapper>- <HugeiconsIcon icon={Tick02Icon} size={28} />- </GlowingIconWrapper>- );+ startIcon = Tick02Icon;} else if (group.total === 1 ||(isZipDownload && !group.isDownloadingZip)) {- startIcon = <SpinningIcon />;+ startIcon = Loading03Icon;} else {- startIcon = (- <DroppingIconWrapper>- <HugeiconsIcon icon={Download01Icon} size={28} />- </DroppingIconWrapper>- );+ startIcon = Download01Icon;}const filesCountTitle = t("files_count", {@@ -382,47 +366,3 @@ const StopDownloadPrimaryButton = styled(Button)(({ theme }) => ({color: theme.vars.palette.critical.contrastText,"&:hover": { backgroundColor: theme.vars.palette.critical.dark },}));--const spinAnimation = keyframes`- from { transform: rotate(0deg); }- to { transform: rotate(360deg); }-`;--const dropAnimation = keyframes`- 0% { transform: translateY(-100%); opacity: 0.15; }- 50% { transform: translateY(10%); opacity: 0.6; }- 100% { transform: translateY(0); opacity: 1; }-`;--const glowAnimation = keyframes`- 0% { color: var(--mui-palette-fixed-success); }- 100% { color: inherit; }-`;--const fadeInAnimation = keyframes`- 0% { opacity: 0; }- 100% { opacity: 1; }-`;--const DroppingIconWrapper = styled("span")`- display: inline-flex;- animation: ${dropAnimation} 0.8s ease-out forwards;-`;--const GlowingIconWrapper = styled("span")`- display: inline-flex;- animation: ${glowAnimation} 2s ease-out forwards;-`;--const SpinningIconWrapper = styled("span")`- display: inline-flex;- animation:- ${fadeInAnimation} 0.5s ease-out forwards,- ${spinAnimation} 3s linear infinite;-`;--const SpinningIcon: React.FC = () => (- <SpinningIconWrapper>- <HugeiconsIcon icon={Loading03Icon} size={28} />- </SpinningIconWrapper>-);