Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Deduplicate shared web UI components

Anand Baburajand3235b6cd155
diff --git a/web/apps/albums/src/app/context/albums-app-context.ts b/web/apps/albums/src/app/context/albums-app-context.ts
index f1862145cf..35739da735 100644
--- a/web/apps/albums/src/app/context/albums-app-context.ts
+++ b/web/apps/albums/src/app/context/albums-app-context.ts
@@ -1,4 +1,4 @@
-import type { NotificationAttributes } from "@/shared/ui/feedback/Notification";
+import type { NotificationAttributes } from "ente-base/components/Notification";
import { createContext, useContext } from "react";
/**
diff --git a/web/apps/albums/src/app/hooks/useNotification.ts b/web/apps/albums/src/app/hooks/useNotification.ts
index 0ace4417ed..8d8cc56646 100644
--- a/web/apps/albums/src/app/hooks/useNotification.ts
+++ b/web/apps/albums/src/app/hooks/useNotification.ts
@@ -1,4 +1,4 @@
-import type { NotificationAttributes } from "@/shared/ui/feedback/Notification";
+import type { NotificationAttributes } from "ente-base/components/Notification";
import { useCallback, useState } from "react";
/**
diff --git a/web/apps/albums/src/app/lazy/global-ui.ts b/web/apps/albums/src/app/lazy/global-ui.ts
index fe52ba20a3..e051326e70 100644
--- a/web/apps/albums/src/app/lazy/global-ui.ts
+++ b/web/apps/albums/src/app/lazy/global-ui.ts
@@ -2,7 +2,7 @@ import dynamic from "next/dynamic";
export const LazyNotification = dynamic(
() =>
- import("@/shared/ui/feedback/Notification").then(
+ import("ente-base/components/Notification").then(
({ Notification }) => Notification,
),
{ ssr: false },
diff --git a/web/apps/albums/src/app/providers/AlbumsAppProviders.tsx b/web/apps/albums/src/app/providers/AlbumsAppProviders.tsx
index eff38c4fc0..ca44cf6307 100644
--- a/web/apps/albums/src/app/providers/AlbumsAppProviders.tsx
+++ b/web/apps/albums/src/app/providers/AlbumsAppProviders.tsx
@@ -4,7 +4,6 @@ import {
LazyAttributedMiniDialog,
LazyNotification,
} from "@/app/lazy/global-ui";
-import { useLoadingBar } from "@/shared/hooks/useLoadingBar";
import { ThemedLoadingBar } from "@/shared/ui/feedback/ThemedLoadingBar";
import { CssBaseline } from "@mui/material";
import { ThemeProvider } from "@mui/material/styles";
@@ -14,6 +13,7 @@ import { LoadingIndicator } from "ente-base/components/loaders";
import { useAttributedMiniDialog } from "ente-base/components/utils/dialog";
import { useSetupI18n } from "ente-base/components/utils/hooks-app";
import { photosTheme } from "ente-base/components/utils/theme";
+import { useLoadingBar } from "ente-base/components/utils/use-loading-bar";
import { BaseContext, deriveBaseContext } from "ente-base/context";
import { t } from "i18next";
import { useCallback, useMemo, type PropsWithChildren } from "react";
diff --git a/web/apps/albums/src/public-album/download/components/ActiveDownloadStatusNotifications.tsx b/web/apps/albums/src/public-album/download/components/ActiveDownloadStatusNotifications.tsx
index 798317892f..6356e42353 100644
--- a/web/apps/albums/src/public-album/download/components/ActiveDownloadStatusNotifications.tsx
+++ b/web/apps/albums/src/public-album/download/components/ActiveDownloadStatusNotifications.tsx
@@ -1,11 +1,11 @@
+import type { DownloadStatusNotificationsProps } from "ente-gallery/components/DownloadStatusNotifications";
import { useSaveGroups } from "ente-gallery/components/utils/save-groups";
import dynamic from "next/dynamic";
-import type { DownloadStatusNotificationsProps } from "./DownloadStatusNotifications";
const LazyDownloadStatusNotifications =
dynamic<DownloadStatusNotificationsProps>(
() =>
- import("./DownloadStatusNotifications").then(
+ import("ente-gallery/components/DownloadStatusNotifications").then(
({ DownloadStatusNotifications }) =>
DownloadStatusNotifications,
),
diff --git a/web/apps/albums/src/public-album/download/components/DownloadStatusNotifications.tsx b/web/apps/albums/src/public-album/download/components/DownloadStatusNotifications.tsx
deleted file mode 100644
index f79cdc49c3..0000000000
--- a/web/apps/albums/src/public-album/download/components/DownloadStatusNotifications.tsx
+++ /dev/null
@@ -1,463 +0,0 @@
-import { Notification } from "@/shared/ui/feedback/Notification";
-import {
- Download01Icon,
- Loading03Icon,
- Tick02Icon,
-} from "@hugeicons/core-free-icons";
-import { HugeiconsIcon } from "@hugeicons/react";
-import ErrorOutlineIcon from "@mui/icons-material/ErrorOutline";
-import ReplayIcon from "@mui/icons-material/Replay";
-import {
- Box,
- Button,
- Dialog,
- keyframes,
- styled,
- Typography,
-} from "@mui/material";
-import { useBaseContext } from "ente-base/context";
-import {
- isSaveComplete,
- isSaveCompleteWithErrors,
- type SaveGroup,
-} from "ente-gallery/components/utils/save-groups";
-import { t } from "i18next";
-import { useState } from "react";
-
-/** Maximum characters for album name before truncation */
-const MAX_ALBUM_NAME_LENGTH = 25;
-const SINGLE_FILE_SUCCESS_AUTO_CLOSE_DELAY_MS = 3000;
-
-/** Truncate album name with ellipsis if it exceeds max length */
-const truncateAlbumName = (name: string): string => {
- if (name.length <= MAX_ALBUM_NAME_LENGTH) return name;
- return name.slice(0, MAX_ALBUM_NAME_LENGTH) + "...";
-};
-
-export interface DownloadStatusNotificationsProps {
- /**
- * A list of user-initiated downloads for which a status should be shown.
- *
- * An entry is added to this list when the user initiates the download, and
- * remains here until the user explicitly closes the corresponding
- * {@link Notification} component that was showing the save group's status.
- */
- saveGroups: SaveGroup[];
- /**
- * Called when the user closes the download status associated with the given
- * {@link saveGroup}.
- */
- onRemoveSaveGroup: (saveGroup: SaveGroup) => void;
- /**
- * If true, make each notification full width on mobile phones (MUI "sm"
- * and below). Tablet and desktop widths remain unchanged.
- */
- fullWidthOnMobile?: boolean;
-}
-
-/**
- * A component that shows a list of notifications, one each for an active
- * user-initiated download.
- */
-export const DownloadStatusNotifications: React.FC<
- DownloadStatusNotificationsProps
-> = ({ saveGroups, onRemoveSaveGroup, fullWidthOnMobile }) => {
- const { showMiniDialog } = useBaseContext();
- const fileLabel = t("file").toLowerCase();
- const [cancelDownloadGroup, setCancelDownloadGroup] =
- useState<SaveGroup | null>(null);
-
- const closeCancelDownloadDialog = () => setCancelDownloadGroup(null);
-
- const confirmCancelDownload = (group: SaveGroup) => {
- if (fullWidthOnMobile) {
- setCancelDownloadGroup(group);
- return;
- }
-
- showMiniDialog({
- title: t("stop_downloads_title"),
- message: t("stop_downloads_message"),
- continue: {
- text: t("yes_stop_downloads"),
- color: "critical",
- action: () => {
- group.canceller.abort();
- onRemoveSaveGroup(group);
- },
- },
- cancel: t("no"),
- });
- };
-
- const handleConfirmCancelDownload = () => {
- if (!cancelDownloadGroup) return;
- cancelDownloadGroup.canceller.abort();
- onRemoveSaveGroup(cancelDownloadGroup);
- closeCancelDownloadDialog();
- };
-
- const createOnClose = (group: SaveGroup) => () => {
- if (isSaveComplete(group)) {
- onRemoveSaveGroup(group);
- } else {
- confirmCancelDownload(group);
- }
- };
-
- return (
- <>
- {saveGroups.map((group, index) => {
- const hasErrors = isSaveCompleteWithErrors(group);
- const isComplete = isSaveComplete(group);
- const canRetry = hasErrors && !!group.retry;
- const shouldAutoClose =
- group.total === 1 && isComplete && !hasErrors;
-
- // Determine if this is a ZIP download (web with multiple files or live photo)
- const isZipDownload = !group.downloadDirPath && group.total > 1;
- const shouldShowZipPart =
- isZipDownload &&
- (group.includeZipNumber || (group.currentPart ?? 1) > 1);
- const isDesktopOrSingleFile =
- !!group.downloadDirPath || group.total === 1;
-
- // Build the status text for the caption
- let statusText: React.ReactNode;
- if (hasErrors) {
- // Show specific error message based on failure reason
- if (group.failureReason === "network_offline") {
- statusText = t("download_failed_network_offline");
- } else if (group.failureReason === "file_error") {
- statusText = t("download_failed_file_error");
- } else {
- statusText = t("download_failed");
- }
- } else if (isComplete) {
- statusText = t("download_complete");
- } else if (shouldShowZipPart) {
- const part = group.currentPart ?? 1;
- statusText = group.isDownloadingZip
- ? t("downloading_part", { part })
- : t("preparing_part", { part });
- } else if (isZipDownload) {
- statusText = group.isDownloadingZip
- ? t("downloading")
- : t("preparing");
- } else if (isDesktopOrSingleFile) {
- statusText =
- group.total === 1
- ? t("downloading_file")
- : t("downloading_files");
- } else {
- statusText = t("downloading");
- }
-
- // Build caption: "Status β€’ X / Y files"
- const completedCount = group.success + group.failed;
- const progress =
- group.total === 1
- ? `${t("processed_counts", {
- count: completedCount,
- total: group.total,
- })} ${fileLabel}`
- : t("download_progress", {
- count: completedCount,
- total: group.total,
- });
- const caption = (
- <Box
- component="span"
- sx={{
- color: hasErrors ? "white" : "text.muted",
- fontVariantNumeric: "tabular-nums",
- }}
- >
- {statusText}
- {!isComplete && (
- <>
- {" "}
- {"\u2022"} {progress}
- </>
- )}
- </Box>
- );
-
- // Determine the start icon based on state
- let startIcon: React.ReactNode;
- if (hasErrors) {
- startIcon = <ErrorOutlineIcon />;
- } else if (isComplete) {
- startIcon = (
- <GlowingIconWrapper>
- <HugeiconsIcon icon={Tick02Icon} size={28} />
- </GlowingIconWrapper>
- );
- } else if (isZipDownload && !group.isDownloadingZip) {
- // Preparing state - use loading icon
- startIcon = <SpinningIcon />;
- } else {
- // Downloading state
- startIcon = (
- <DroppingIconWrapper>
- <HugeiconsIcon icon={Download01Icon} size={28} />
- </DroppingIconWrapper>
- );
- }
-
- // Title is always the album name (truncated)
- const filesCountTitle = t("files_count", {
- count: group.total,
- });
- const title =
- group.total === 1 && group.title === filesCountTitle
- ? `${group.total} ${fileLabel}`
- : group.title;
- const truncatedName = truncateAlbumName(title);
-
- return (
- <Notification
- key={group.id}
- horizontal="left"
- sx={(theme) => ({
- "&&": { bottom: `${index * 80 + 20}px` },
- width: "min(400px, 100vw)",
- borderRadius: "20px",
- "& .MuiButton-root": {
- borderRadius: "20px",
- padding: "16px 16px 16px 20px",
- },
- "& .MuiIconButton-root": {
- width: "40px",
- height: "40px",
- "& svg": { fontSize: "22px" },
- },
- [theme.breakpoints.down("sm")]: {
- "&&": {
- bottom: `${index * 70 + 16}px`,
- ...(fullWidthOnMobile
- ? { left: "8px" }
- : {}),
- },
- width: fullWidthOnMobile
- ? "calc(100vw - 16px)"
- : "min(340px, calc(100vw - 16px))",
- borderRadius: "16px",
- "& .MuiButton-root": {
- borderRadius: "16px",
- padding: "12px 12px 12px 16px",
- },
- "& .MuiIconButton-root": {
- width: "36px",
- height: "36px",
- "& svg": { fontSize: "20px" },
- },
- },
- })}
- open={true}
- onClose={createOnClose(group)}
- autoHideDuration={
- shouldAutoClose
- ? SINGLE_FILE_SUCCESS_AUTO_CLOSE_DELAY_MS
- : undefined
- }
- keepOpenOnClick
- attributes={{
- color: hasErrors ? "critical" : "secondary",
- startIcon,
- title: truncatedName,
- caption,
- endIcon: canRetry ? (
- <ReplayIcon
- titleAccess={t("retry")}
- sx={{ color: "white" }}
- />
- ) : undefined,
- onEndIconClick: canRetry
- ? () => group.retry?.()
- : undefined,
- }}
- />
- );
- })}
-
- {fullWidthOnMobile && (
- <StyledStopDownloadDialog
- open={!!cancelDownloadGroup}
- onClose={closeCancelDownloadDialog}
- >
- <StopDownloadDialogWrapper>
- <StopDownloadTitleSection>
- <Typography
- sx={{
- fontWeight: 600,
- fontSize: 24,
- lineHeight: "28px",
- letterSpacing: "-0.48px",
- textAlign: "center",
- }}
- >
- {t("stop_downloads_title")}
- </Typography>
- <StopDownloadSubtitle>
- {t("stop_downloads_message")}
- </StopDownloadSubtitle>
- </StopDownloadTitleSection>
- <StopDownloadButtonsSection>
- <StopDownloadPrimaryButton
- fullWidth
- onClick={handleConfirmCancelDownload}
- >
- {t("yes_stop_downloads")}
- </StopDownloadPrimaryButton>
- <StopDownloadSecondaryButton
- fullWidth
- onClick={closeCancelDownloadDialog}
- >
- {t("no")}
- </StopDownloadSecondaryButton>
- </StopDownloadButtonsSection>
- </StopDownloadDialogWrapper>
- </StyledStopDownloadDialog>
- )}
- </>
- );
-};
-
-const StyledStopDownloadDialog = styled(Dialog)(({ theme }) => ({
- "& .MuiDialog-paper": {
- width: 381,
- maxWidth: "calc(100% - 32px)",
- borderRadius: 28,
- backgroundColor: "#fff",
- padding: 0,
- margin: 16,
- boxShadow: "none",
- border: "1px solid #E0E0E0",
- ...theme.applyStyles("dark", {
- backgroundColor: "#1b1b1b",
- border: "1px solid rgba(255, 255, 255, 0.18)",
- }),
- },
- "& .MuiBackdrop-root": { backgroundColor: "rgba(0, 0, 0, 0.5)" },
-}));
-
-const StopDownloadDialogWrapper = styled(Box)(() => ({
- padding: "40px 16px 16px 16px",
-}));
-
-const StopDownloadTitleSection = styled(Box)(() => ({
- display: "flex",
- flexDirection: "column",
- alignItems: "center",
- justifyContent: "center",
- gap: 9,
- textAlign: "center",
- marginBottom: 36,
-}));
-
-const StopDownloadButtonsSection = styled(Box)(() => ({
- width: "100%",
- display: "flex",
- flexDirection: "column",
- gap: 12,
-}));
-
-const StopDownloadSubtitle = styled(Typography)(({ theme }) => ({
- fontWeight: 500,
- fontSize: 14,
- lineHeight: "20px",
- color: "#666666",
- maxWidth: 295,
- textAlign: "center",
- marginInline: "auto",
- ...theme.applyStyles("dark", { color: "rgba(255, 255, 255, 0.7)" }),
-}));
-
-const StopDownloadSecondaryButton = styled(Button)(({ theme }) => ({
- display: "flex",
- padding: "20px 16px",
- justifyContent: "center",
- alignItems: "center",
- gap: 8,
- borderRadius: 20,
- backgroundColor: "rgba(0, 0, 0, 0.04)",
- border: "none",
- fontSize: 16,
- fontWeight: 500,
- textTransform: "none",
- color: "#000",
- "&:hover": { backgroundColor: "rgba(0, 0, 0, 0.08)", border: "none" },
- ...theme.applyStyles("dark", {
- backgroundColor: "rgba(255, 255, 255, 0.08)",
- color: "#fff",
- "&:hover": { backgroundColor: "rgba(255, 255, 255, 0.12)" },
- }),
-}));
-
-const StopDownloadPrimaryButton = styled(Button)(({ theme }) => ({
- display: "flex",
- padding: "20px 16px",
- justifyContent: "center",
- alignItems: "center",
- gap: 8,
- borderRadius: 20,
- backgroundColor: theme.vars.palette.critical.main,
- fontSize: 16,
- fontWeight: 500,
- textTransform: "none",
- color: theme.vars.palette.critical.contrastText,
- "&:hover": { backgroundColor: theme.vars.palette.critical.dark },
-}));
-
-/** CSS keyframes for spinning animation */
-const spinAnimation = keyframes`
- from { transform: rotate(0deg); }
- to { transform: rotate(360deg); }
-`;
-
-/** CSS keyframes for drop from top animation */
-const dropAnimation = keyframes`
- 0% { transform: translateY(-100%); opacity: 0.15; }
- 50% { transform: translateY(10%); opacity: 0.6; }
- 100% { transform: translateY(0); opacity: 1; }
-`;
-
-/** CSS keyframes for green glow animation */
-const glowAnimation = keyframes`
- 0% { color: var(--mui-palette-fixed-success); }
- 100% { color: inherit; }
-`;
-
-/** CSS keyframes for fade in animation */
-const fadeInAnimation = keyframes`
- 0% { opacity: 0; }
- 100% { opacity: 1; }
-`;
-
-/** Drop animation icon wrapper */
-const DroppingIconWrapper = styled("span")`
- display: inline-flex;
- animation: ${dropAnimation} 0.8s ease-out forwards;
-`;
-
-/** Glowing icon wrapper for success state */
-const GlowingIconWrapper = styled("span")`
- display: inline-flex;
- animation: ${glowAnimation} 2s ease-out forwards;
-`;
-
-/** Spinning loading icon wrapper */
-const SpinningIconWrapper = styled("span")`
- display: inline-flex;
- animation:
- ${fadeInAnimation} 0.5s ease-out forwards,
- ${spinAnimation} 3s linear infinite;
-`;
-
-/** Spinning loading icon */
-const SpinningIcon: React.FC = () => (
- <SpinningIconWrapper>
- <HugeiconsIcon icon={Loading03Icon} size={28} />
- </SpinningIconWrapper>
-);
diff --git a/web/apps/albums/src/public-album/page/PublicAlbumPage.tsx b/web/apps/albums/src/public-album/page/PublicAlbumPage.tsx
index 70dbe27f4e..252451a3ef 100644
--- a/web/apps/albums/src/public-album/page/PublicAlbumPage.tsx
+++ b/web/apps/albums/src/public-album/page/PublicAlbumPage.tsx
@@ -22,7 +22,6 @@ import { ActiveDownloadStatusNotifications } from "@/public-album/download/compo
import { downloadManager } from "@/public-album/download/services/download-manager";
import { thumbnailManager } from "@/public-album/media/thumbnails/thumbnail-manager";
import { sortFiles } from "@/public-album/media/utils/sort-files";
-import type { FullScreenDropZoneProps } from "@/public-album/upload/components/CollectDropZone";
import type { UploadProps } from "@/public-album/upload/components/Upload";
import {
getSelectedFiles,
@@ -62,6 +61,7 @@ import {
} from "ente-base/http";
import log from "ente-base/log";
import { apiOrigin, isCustomAPIOrigin } from "ente-base/origins";
+import type { FullScreenDropZoneProps } from "ente-gallery/components/FullScreenDropZone";
import {
useSaveGroupsActions,
type AddSaveGroup,
@@ -999,7 +999,7 @@ const LazyCollectDropZone: React.FC<LazyCollectDropZoneProps> = ({
if (!enabled || DropZoneComponent) return;
let isCancelled = false;
- void import("@/public-album/upload/components/CollectDropZone").then(
+ void import("ente-gallery/components/FullScreenDropZone").then(
({ FullScreenDropZone }) => {
if (isCancelled) return;
setDropZoneComponent(() => FullScreenDropZone);
diff --git a/web/apps/albums/src/public-album/upload/components/CollectDropZone.tsx b/web/apps/albums/src/public-album/upload/components/CollectDropZone.tsx
deleted file mode 100644
index 458444f5ad..0000000000
--- a/web/apps/albums/src/public-album/upload/components/CollectDropZone.tsx
+++ /dev/null
@@ -1,176 +0,0 @@
-import CloseIcon from "@mui/icons-material/Close";
-import { IconButton, Stack, styled, Typography } from "@mui/material";
-import { ActivityIndicator } from "ente-base/components/mui/ActivityIndicator";
-import { t } from "i18next";
-import React, { useCallback, useEffect, useState } from "react";
-import { type FileWithPath, useDropzone } from "react-dropzone";
-
-const hasDraggedFiles = (
- dataTransfer: DataTransfer | null | undefined,
-): boolean => {
- if (!dataTransfer) return false;
-
- for (const item of Array.from(dataTransfer.items)) {
- if (item.kind == "file") return true;
- }
-
- for (const type of Array.from(dataTransfer.types)) {
- if (type == "Files") return true;
- }
-
- return false;
-};
-
-export interface FullScreenDropZoneProps {
- /**
- * Optional override to the message show to the user when a drag is in
- * progress.
- *
- * Default: t("upload_dropzone_hint")
- */
- message?: string;
- /**
- * If `true`, then drag and drop functionality is disabled.
- */
- disabled?: boolean;
- /**
- * Callback invoked when the user drags and drops files.
- *
- * It will only be called if there is at least one file in {@link files}.
- */
- onDrop: (files: FileWithPath[]) => void;
-}
-
-/**
- * A full screen container that accepts drag and drop of files, and also shows a
- * visual overlay to the user while a drag is in progress.
- *
- * It can serves as the root component of the gallery pages as the container
- * itself is a stack with flex 1, and so will fill all the height (and width)
- * available to it. The other contents of the screen can then be placed as its
- * children.
- *
- * It is meant to be used in tandem with "react-dropzone"; specifically, it
- * requires the `getRootProps` function returned by a call to
- * {@link useDropzone}.
- */
-export const FullScreenDropZone: React.FC<
- React.PropsWithChildren<FullScreenDropZoneProps>
-> = ({ message, disabled, onDrop, children }) => {
- const {
- // A function to call to get the props we should apply to the container,
- getRootProps,
- // ... the props we should apply to the <input> element,
- getInputProps,
- } = useDropzone({
- noClick: true,
- noKeyboard: true,
- disabled,
- onDrop(acceptedFiles) {
- setIsDropPending(false);
- // Invoked the `onDrop` callback only if there is at least 1 file.
- if (acceptedFiles.length) {
- // Create a regular array from the readonly array returned by
- // dropzone.
- onDrop([...acceptedFiles]);
- }
- },
- });
-
- const [isDragActive, setIsDragActive] = useState(false);
- const [isDropPending, setIsDropPending] = useState(false);
-
- const handleDragEnter = useCallback(
- (event: React.DragEvent<HTMLElement>) => {
- if (!hasDraggedFiles(event.dataTransfer)) return;
- setIsDragActive(true);
- },
- [],
- );
-
- const handleOverlayDrop = useCallback(
- (event: React.DragEvent<HTMLElement>) => {
- if (!hasDraggedFiles(event.dataTransfer)) {
- setIsDropPending(false);
- setIsDragActive(false);
- return;
- }
- setIsDropPending(true);
- setIsDragActive(false);
- },
- [],
- );
-
- const handleDragLeave = useCallback(() => {
- setIsDragActive(false);
- }, []);
-
- useEffect(() => {
- const handleKeydown = (event: KeyboardEvent) => {
- if (event.code == "Escape" && !isDropPending) handleDragLeave();
- };
-
- window.addEventListener("keydown", handleKeydown);
- return () => window.removeEventListener("keydown", handleKeydown);
- }, [isDropPending, handleDragLeave]);
-
- return (
- <>
- <input {...getInputProps()} />
- <Stack
- sx={{ flex: 1 }}
- {...getRootProps({ onDragEnter: handleDragEnter })}
- >
- {(isDragActive || isDropPending) && (
- <DropZoneOverlay
- onDrop={handleOverlayDrop}
- onDragLeave={handleDragLeave}
- >
- <CloseButton
- disabled={isDropPending}
- onClick={handleDragLeave}
- >
- <CloseIcon />
- </CloseButton>
- <Typography variant="h3">
- {isDropPending ? (
- <ActivityIndicator />
- ) : (
- (message ?? t("upload_dropzone_hint"))
- )}
- </Typography>
- </DropZoneOverlay>
- )}
- {children}
- </Stack>
- </>
- );
-};
-
-const DropZoneOverlay = styled(Stack)(
- ({ theme }) => `
- position: absolute;
- left: 0;
- top: 0;
- height: 100%;
- width: 100%;
- outline: none;
- justify-content: center;
- align-items: center;
- transition: border 0.24s ease-in-out;
- border-width: 5px;
- border-style: solid;
- border-color: ${theme.vars.palette.accent.light};
- background-color: ${theme.vars.palette.backdrop.base};
- backdrop-filter: blur(10px);
- /* Above the highest possible MUI z-index, that of the MUI tooltip
- See: https://mui.com/material-ui/customization/default-theme/ */
- z-index: calc(var(--mui-zIndex-tooltip) + 1);
-`,
-);
-
-const CloseButton = styled(IconButton)`
- position: absolute;
- top: 10px;
- right: 10px;
-`;
diff --git a/web/apps/albums/src/shared/hooks/useLoadingBar.ts b/web/apps/albums/src/shared/hooks/useLoadingBar.ts
deleted file mode 100644
index f0742bb17d..0000000000
--- a/web/apps/albums/src/shared/hooks/useLoadingBar.ts
+++ /dev/null
@@ -1,26 +0,0 @@
-import { useCallback, useRef } from "react";
-import type { LoadingBarRef } from "react-top-loading-bar";
-
-/**
- * A convenience hook for returning stable functions tied to a
- * {@link LoadingBar} ref.
- *
- * The {@link LoadingBar} component comes from the "react-top-loading-bar"
- * library. To control it, we keep a ref. We want to allow components in our
- * React tree to be able to also control the loading bar, but instead of
- * exposing the ref directly, we export wrapper functions to start and stop the
- * loading bar. This hook returns these functions (and the ref).
- */
-export const useLoadingBar = () => {
- const loadingBarRef = useRef<LoadingBarRef | null>(null);
-
- const showLoadingBar = useCallback(() => {
- loadingBarRef.current?.continuousStart();
- }, []);
-
- const hideLoadingBar = useCallback(() => {
- loadingBarRef.current?.complete();
- }, []);
-
- return { loadingBarRef, showLoadingBar, hideLoadingBar };
-};
diff --git a/web/apps/albums/src/shared/ui/feedback/ThemedLoadingBar.tsx b/web/apps/albums/src/shared/ui/feedback/ThemedLoadingBar.tsx
index 1d9b5ffa18..6e6df7853d 100644
--- a/web/apps/albums/src/shared/ui/feedback/ThemedLoadingBar.tsx
+++ b/web/apps/albums/src/shared/ui/feedback/ThemedLoadingBar.tsx
@@ -1,9 +1,10 @@
import { useTheme } from "@mui/material";
+import type { LoadingBarController } from "ente-base/components/utils/use-loading-bar";
import React from "react";
import LoadingBar, { type LoadingBarRef } from "react-top-loading-bar";
interface ThemedLoadingBarProps {
- ref: React.Ref<LoadingBarRef>;
+ ref: React.Ref<LoadingBarController>;
}
/**
@@ -13,5 +14,10 @@ interface ThemedLoadingBarProps {
export const ThemedLoadingBar: React.FC<ThemedLoadingBarProps> = ({ ref }) => {
const theme = useTheme();
- return <LoadingBar color={theme.vars.palette.accent.main} ref={ref} />;
+ return (
+ <LoadingBar
+ color={theme.vars.palette.accent.main}
+ ref={ref as React.Ref<LoadingBarRef>}
+ />
+ );
};
diff --git a/web/apps/embed/src/pages/_app.tsx b/web/apps/embed/src/pages/_app.tsx
index 074b16c1c8..f42b6921f6 100644
--- a/web/apps/embed/src/pages/_app.tsx
+++ b/web/apps/embed/src/pages/_app.tsx
@@ -8,10 +8,10 @@ import {
useSetupLogs,
} from "ente-base/components/utils/hooks-app";
import { photosTheme } from "ente-base/components/utils/theme";
+import { useLoadingBar } from "ente-base/components/utils/use-loading-bar";
import { BaseContext, deriveBaseContext } from "ente-base/context";
import { logStartupBanner } from "ente-base/log-web";
import { ThemedLoadingBar } from "ente-new/photos/components/ThemedLoadingBar";
-import { useLoadingBar } from "ente-new/photos/components/utils/use-loading-bar";
import { PhotosAppContext } from "ente-new/photos/types/context";
import type { AppProps } from "next/app";
import "photoswipe/dist/photoswipe.css";
diff --git a/web/apps/ensu/src/components/chat/ChatDialogs.tsx b/web/apps/ensu/src/components/chat/ChatDialogs.tsx
index bf7e1b6dd5..eebdc3ead4 100644
--- a/web/apps/ensu/src/components/chat/ChatDialogs.tsx
+++ b/web/apps/ensu/src/components/chat/ChatDialogs.tsx
@@ -29,7 +29,7 @@ import type { SxProps, Theme } from "@mui/material/styles";
import {
Notification,
type NotificationAttributes,
-} from "ente-new/photos/components/Notification";
+} from "ente-base/components/Notification";
import React, { memo } from "react";
interface IconProps {
diff --git a/web/apps/ensu/src/pages/chat.tsx b/web/apps/ensu/src/pages/chat.tsx
index 233b2bad54..0c97178a79 100644
--- a/web/apps/ensu/src/pages/chat.tsx
+++ b/web/apps/ensu/src/pages/chat.tsx
@@ -59,13 +59,13 @@ import {
} from "@mui/material";
import { getLuminance, useTheme } from "@mui/material/styles";
import { NavbarBase } from "ente-base/components/Navbar";
+import type { NotificationAttributes } from "ente-base/components/Notification";
import { useBaseContext } from "ente-base/context";
import { buildEnvEnsuDesktopVersion } from "ente-base/env";
import { getKV, removeKV, setKV } from "ente-base/kv";
import log from "ente-base/log";
import { savedLogs } from "ente-base/log-web";
import { saveStringAsFile } from "ente-base/utils/web";
-import type { NotificationAttributes } from "ente-new/photos/components/Notification";
import { useRouter } from "next/router";
import React, {
useCallback,
diff --git a/web/apps/photos/src/components/ActiveDownloadStatusNotifications.tsx b/web/apps/photos/src/components/ActiveDownloadStatusNotifications.tsx
index 6f5d639a02..3fc2e2f452 100644
--- a/web/apps/photos/src/components/ActiveDownloadStatusNotifications.tsx
+++ b/web/apps/photos/src/components/ActiveDownloadStatusNotifications.tsx
@@ -1,6 +1,6 @@
+import { DownloadStatusNotifications } from "ente-gallery/components/DownloadStatusNotifications";
import { useSaveGroups } from "ente-gallery/components/utils/save-groups";
import type { ComponentProps } from "react";
-import { DownloadStatusNotifications } from "./DownloadStatusNotifications";
type ActiveDownloadStatusNotificationsProps = Omit<
ComponentProps<typeof DownloadStatusNotifications>,
diff --git a/web/apps/photos/src/components/utils/hooks-app.ts b/web/apps/photos/src/components/utils/hooks-app.ts
index 9f2b1ffc88..8d8cc56646 100644
--- a/web/apps/photos/src/components/utils/hooks-app.ts
+++ b/web/apps/photos/src/components/utils/hooks-app.ts
@@ -1,4 +1,4 @@
-import type { NotificationAttributes } from "ente-new/photos/components/Notification";
+import type { NotificationAttributes } from "ente-base/components/Notification";
import { useCallback, useState } from "react";
/**
diff --git a/web/apps/photos/src/pages/_app.tsx b/web/apps/photos/src/pages/_app.tsx
index f8abd64e0b..4cf092e519 100644
--- a/web/apps/photos/src/pages/_app.tsx
+++ b/web/apps/photos/src/pages/_app.tsx
@@ -18,6 +18,7 @@ import {
TranslucentLoadingOverlay,
} from "ente-base/components/loaders";
import { AttributedMiniDialog } from "ente-base/components/MiniDialog";
+import { Notification } from "ente-base/components/Notification";
import { useAttributedMiniDialog } from "ente-base/components/utils/dialog";
import {
useIsRouteChangeInProgress,
@@ -25,6 +26,7 @@ import {
useSetupLogs,
} from "ente-base/components/utils/hooks-app";
import { photosTheme } from "ente-base/components/utils/theme";
+import { useLoadingBar } from "ente-base/components/utils/use-loading-bar";
import { BaseContext, deriveBaseContext } from "ente-base/context";
import log from "ente-base/log";
import { logStartupBanner } from "ente-base/log-web";
@@ -34,7 +36,6 @@ import {
isHLSGenerationSupported,
} from "ente-gallery/services/video";
import { AppLockReauthenticationDialog } from "ente-new/photos/components/app-lock/AppLockReauthenticationDialog";
-import { Notification } from "ente-new/photos/components/Notification";
import { ThemedLoadingBar } from "ente-new/photos/components/ThemedLoadingBar";
import {
updateAvailableForDownloadDialogAttributes,
@@ -44,7 +45,6 @@ import {
useAutoLockWhenBackgrounded,
useSetupAppLock,
} from "ente-new/photos/components/utils/use-app-lock";
-import { useLoadingBar } from "ente-new/photos/components/utils/use-loading-bar";
import { useAppLockSnapshot } from "ente-new/photos/components/utils/use-snapshot";
import { resumeExportsIfNeeded } from "ente-new/photos/services/export";
import { runMigrations } from "ente-new/photos/services/migration";
diff --git a/web/apps/photos/src/pages/gallery.tsx b/web/apps/photos/src/pages/gallery.tsx
index c73a4ed4c8..cb642fac95 100644
--- a/web/apps/photos/src/pages/gallery.tsx
+++ b/web/apps/photos/src/pages/gallery.tsx
@@ -7,7 +7,6 @@ import { AlbumAddedNotification } from "@/components/AlbumAddedNotification";
import { AuthenticateUser } from "@/components/AuthenticateUser";
import { GalleryBarAndListHeader } from "@/components/Collections/GalleryBarAndListHeader";
import { PickCoverPhotoDialog } from "@/components/Collections/PickCoverPhotoDialog";
-import { DownloadStatusNotifications } from "@/components/DownloadStatusNotifications";
import type { FileListHeaderOrFooter } from "@/components/FileList";
import { FileListWithViewer } from "@/components/FileListWithViewer";
import { FixCreationTime } from "@/components/FixCreationTime";
@@ -52,6 +51,7 @@ import {
import { savedAuthToken } from "ente-base/token";
import type { Location } from "ente-base/types";
import { ensureContactsReady } from "ente-contacts-web";
+import { DownloadStatusNotifications } from "ente-gallery/components/DownloadStatusNotifications";
import { FullScreenDropZone } from "ente-gallery/components/FullScreenDropZone";
import type { UploadTypeSelectorIntent } from "ente-gallery/components/Upload";
import { useSaveGroups } from "ente-gallery/components/utils/save-groups";
diff --git a/web/apps/share/src/components/file-share/CollectionShareView.tsx b/web/apps/share/src/components/file-share/CollectionShareView.tsx
index bf931fde6b..86d69fe20c 100644
--- a/web/apps/share/src/components/file-share/CollectionShareView.tsx
+++ b/web/apps/share/src/components/file-share/CollectionShareView.tsx
@@ -6,8 +6,8 @@ import {
Stack,
Typography,
} from "@mui/material";
+import { Notification } from "ente-base/components/Notification";
import { SingleInputForm } from "ente-base/components/SingleInputForm";
-import { Notification } from "ente-new/photos/components/Notification";
import { t } from "i18next";
import React from "react";
import { useCollectionShare } from "../../hooks/useCollectionShare";
diff --git a/web/apps/share/src/components/file-share/FileShareView.tsx b/web/apps/share/src/components/file-share/FileShareView.tsx
index d51b2476a6..52a700bf89 100644
--- a/web/apps/share/src/components/file-share/FileShareView.tsx
+++ b/web/apps/share/src/components/file-share/FileShareView.tsx
@@ -1,5 +1,5 @@
import { Box, Button, CircularProgress, Typography } from "@mui/material";
-import { Notification } from "ente-new/photos/components/Notification";
+import { Notification } from "ente-base/components/Notification";
import Head from "next/head";
import React from "react";
import { useFileShare } from "../../hooks/useFileShare";
diff --git a/web/apps/share/src/hooks/useCollectionShare.ts b/web/apps/share/src/hooks/useCollectionShare.ts
index 54cda8751f..f61b132d4e 100644
--- a/web/apps/share/src/hooks/useCollectionShare.ts
+++ b/web/apps/share/src/hooks/useCollectionShare.ts
@@ -1,3 +1,4 @@
+import type { NotificationAttributes } from "ente-base/components/Notification";
import type { SingleInputFormProps } from "ente-base/components/SingleInputForm";
import {
HTTPError,
@@ -7,7 +8,6 @@ import {
import { apiOrigin } from "ente-base/origins";
import { extractCollectionKeyFromShareURL } from "ente-gallery/services/share";
import type { PublicURL } from "ente-media/collection";
-import type { NotificationAttributes } from "ente-new/photos/components/Notification";
import { useRouter } from "next/router";
import { useCallback, useEffect, useRef, useState } from "react";
import {
diff --git a/web/apps/share/src/hooks/useFileShare.ts b/web/apps/share/src/hooks/useFileShare.ts
index 5602f1e957..82f549c10b 100644
--- a/web/apps/share/src/hooks/useFileShare.ts
+++ b/web/apps/share/src/hooks/useFileShare.ts
@@ -1,5 +1,5 @@
+import type { NotificationAttributes } from "ente-base/components/Notification";
import { apiOrigin } from "ente-base/origins";
-import type { NotificationAttributes } from "ente-new/photos/components/Notification";
import { useRouter } from "next/router";
import { useEffect, useState } from "react";
import {
diff --git a/web/apps/albums/src/shared/ui/feedback/Notification.tsx b/web/packages/base/components/Notification.tsx
similarity index 100%
rename from web/apps/albums/src/shared/ui/feedback/Notification.tsx
rename to web/packages/base/components/Notification.tsx
diff --git a/web/packages/new/photos/components/utils/use-loading-bar.ts b/web/packages/base/components/utils/use-loading-bar.ts
similarity index 82%
rename from web/packages/new/photos/components/utils/use-loading-bar.ts
rename to web/packages/base/components/utils/use-loading-bar.ts
index f0742bb17d..0f3a7c61f4 100644
--- a/web/packages/new/photos/components/utils/use-loading-bar.ts
+++ b/web/packages/base/components/utils/use-loading-bar.ts
@@ -1,5 +1,9 @@
import { useCallback, useRef } from "react";
-import type { LoadingBarRef } from "react-top-loading-bar";
+
+export interface LoadingBarController {
+ continuousStart: () => void;
+ complete: () => void;
+}
/**
* A convenience hook for returning stable functions tied to a
@@ -12,7 +16,7 @@ import type { LoadingBarRef } from "react-top-loading-bar";
* loading bar. This hook returns these functions (and the ref).
*/
export const useLoadingBar = () => {
- const loadingBarRef = useRef<LoadingBarRef | null>(null);
+ const loadingBarRef = useRef<LoadingBarController | null>(null);
const showLoadingBar = useCallback(() => {
loadingBarRef.current?.continuousStart();
diff --git a/web/apps/photos/src/components/DownloadStatusNotifications.tsx b/web/packages/gallery/components/DownloadStatusNotifications.tsx
similarity index 99%
rename from web/apps/photos/src/components/DownloadStatusNotifications.tsx
rename to web/packages/gallery/components/DownloadStatusNotifications.tsx
index 18b9f64e26..4ea89f1da1 100644
--- a/web/apps/photos/src/components/DownloadStatusNotifications.tsx
+++ b/web/packages/gallery/components/DownloadStatusNotifications.tsx
@@ -14,13 +14,13 @@ import {
styled,
Typography,
} from "@mui/material";
+import { Notification } from "ente-base/components/Notification";
import { useBaseContext } from "ente-base/context";
import {
isSaveComplete,
isSaveCompleteWithErrors,
type SaveGroup,
} from "ente-gallery/components/utils/save-groups";
-import { Notification } from "ente-new/photos/components/Notification";
import { t } from "i18next";
import { useState } from "react";
@@ -34,7 +34,7 @@ const truncateAlbumName = (name: string): string => {
return name.slice(0, MAX_ALBUM_NAME_LENGTH) + "...";
};
-interface DownloadStatusNotificationsProps {
+export interface DownloadStatusNotificationsProps {
/**
* A list of user-initiated downloads for which a status should be shown.
*
diff --git a/web/packages/gallery/components/FullScreenDropZone.tsx b/web/packages/gallery/components/FullScreenDropZone.tsx
index caa4445e0c..458444f5ad 100644
--- a/web/packages/gallery/components/FullScreenDropZone.tsx
+++ b/web/packages/gallery/components/FullScreenDropZone.tsx
@@ -21,7 +21,7 @@ const hasDraggedFiles = (
return false;
};
-interface FullScreenDropZoneProps {
+export interface FullScreenDropZoneProps {
/**
* Optional override to the message show to the user when a drag is in
* progress.
diff --git a/web/packages/new/photos/components/Notification.tsx b/web/packages/new/photos/components/Notification.tsx
deleted file mode 100644
index 7e4f199052..0000000000
--- a/web/packages/new/photos/components/Notification.tsx
+++ /dev/null
@@ -1,273 +0,0 @@
-import CloseIcon from "@mui/icons-material/Close";
-import InfoIcon from "@mui/icons-material/InfoOutlined";
-import {
- IconButton,
- Snackbar,
- Stack,
- Typography,
- type ButtonProps,
- type SxProps,
- type Theme,
-} from "@mui/material";
-import { EllipsizedTypography } from "ente-base/components/Typography";
-import { RippleDisabledButton } from "ente-base/components/mui/FocusVisibleButton";
-import type { ModalVisibilityProps } from "ente-base/components/utils/modal";
-import { isSxArray } from "ente-base/components/utils/sx";
-import React from "react";
-
-/**
- * Customize the contents of an {@link Notification}.
- */
-export interface NotificationAttributes {
- /**
- * If set, then the caption is shown first, then the title.
- *
- * Default is to show the title first, then the caption.
- */
- captionFirst?: boolean;
- /**
- * The color of the notification.
- */
- color: ButtonProps["color"];
- /**
- * Optional override to the default InfoIcon shown at the leading edge of
- * the notification.
- *
- * Default: InfoIcon
- */
- startIcon?: React.ReactNode;
- /**
- * The primary textual content of the notification.
- */
- title: React.ReactNode;
- /**
- * The secondary textual content of the notification.
- *
- * It will be ellipsized if it does not fit into a single line.
- */
- caption?: React.ReactNode;
- /**
- * Callback invoked (if provided) when the user clicks on the notification
- * (anywhere except the close button).
- *
- * The notification is closed when this happens, unless the
- * {@link keepOpenOnClick} property is set on the notification instance.
- */
- onClick?: () => void;
- /**
- * Optional override to the default CloseIcon shown at the trailing edge of
- * the notification.
- *
- * Unlike {@link startIcon} which is not interactable, setting this replaces
- * the close button with a icon button showing the given {@link endIcon},
- * and on clicking that icon {@link onClick} would be called instead of
- * {@link onClose} (which would've been called on clicking the default close
- * button in this position).
- */
- endIcon?: React.ReactNode;
- /**
- * Optional handler when {@link endIcon} is clicked.
- *
- * If not provided, clicks on the end icon behave the same as clicking the
- * notification body.
- */
- onEndIconClick?: () => void;
-}
-
-type NotificationProps = ModalVisibilityProps & {
- /**
- * Attributes that customize the contents of the notification, and the
- * actions that happen on clicking it.
- */
- attributes: NotificationAttributes | undefined;
- /**
- * If `true`, then the notification is not closed when it is clicked, and
- * should be closed by pressing the close icon button it contains.
- */
- keepOpenOnClick?: boolean;
- /**
- * Horizontal positioning of the notification.
- *
- * Default: "right".
- */
- horizontal?: "left" | "right";
- /**
- * Vertical positioning of the notification.
- *
- * Default: "bottom".
- */
- vertical?: "top" | "bottom";
- /**
- * Optional time in milliseconds after which the notification closes.
- */
- autoHideDuration?: number;
- /**
- * sx props to customize the appearance of the underlying MUI
- * {@link Snackbar}.
- */
- sx?: SxProps<Theme>;
-};
-
-/**
- * A small notification popup shown on some edge of the screen to notify the
- * user of some asynchronous update or error.
- *
- * In Material UI terms, this is a custom "Snackbar".
- *
- * A single Notification component can be shared by multiple sources of
- * notifications (which means that there can't be multiple of them outstanding
- * at the same time from the same source). The source can customize the actual
- * contents and appearance of this notification by providing appropriate
- * {@link NotificationAttributes}.
- */
-export const Notification: React.FC<NotificationProps> = ({
- open,
- onClose,
- horizontal,
- vertical,
- autoHideDuration,
- sx,
- attributes,
- keepOpenOnClick,
-}) => {
- if (!attributes) return <></>;
-
- const {
- captionFirst,
- color,
- startIcon,
- title,
- caption,
- endIcon,
- onClick,
- onEndIconClick,
- } = attributes;
-
- const handleClose: React.MouseEventHandler = (event) => {
- onClose();
- event.stopPropagation();
- };
-
- const handleClick = () => {
- onClick?.();
- if (!keepOpenOnClick) onClose();
- };
-
- const handleEndIconClick: React.MouseEventHandler = (event) => {
- event.stopPropagation();
- if (onEndIconClick) {
- onEndIconClick();
- } else {
- handleClick();
- }
- };
-
- return (
- <Snackbar
- open={open}
- autoHideDuration={autoHideDuration}
- onClose={(_, reason) => {
- if (reason === "timeout") onClose();
- }}
- anchorOrigin={{
- horizontal: horizontal ?? "right",
- vertical: vertical ?? "bottom",
- }}
- sx={[
- (theme) => ({
- width: "min(320px, 100vw)",
- // If the `color` of the button is a translucent one, e.g.
- // "secondary", then the notification becomes opaque, which
- // is not what we want. So give the entire snackbar a solid
- // background color.
- backgroundColor: "background.default",
- boxShadow: theme.vars.palette.boxShadow.menu,
- }),
- ...(sx ? (isSxArray(sx) ? sx : [sx]) : []),
- ]}
- >
- <RippleDisabledButton
- color={color}
- onClick={handleClick}
- sx={{
- flex: "1",
- padding: "12px 8px 12px 14px",
- borderRadius: "8px",
- }}
- >
- <Stack
- direction="row"
- sx={{
- gap: 2,
- alignItems: "center",
- // Necessary to get the ellipsizing to work.
- width: "100%",
- }}
- >
- <Stack sx={{ svg: { fontSize: "36px" } }}>
- {startIcon ?? <InfoIcon />}
- </Stack>
-
- <Stack
- sx={{
- flex: 1,
- gap: 0.5,
- // Undo the center alignment done by the button.
- textAlign: "left",
- // This is necessary to trigger the ellipsizing of the
- // text in children.
- overflow: "hidden",
- }}
- >
- {captionFirst ? (
- <>
- {caption && (
- <EllipsizedTypography variant="small">
- {caption}
- </EllipsizedTypography>
- )}
- <Typography sx={{ fontWeight: "medium" }}>
- {title}
- </Typography>
- </>
- ) : (
- <>
- <Typography sx={{ fontWeight: "medium" }}>
- {title}
- </Typography>
- {caption && (
- <EllipsizedTypography variant="small">
- {caption}
- </EllipsizedTypography>
- )}
- </>
- )}
- </Stack>
-
- {endIcon ? (
- <IconButton
- component="div"
- onClick={handleEndIconClick}
- sx={{ fontSize: "36px", bgcolor: "fill.faint" }}
- >
- {endIcon}
- </IconButton>
- ) : (
- <IconButton
- // Buttons cannot be nested in buttons, so we use a div
- // here instead.
- component="div"
- // Inherit the color of the parent button instead of
- // using the IconButton defaults.
- color="inherit"
- onClick={handleClose}
- sx={{ bgcolor: "fill.faint" }}
- >
- <CloseIcon />
- </IconButton>
- )}
- </Stack>
- </RippleDisabledButton>
- </Snackbar>
- );
-};
diff --git a/web/packages/new/photos/components/ThemedLoadingBar.tsx b/web/packages/new/photos/components/ThemedLoadingBar.tsx
index 96ad8afbdb..315428b248 100644
--- a/web/packages/new/photos/components/ThemedLoadingBar.tsx
+++ b/web/packages/new/photos/components/ThemedLoadingBar.tsx
@@ -1,9 +1,10 @@
import { useTheme } from "@mui/material";
+import type { LoadingBarController } from "ente-base/components/utils/use-loading-bar";
import React from "react";
import LoadingBar, { type LoadingBarRef } from "react-top-loading-bar";
interface ThemedLoadingBarProps {
- ref: React.Ref<LoadingBarRef>;
+ ref: React.Ref<LoadingBarController>;
}
/**
* A wrapper over the {@link LoadingBar} library component that sets it to use
@@ -12,5 +13,10 @@ interface ThemedLoadingBarProps {
export const ThemedLoadingBar: React.FC<ThemedLoadingBarProps> = ({ ref }) => {
const theme = useTheme();
- return <LoadingBar color={theme.vars.palette.accent.main} ref={ref} />;
+ return (
+ <LoadingBar
+ color={theme.vars.palette.accent.main}
+ ref={ref as React.Ref<LoadingBarRef>}
+ />
+ );
};
diff --git a/web/packages/new/photos/types/context.ts b/web/packages/new/photos/types/context.ts
index 39190a8d78..27b5ab1954 100644
--- a/web/packages/new/photos/types/context.ts
+++ b/web/packages/new/photos/types/context.ts
@@ -1,4 +1,4 @@
-import type { NotificationAttributes } from "ente-new/photos/components/Notification";
+import type { NotificationAttributes } from "ente-base/components/Notification";
import { createContext, useContext } from "react";
/**