Skip to content

armgit / ente

Public Imported from GitHub
0

💚 End-to-end encrypted cloud for everything.

Add header, footer, and PhotoSwipe viewer to embed app

Manav Rathi2214166b3fd9
diff --git a/web/apps/embed/src/components/EmbedFileList.tsx b/web/apps/embed/src/components/EmbedFileList.tsx
index 4954354242..9c9f2d17ac 100644
--- a/web/apps/embed/src/components/EmbedFileList.tsx
+++ b/web/apps/embed/src/components/EmbedFileList.tsx
@@ -21,19 +21,22 @@ export interface EmbedFileListProps {
height: number;
annotatedFiles: EmbedFileListAnnotatedFile[];
onItemClick: (index: number) => void;
+ header?: React.ReactNode;
+ footer?: React.ReactNode;
}
const THUMBNAIL_SIZE = 200;
const THUMBNAIL_GAP = 4;
export const EmbedFileList: React.FC<EmbedFileListProps> = memo(
- ({ width, height, annotatedFiles, onItemClick }) => {
+ ({ width, height, annotatedFiles, onItemClick, header, footer }) => {
const columns = Math.floor(width / (THUMBNAIL_SIZE + THUMBNAIL_GAP));
const actualThumbnailSize =
(width - (columns - 1) * THUMBNAIL_GAP) / columns;
return (
<Container style={{ width, height }}>
+ {header}
<Grid columns={columns} gap={THUMBNAIL_GAP}>
{annotatedFiles.map((annotatedFile, index) => (
<EmbedFileTile
@@ -44,6 +47,7 @@ export const EmbedFileList: React.FC<EmbedFileListProps> = memo(
/>
))}
</Grid>
+ {footer}
</Container>
);
},
diff --git a/web/apps/embed/src/components/EmbedFileListWithViewer.tsx b/web/apps/embed/src/components/EmbedFileListWithViewer.tsx
index 0d22adc6c8..9ddee1078e 100644
--- a/web/apps/embed/src/components/EmbedFileListWithViewer.tsx
+++ b/web/apps/embed/src/components/EmbedFileListWithViewer.tsx
@@ -1,8 +1,16 @@
-import { styled } from "@mui/material";
+import { Link, styled, Typography } from "@mui/material";
+import { EnteLogo } from "ente-base/components/EnteLogo";
+import { SpacedRow } from "ente-base/components/containers";
import { isSameDay } from "ente-base/date";
import { formattedDate } from "ente-base/i18n-date";
+import { FileViewer } from "ente-gallery/components/viewer/FileViewer";
+import type { Collection } from "ente-media/collection";
import type { EnteFile } from "ente-media/file";
import { fileCreationTime } from "ente-media/file-metadata";
+import {
+ GalleryItemsHeaderAdapter,
+ GalleryItemsSummary,
+} from "ente-new/photos/components/gallery/ListHeader";
import { t } from "i18next";
import { useCallback, useMemo, useState } from "react";
import AutoSizer from "react-virtualized-auto-sizer";
@@ -10,16 +18,16 @@ import {
EmbedFileList,
type EmbedFileListAnnotatedFile,
} from "./EmbedFileList";
-import { EmbedFileViewer } from "./EmbedFileViewer";
export interface EmbedFileListWithViewerProps {
files: EnteFile[];
- onRemotePull?: () => Promise<void>; // Optional for embed
+ publicCollection: Collection;
+ onRemotePull?: () => Promise<void>;
}
export const EmbedFileListWithViewer: React.FC<
EmbedFileListWithViewerProps
-> = ({ files }) => {
+> = ({ files, publicCollection, onRemotePull }) => {
const [openFileViewer, setOpenFileViewer] = useState(false);
const [currentIndex, setCurrentIndex] = useState(0);
@@ -33,14 +41,61 @@ export const EmbedFileListWithViewer: React.FC<
);
const handleThumbnailClick = useCallback((index: number) => {
+ console.log("Thumbnail clicked, index:", index);
+ console.log("Files available:", files.length);
setCurrentIndex(index);
setOpenFileViewer(true);
- }, []);
+ }, [files.length]);
const handleCloseFileViewer = useCallback(() => {
+ console.log("Closing file viewer");
setOpenFileViewer(false);
}, []);
+ const handleTriggerRemotePull = useCallback(
+ () => void onRemotePull?.(),
+ [onRemotePull],
+ );
+
+ const header = useMemo(
+ () => (
+ <GalleryItemsHeaderAdapter>
+ <SpacedRow>
+ <GalleryItemsSummary
+ name={publicCollection.name}
+ fileCount={files.length}
+ />
+ <Typography sx={{ color: "text.muted" }}>
+ <EnteLogo height={16} />
+ </Typography>
+ </SpacedRow>
+ </GalleryItemsHeaderAdapter>
+ ),
+ [publicCollection.name, files.length],
+ );
+
+ const footer = useMemo(
+ () => (
+ <FooterContainer>
+ <Link
+ color="text.muted"
+ sx={{
+ textAlign: "right",
+ alignSelf: "flex-end",
+ "&:hover": { color: "inherit" },
+ }}
+ target="_blank"
+ href="https://ente.io"
+ >
+ <Typography variant="small">
+ powered by ente.io
+ </Typography>
+ </Link>
+ </FooterContainer>
+ ),
+ [],
+ );
+
return (
<Container>
<AutoSizer>
@@ -50,21 +105,37 @@ export const EmbedFileListWithViewer: React.FC<
height={height}
annotatedFiles={annotatedFiles}
onItemClick={handleThumbnailClick}
+ header={header}
+ footer={footer}
/>
)}
</AutoSizer>
- <EmbedFileViewer
- open={openFileViewer}
- onClose={handleCloseFileViewer}
- initialIndex={currentIndex}
- files={files}
- />
+ {openFileViewer && (
+ <FileViewer
+ open={openFileViewer}
+ onClose={handleCloseFileViewer}
+ initialIndex={currentIndex}
+ files={files}
+ disableDownload={true}
+ onTriggerRemotePull={handleTriggerRemotePull}
+ onVisualFeedback={() => {
+ console.log("Visual feedback requested");
+ }}
+ />
+ )}
</Container>
);
};
const Container = styled("div")({ flex: 1, width: "100%" });
+const FooterContainer = styled("div")({
+ display: "flex",
+ justifyContent: "flex-end",
+ padding: "16px",
+ minHeight: "50px",
+});
+
const fileTimelineDateString = (file: EnteFile) => {
const date = new Date(fileCreationTime(file) / 1000);
return isSameDay(date, new Date())
diff --git a/web/apps/embed/src/components/EmbedFileViewer.tsx b/web/apps/embed/src/components/EmbedFileViewer.tsx
deleted file mode 100644
index eb535dedef..0000000000
--- a/web/apps/embed/src/components/EmbedFileViewer.tsx
+++ /dev/null
@@ -1,318 +0,0 @@
-import ArrowBackIosIcon from "@mui/icons-material/ArrowBackIos";
-import ArrowForwardIosIcon from "@mui/icons-material/ArrowForwardIos";
-import CloseIcon from "@mui/icons-material/Close";
-import FullscreenIcon from "@mui/icons-material/Fullscreen";
-import FullscreenExitIcon from "@mui/icons-material/FullscreenExit";
-import { Dialog, IconButton, styled } from "@mui/material";
-import type { EnteFile } from "ente-media/file";
-import { FileType } from "ente-media/file-type";
-import React, { useCallback, useEffect, useMemo, useState } from "react";
-
-export interface EmbedFileViewerProps {
- open: boolean;
- onClose: () => void;
- initialIndex: number;
- files: EnteFile[];
-}
-
-export const EmbedFileViewer: React.FC<EmbedFileViewerProps> = ({
- open,
- onClose,
- initialIndex,
- files,
-}) => {
- const [currentIndex, setCurrentIndex] = useState(initialIndex);
- const [isFullscreen, setIsFullscreen] = useState(false);
-
- const currentFile = useMemo(
- () => files[currentIndex],
- [files, currentIndex],
- );
-
- // Update currentIndex when initialIndex changes (and dialog is open)
- useEffect(() => {
- if (open) {
- setCurrentIndex(initialIndex);
- }
- }, [open, initialIndex]);
-
- const navigateToNext = useCallback(() => {
- if (currentIndex < files.length - 1) {
- setCurrentIndex(currentIndex + 1);
- }
- }, [currentIndex, files.length]);
-
- const navigateToPrevious = useCallback(() => {
- if (currentIndex > 0) {
- setCurrentIndex(currentIndex - 1);
- }
- }, [currentIndex]);
-
- const toggleFullscreen = useCallback(() => {
- setIsFullscreen(!isFullscreen);
- }, [isFullscreen]);
-
- const handleKeyDown = useCallback(
- (event: KeyboardEvent) => {
- if (!open) return;
-
- switch (event.key) {
- case "ArrowRight":
- navigateToNext();
- break;
- case "ArrowLeft":
- navigateToPrevious();
- break;
- case "Escape":
- if (isFullscreen) {
- setIsFullscreen(false);
- } else {
- onClose();
- }
- break;
- case "f":
- case "F":
- toggleFullscreen();
- break;
- }
- },
- [
- open,
- navigateToNext,
- navigateToPrevious,
- onClose,
- isFullscreen,
- toggleFullscreen,
- ],
- );
-
- useEffect(() => {
- document.addEventListener("keydown", handleKeyDown);
- return () => document.removeEventListener("keydown", handleKeyDown);
- }, [handleKeyDown]);
-
- if (!currentFile) {
- return null;
- }
-
- return (
- <EmbedViewerDialog
- open={open}
- onClose={onClose}
- fullScreen
- isFullscreen={isFullscreen}
- >
- {!isFullscreen && (
- <Controls>
- <TopControls>
- <IconButton onClick={onClose} color="inherit">
- <CloseIcon />
- </IconButton>
- </TopControls>
- <BottomControls>
- <IconButton
- onClick={navigateToPrevious}
- disabled={currentIndex === 0}
- color="inherit"
- >
- <ArrowBackIosIcon />
- </IconButton>
- <IconButton onClick={toggleFullscreen} color="inherit">
- <FullscreenIcon />
- </IconButton>
- <IconButton
- onClick={navigateToNext}
- disabled={currentIndex === files.length - 1}
- color="inherit"
- >
- <ArrowForwardIosIcon />
- </IconButton>
- </BottomControls>
- </Controls>
- )}
-
- {isFullscreen && (
- <FullscreenControls>
- <IconButton onClick={toggleFullscreen} color="inherit">
- <FullscreenExitIcon />
- </IconButton>
- </FullscreenControls>
- )}
-
- <MediaContainer>
- <EmbedMediaRenderer
- file={currentFile}
- isFullscreen={isFullscreen}
- />
- </MediaContainer>
- </EmbedViewerDialog>
- );
-};
-
-interface EmbedMediaRendererProps {
- file: EnteFile;
- isFullscreen: boolean;
-}
-
-const EmbedMediaRenderer: React.FC<EmbedMediaRendererProps> = ({
- file,
- isFullscreen,
-}) => {
- const [mediaSrc, setMediaSrc] = useState<string>();
- const [isLoading, setIsLoading] = useState(true);
-
- useEffect(() => {
- const loadMedia = async () => {
- try {
- setIsLoading(true);
- // For embed, we'll use thumbnail for now - in a production version,
- // you might want to load the full resolution file
- const { downloadManager } = await import(
- "ente-gallery/services/download"
- );
- const thumbnailData = await downloadManager.thumbnailData(file);
- if (!thumbnailData) throw new Error("No thumbnail data");
- const media = new Blob([thumbnailData]);
- const url = URL.createObjectURL(media);
- setMediaSrc(url);
- } catch (error) {
- console.error("Failed to load media:", error);
- } finally {
- setIsLoading(false);
- }
- };
-
- void loadMedia();
-
- return () => {
- if (mediaSrc) {
- URL.revokeObjectURL(mediaSrc);
- }
- };
- }, [file, mediaSrc]);
-
- if (isLoading) {
- return <MediaPlaceholder>Loading...</MediaPlaceholder>;
- }
-
- if (!mediaSrc) {
- return <MediaPlaceholder>Failed to load media</MediaPlaceholder>;
- }
-
- const isVideo = file.metadata.fileType === FileType.video;
-
- return isVideo ? (
- <MediaVideo src={mediaSrc} controls isFullscreen={isFullscreen} />
- ) : (
- <MediaImage src={mediaSrc} alt="" isFullscreen={isFullscreen} />
- );
-};
-
-const EmbedViewerDialog = styled(Dialog)<{ isFullscreen: boolean }>(
- ({ theme, isFullscreen }) => ({
- "& .MuiDialog-paper": {
- backgroundColor: theme.palette.background.default,
- backgroundImage: "none",
- margin: 0,
- maxWidth: "none",
- maxHeight: "none",
- width: "100%",
- height: "100%",
- borderRadius: 0,
- },
- "& .MuiBackdrop-root": {
- backgroundColor: isFullscreen
- ? "rgba(0, 0, 0, 1)"
- : "rgba(0, 0, 0, 0.8)",
- },
- }),
-);
-
-const Controls = styled("div")({
- position: "absolute",
- top: 0,
- left: 0,
- right: 0,
- bottom: 0,
- pointerEvents: "none",
- zIndex: 1,
-});
-
-const TopControls = styled("div")({
- position: "absolute",
- top: 0,
- right: 0,
- padding: "16px",
- pointerEvents: "auto",
- "& button": {
- backgroundColor: "rgba(0, 0, 0, 0.5)",
- color: "white",
- "&:hover": { backgroundColor: "rgba(0, 0, 0, 0.7)" },
- },
-});
-
-const BottomControls = styled("div")({
- position: "absolute",
- bottom: 0,
- left: "50%",
- transform: "translateX(-50%)",
- padding: "16px",
- display: "flex",
- gap: "8px",
- pointerEvents: "auto",
- "& button": {
- backgroundColor: "rgba(0, 0, 0, 0.5)",
- color: "white",
- "&:hover": { backgroundColor: "rgba(0, 0, 0, 0.7)" },
- "&:disabled": {
- backgroundColor: "rgba(0, 0, 0, 0.3)",
- color: "rgba(255, 255, 255, 0.5)",
- },
- },
-});
-
-const FullscreenControls = styled("div")({
- position: "absolute",
- top: "16px",
- right: "16px",
- zIndex: 2,
- pointerEvents: "auto",
- "& button": {
- backgroundColor: "rgba(0, 0, 0, 0.5)",
- color: "white",
- "&:hover": { backgroundColor: "rgba(0, 0, 0, 0.7)" },
- },
-});
-
-const MediaContainer = styled("div")({
- display: "flex",
- alignItems: "center",
- justifyContent: "center",
- width: "100%",
- height: "100%",
-});
-
-const MediaPlaceholder = styled("div")({
- display: "flex",
- alignItems: "center",
- justifyContent: "center",
- color: "white",
- fontSize: "1.2rem",
-});
-
-const MediaImage = styled("img")<{ isFullscreen: boolean }>(
- ({ isFullscreen }) => ({
- maxWidth: "100%",
- maxHeight: "100%",
- objectFit: "contain",
- ...(isFullscreen && { width: "100vw", height: "100vh" }),
- }),
-);
-
-const MediaVideo = styled("video")<{ isFullscreen: boolean }>(
- ({ isFullscreen }) => ({
- maxWidth: "100%",
- maxHeight: "100%",
- ...(isFullscreen && { width: "100vw", height: "100vh" }),
- }),
-);
diff --git a/web/apps/embed/src/pages/_app.tsx b/web/apps/embed/src/pages/_app.tsx
index fd0c3edce1..97efd18d8c 100644
--- a/web/apps/embed/src/pages/_app.tsx
+++ b/web/apps/embed/src/pages/_app.tsx
@@ -1,4 +1,6 @@
import "@fontsource-variable/inter";
+import "photoswipe/dist/photoswipe.css";
+import "styles/photoswipe.css";
import { CssBaseline } from "@mui/material";
import { ThemeProvider } from "@mui/material/styles";
import { CustomHeadPhotosOrAlbums } from "ente-base/components/Head";
diff --git a/web/apps/embed/src/pages/index.tsx b/web/apps/embed/src/pages/index.tsx
index 8b737e4680..39560403c9 100644
--- a/web/apps/embed/src/pages/index.tsx
+++ b/web/apps/embed/src/pages/index.tsx
@@ -234,6 +234,7 @@ export default function EmbedGallery() {
<EmbedContainer>
<EmbedFileListWithViewer
files={publicFiles}
+ publicCollection={publicCollection!}
onRemotePull={publicAlbumsRemotePull}
/>
</EmbedContainer>
diff --git a/web/apps/embed/src/styles/photoswipe.css b/web/apps/embed/src/styles/photoswipe.css
new file mode 100644
index 0000000000..e69c838f38
--- /dev/null
+++ b/web/apps/embed/src/styles/photoswipe.css
@@ -0,0 +1,364 @@
+.pswp-ente {
+ /* The default z-index for PhotoSwipe is 10k, way beyond everything else.
+ Give it a more moderate value so that MUI elements can be used with it. */
+ z-index: calc(var(--mui-zIndex-drawer) - 1);
+}
+
+/* Shift the top bar by a fraction of the desktop title bar, if any. The top bar
+ contents already have a decent top padding, so we don't need to shift by the
+ entire amount. See also: [Note: Customize the desktop title bar] */
+.pswp-ente .pswp__top-bar {
+ top: calc(env(titlebar-area-height, 0px) * 0.4);
+}
+
+/* The PhotoSwipe CSS already disables and re-enables pointer-events for hidden
+ UI elements, but for a reason that I didn't investigate more, that isn't
+ working, and the hidden buttons still remain clickable.
+
+ As a workaround, repeat the CSS, but with a higher specificity by including
+ the button selector */
+
+.pswp .pswp__hide-on-close button {
+ pointer-events: none;
+}
+
+.pswp--ui-visible .pswp__hide-on-close button {
+ pointer-events: auto;
+}
+
+/* Tweak the visual look of the preloader to match the rest of the elements */
+
+.pswp-ente .pswp__preloader--active .pswp__icn {
+ opacity: 0.4;
+}
+
+/*
+ Error indicator on the file viewer.
+
+ It is styled similar to the loading indicator provided by PhotoSwipe since it
+ is meant to occupy the same space. Only one of these will be shown at the same
+ time, so it can also set the auto right margin.
+ */
+.pswp-ente .pswp__error {
+ position: relative;
+ overflow: hidden;
+ width: 50px;
+ height: 60px;
+ /* Unlike the loading indicator, "display" is used to toggle visibility, and
+ the opacity is fixed to be similar to that of the counter. */
+ display: none;
+ opacity: 0.85;
+}
+
+.pswp-ente .pswp__error .pswp__icn {
+ /* Use a warning color for the error icon */
+ fill: var(--mui-palette-fixed-golden);
+}
+
+.pswp-ente .pswp__error .pswp__icn-shadow {
+ /* Reduce the stroke from default (2px) to make it look better with the
+ golden icon outline */
+ stroke-width: 1px;
+}
+
+/* The ".pswp--ui-visible .pswp__hide-on-close" selector in PhotoSwipe's CSS
+ sets the opacity of the arrows to 1, which doesn't match the rest of the
+ controls (0.85). */
+.pswp-ente.pswp--ui-visible .pswp__hide-on-close.pswp__button--arrow {
+ opacity: 0.85;
+}
+
+.pswp-ente .pswp__error--active {
+ display: initial;
+}
+
+/* Transform the built in controls to better fit our requirements */
+
+.pswp-ente .pswp__counter {
+ margin-top: 22.5px;
+ margin-inline-start: 18px;
+ margin-inline-end: 9px;
+ line-height: 20px;
+}
+
+.pswp-ente .pswp__button--zoom .pswp__icn {
+ top: 16px;
+ transform: scale(0.85);
+}
+
+.pswp-ente .pswp__preloader {
+ transform: translate(-2px, 2px);
+}
+
+.pswp-ente .pswp__error {
+ transform: translate(-2px, 2px);
+}
+
+.pswp-ente .pswp__button--close .pswp__icn {
+ transform: translate(-6px, 0) scale(0.925);
+}
+
+.pswp-ente .pswp__button--close {
+ margin-right: 2px;
+}
+
+.pswp-ente .pswp__button--arrow--prev .pswp__icn {
+ transform: scale(0.8);
+}
+
+.pswp-ente .pswp__button--arrow--next .pswp__icn {
+ /* default is a horizontal flip, transform: scale(-1, 1); */
+ transform: scale(-0.8, 0.8);
+}
+
+/* Toggleable live photo buttons */
+
+.pswp-ente button.pswp-ente-off .pswp__icn {
+ /* PhotoSwipe already uses the CSS opacity, so reduce the color's opacity */
+ fill: rgb(255 255 255 / 0.6);
+}
+
+/* Make the controls fit the top bar on mobile sized screens */
+@media (width < 450px) {
+ .pswp-ente .pswp__button {
+ width: 44px;
+ }
+
+ .pswp-ente .pswp__counter {
+ margin-inline-start: 10px;
+ margin-inline-end: 0;
+ }
+
+ .pswp-ente .pswp__button--close {
+ margin-right: -2px;
+ }
+}
+
+@media (width < 350px) {
+ .pswp-ente .pswp__button {
+ width: 42px;
+ }
+
+ .pswp-ente .pswp__counter {
+ margin-inline-start: 4px;
+ }
+
+ .pswp-ente .pswp__button--close {
+ margin-right: -4px;
+ }
+}
+
+/* 4 line caption */
+
+.pswp-ente .pswp__caption {
+ position: absolute;
+ bottom: 0px;
+ right: 0;
+ margin: 20px 24px;
+ border-radius: 3px;
+ /* Same opacity as the other controls. */
+ color: rgb(255 255 255 / 0.85);
+ background-color: rgb(0 0 0 / 0.2);
+ backdrop-filter: blur(10px);
+ max-width: 375px;
+ max-height: 200px;
+ p {
+ margin: 12px 17px;
+ /* 4 lines max, ellipsis on overflow. */
+ word-break: break-word;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ display: -webkit-box;
+ -webkit-box-orient: vertical;
+ -webkit-line-clamp: 4;
+ line-clamp: 4;
+ }
+}
+
+.pswp-ente .pswp__caption.ente-video {
+ /* Add extra offset for video captions so that they do not overlap with the
+ video controls. The constant was picked such that it lay above the media
+ controls. */
+ bottom: 48px;
+ /* Adding a caption with a blur backdrop filter above the video element
+ contained in a media-controller causes a subtle tint to be overlaid on
+ the entire video. This is visible on both Chrome and Firefox as of
+ writing.
+
+ We'll hide the caption anyways when hovering on the controls or when the
+ video is playing, so remove the backdrop filter and rely on the
+ translucent background. Note that usually the video might not even extent
+ to this part of the screen on desktop sized screens. */
+ backdrop-filter: none;
+ /* Since there is too much going on in this part of the screen now, also
+ reduce the maximum number of lines for the caption. */
+ p {
+ -webkit-line-clamp: 2;
+ line-clamp: 2;
+ }
+}
+
+/* Change the cursor on the thumbnail to the default arrow to indicate that it
+ is not interactable (PhotoSwipe by default shows the zoom out icon). */
+.pswp-ente .pswp__img {
+ cursor: auto;
+}
+
+/*
+ Make the controllable video elements we render as custom PhotoSwipe content
+ take .pswp-ente up the entire container.
+ */
+.pswp-ente video[controls] {
+ width: 100%;
+ height: 100%;
+}
+
+/*
+ I tried various ways to get media-controller to embed a normal video, but in
+ all methods I kept getting a flickering at the edges on Chrome. My best guess
+ is that it happens when the resolved size of the video is a fractional value.
+
+ This is the current magic incantation that seems to get them to play without
+ the video's frame jittering. Note that the streaming hls-video elements work
+ fine without any workarounds, it is only the vanilla video elements that have
+ this issue and necessitate this workaround. The downside is that clicking
+ "outside" the video works for hls-video, but not for vanilla videos.
+ */
+.pswp-ente media-controller.ente-vanilla-video {
+ width: 100%;
+ height: 100%;
+
+ video {
+ width: calc(100% - 1px);
+ height: calc(100% - 1px);
+ }
+}
+
+/*
+ Style the custom video controls we provide.
+
+ The media-controller itself is center positioned (shrinking if needed) by
+ PhotoSwipe using the width and height of the video that we provide to it.
+
+ The controls are absolutely position at the bottom of the screen instead of
+ being attached to the video.
+ */
+.pswp-ente .pswp__media-controls {
+ position: absolute;
+ bottom: 0px;
+ left: 0px;
+ right: 0px;
+
+ background: linear-gradient(transparent, rgb(0 0 0 / 0.8));
+
+ /* Similar to our other controls */
+ --media-icon-color: rgb(255 255 255 / 0.8);
+ /* NB: We don't reset the font-weight, so this'll be using 400 instead of
+ the 500 we use elsewhere. See: [Note: Font weights].
+
+ We don't reset it because on this screen the 400 looks better (for now).
+ */
+ --media-font-family: "Inter Variable", sans-serif;
+ --media-control-background: transparent;
+ --media-control-hover-background: rgb(255 255 255 / 0.12);
+ /*
+ Prevent menus from occluding clicks on other controls when hidden.
+
+ [Note: Showing menus outside of media-controller]
+
+ This is all very hacky. The standalone control example
+ (https://media-chrome.mux.dev/examples/vanilla/standalone-controls.html),
+ doesn't (as of now) include a menu, so it is possible this is just not
+ supported. None of the media controller examples I could find show menus
+ work for our specific scenario (the controls detached from the the media
+ controller itself, and shown at the bottom of the screen).
+
+ As such, a lot of undocumented and arbitrary tweaks are needed. This is a
+ house of cards, and might fall when the media-chrome version is updated;
+ on the other hand, they might also add better support for our scenario, in
+ which case this should be possible straightforwardly.
+ */
+ --media-menu-hidden-max-height: 1px;
+ --media-menu-max-height: 1000px;
+}
+
+/*
+ Stack controls rows vertically.
+ */
+.pswp-ente .pswp__media-controls > div {
+ display: flex;
+ flex-direction: column;
+}
+
+/* Hide the controls if they're not associated to a media-controller. */
+media-control-bar:not([mediacontroller]) {
+ display: none;
+}
+
+media-control-bar {
+ padding-inline: 12px;
+}
+
+media-control-bar:last-child {
+ padding-block-end: 4px;
+}
+
+media-loading-indicator {
+ /* Similar to the top bar loading indicator */
+ --media-icon-color: rgb(255 255 255 / 0.6);
+}
+
+/* Used as a spacer. */
+media-text-display {
+ flex-grow: 1;
+}
+
+media-time-range {
+ --media-range-bar-color: red;
+ --media-range-thumb-background: var(--media-range-bar-color);
+ --media-control-hover-background: transparent;
+ --media-control-padding: 0px;
+}
+
+media-time-range:hover {
+ --media-range-track-height: 5px;
+ --media-range-thumb-transform: scale(1.1);
+}
+
+/*
+ Hide specific controls when the user's browser doesn't support the feature
+ they trigger.
+ */
+media-pip-button[mediapipunavailable],
+media-fullscreen-button[mediafullscreenunavailable] {
+ display: none;
+}
+
+media-settings-menu {
+ /*
+ Restore the background for the settings menu (we made it transparent). The
+ default is var(--_menu-bg), which is rgb(20 20 30 / .8).
+ */
+ --media-control-background: var(--mui-palette-fixed-dark-background-paper);
+ /* Regular, but since the rest of media controls use 400, it
+ appears heavier. */
+ --media-font-weight: 500;
+ /*
+ Bring it above the rest of our controls.
+
+ See: [Note: Showing menus outside of media-controller]
+ */
+ z-index: 1;
+}
+
+/* Hide the caption when hovering over the video controls (and when the settings
+ menu is open) since they occupy similar real estate as the caption. */
+body:has(
+ media-time-range[mediapreviewtime],
+ media-controller:not([mediapaused]),
+ media-settings-menu:not([hidden])
+) {
+ & .pswp-ente .pswp__caption {
+ display: none;
+ }
+}
diff --git a/web/packages/accounts/services/redirect.ts b/web/packages/accounts/services/redirect.ts
index 1277963018..a87e2b51c3 100644
--- a/web/packages/accounts/services/redirect.ts
+++ b/web/packages/accounts/services/redirect.ts
@@ -9,6 +9,7 @@ export const appHomeRoute: string = {
accounts: "/passkeys",
auth: "/auth",
cast: "/" /* The cast app doesn't use this, this is an arbitrary value. */,
+ embed: "/" /* The embed app doesn't use this either. */,
locker: "/" /* The locker app also doesn't use this. */,
photos: "/gallery",
}[appName];