π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
[web][photos] Update navigation icons and thumbnail sizing
AswinAsok9548a3efd6c8
diff --git a/web/apps/photos/src/components/FileList.tsx b/web/apps/photos/src/components/FileList.tsxindex d91dfd2e7a..15daeba849 100644--- a/web/apps/photos/src/components/FileList.tsx+++ b/web/apps/photos/src/components/FileList.tsx@@ -17,6 +17,7 @@ import {handleSelectCreator,handleSelectCreatorMulti,} from "@/utils/photoFrame";+import { computePhotosThumbnailGridLayoutParams } from "@/utils/thumbnail-grid-layout";import { StarIcon } from "@hugeicons/core-free-icons";import { HugeiconsIcon } from "@hugeicons/react";import AlbumOutlinedIcon from "@mui/icons-material/AlbumOutlined";@@ -39,7 +40,6 @@ import {} from "ente-new/photos/components/PlaceholderThumbnails";import { TileBottomTextOverlay } from "ente-new/photos/components/Tiles";import {- computeThumbnailGridLayoutParams,thumbnailGap,type ThumbnailGridLayoutParams,} from "ente-new/photos/components/utils/thumbnail-grid-layout";@@ -187,7 +187,7 @@ export const FileList: React.FC<FileListProps> = ({const outerRef = useRef<HTMLDivElement | null>(null);const layoutParams = useMemo(- () => computeThumbnailGridLayoutParams(width),+ () => computePhotosThumbnailGridLayoutParams(width),[width],);diff --git a/web/apps/photos/src/components/gallery/BarImpl.tsx b/web/apps/photos/src/components/gallery/BarImpl.tsxindex 8329f580ac..f1c5e0ff56 100644--- a/web/apps/photos/src/components/gallery/BarImpl.tsx+++ b/web/apps/photos/src/components/gallery/BarImpl.tsx@@ -6,12 +6,16 @@ import {type albumFilters,} from "@/utils/album-filters";import type { PeopleSortBy } from "@/utils/people-sort";-import { Link05Icon, PinIcon, StarIcon } from "@hugeicons/core-free-icons";+import {+ ArrowDown01Icon,+ Link05Icon,+ PinIcon,+ StarIcon,+} from "@hugeicons/core-free-icons";import { HugeiconsIcon } from "@hugeicons/react";import AddIcon from "@mui/icons-material/Add";import ArchiveIcon from "@mui/icons-material/Archive";import CloseIcon from "@mui/icons-material/Close";-import ExpandMoreIcon from "@mui/icons-material/ExpandMore";import PeopleIcon from "@mui/icons-material/People";import SearchIcon from "@mui/icons-material/Search";import {@@ -334,9 +338,12 @@ export const GalleryBarImpl: React.FC<GalleryBarImplProps> = ({sx={{ flexShrink: 0 }}><CardText>{filter.label()}</CardText>- <ExpandMoreIcon+ <Box+ component={HugeiconsIcon}+ icon={ArrowDown01Icon}+ size={16}+ strokeWidth={1.8}sx={{- fontSize: 16,color: "text.muted",transform:displayedAlbumFilter == filter.valuediff --git a/web/apps/photos/src/components/gallery/PhotosNavigationShell.tsx b/web/apps/photos/src/components/gallery/PhotosNavigationShell.tsxindex 00cf70a154..f87986ab2e 100644--- a/web/apps/photos/src/components/gallery/PhotosNavigationShell.tsx+++ b/web/apps/photos/src/components/gallery/PhotosNavigationShell.tsx@@ -3,12 +3,12 @@ import { SearchBar, type SearchBarProps } from "@/components/SearchBar";import { useIsOffline } from "@/components/utils/use-is-offline";import { uploadManager } from "@/services/upload-manager";import {- Album02Icon,+ DashboardSquare01Icon,Home01Icon,- Link05Icon,+ Link04Icon,Settings01Icon,Upload01Icon,- UserGroupIcon,+ User02Icon,} from "@hugeicons/core-free-icons";import { HugeiconsIcon } from "@hugeicons/react";import CloudOffIcon from "@mui/icons-material/CloudOff";@@ -409,10 +409,10 @@ const NormalNavigationRail: React.FC<<HugeiconsIconicon={item == "albums"- ? Album02Icon+ ? DashboardSquare01Icon: item == "links"- ? Link05Icon- : UserGroupIcon+ ? Link04Icon+ : User02Icon}size={20}strokeWidth={1.8}diff --git a/web/apps/photos/src/utils/thumbnail-grid-layout.ts b/web/apps/photos/src/utils/thumbnail-grid-layout.tsnew file mode 100644index 0000000000..2f18a0af62--- /dev/null+++ b/web/apps/photos/src/utils/thumbnail-grid-layout.ts@@ -0,0 +1,38 @@+import {+ thumbnailGap,+ thumbnailGridPadding,+ type ThumbnailGridLayoutParams,+} from "ente-new/photos/components/utils/thumbnail-grid-layout";++const thumbnailSize = 200;+const minimumColumns = 4;++/** Photos uses fixed-size thumbnails, shrinking only on narrow layouts. */+export const computePhotosThumbnailGridLayoutParams = (+ containerWidth: number,+): ThumbnailGridLayoutParams => {+ const availableWidth = Math.max(+ 0,+ containerWidth - 2 * thumbnailGridPadding,+ );+ const columns = Math.max(+ minimumColumns,+ Math.floor(+ (availableWidth + thumbnailGap) / (thumbnailSize + thumbnailGap),+ ),+ );+ const itemSize = Math.min(+ thumbnailSize,+ Math.max(0, (availableWidth - (columns - 1) * thumbnailGap) / columns),+ );++ return {+ containerWidth,+ isSmallerLayout: itemSize < thumbnailSize,+ paddingInline: thumbnailGridPadding,+ columns,+ itemWidth: itemSize,+ itemHeight: itemSize,+ gap: thumbnailGap,+ };+};diff --git a/web/apps/photos/tests/thumbnail-grid-layout.test.ts b/web/apps/photos/tests/thumbnail-grid-layout.test.tsnew file mode 100644index 0000000000..cff5db9432--- /dev/null+++ b/web/apps/photos/tests/thumbnail-grid-layout.test.ts@@ -0,0 +1,49 @@+import { computeThumbnailGridLayoutParams } from "ente-new/photos/components/utils/thumbnail-grid-layout";+import { describe, expect, test } from "vitest";+import { computePhotosThumbnailGridLayoutParams } from "../src/utils/thumbnail-grid-layout";++describe("Photos thumbnail layout", () => {+ test("keeps 200px squares and 4px gaps instead of stretching to fill", () => {+ const layout = computePhotosThumbnailGridLayoutParams(1333);+ expect(layout).toMatchObject({+ columns: 6,+ itemWidth: 200,+ itemHeight: 200,+ gap: 4,+ paddingInline: 24,+ isSmallerLayout: false,+ });+ });++ test("adds a column only when another full thumbnail and gap fit", () => {+ expect(computePhotosThumbnailGridLayoutParams(1063).columns).toBe(4);+ expect(computePhotosThumbnailGridLayoutParams(1064).columns).toBe(5);+ });++ test.each([320, 375, 720, 859, 860, 1063, 1064, 1440, 1920])(+ "fits square thumbnails within a %ipx container",+ (width) => {+ const layout = computePhotosThumbnailGridLayoutParams(width);+ const usedWidth =+ 2 * layout.paddingInline ++ layout.columns * layout.itemWidth ++ (layout.columns - 1) * layout.gap;+ expect(usedWidth).toBeLessThanOrEqual(width);+ expect(layout.itemWidth).toBe(layout.itemHeight);+ expect(layout.itemWidth).toBeLessThanOrEqual(200);+ },+ );++ test("preserves four shrinking columns on narrow layouts", () => {+ expect(computePhotosThumbnailGridLayoutParams(375)).toMatchObject({+ columns: 4,+ itemWidth: 78.75,+ itemHeight: 78.75,+ isSmallerLayout: true,+ });+ });++ test("leaves the shared public-album layout unchanged", () => {+ expect(computeThumbnailGridLayoutParams(1333).columns).toBe(7);+ });+});