Skip to content

armgit / ente

Public Imported from GitHub
0

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

Improve accessibility by using a button

Manav Rathi02e059989eab
diff --git a/web/apps/photos/src/components/Collections/AllCollections/content.tsx b/web/apps/photos/src/components/Collections/AllCollections/content.tsx
index 05876f1ad1..807587b295 100644
--- a/web/apps/photos/src/components/Collections/AllCollections/content.tsx
+++ b/web/apps/photos/src/components/Collections/AllCollections/content.tsx
@@ -1,5 +1,5 @@
import {
- CollectionTile,
+ CollectionTileButton,
ItemCard,
LargeTileTextOverlay,
} from "@/new/photos/components/ItemCards";
@@ -68,7 +68,7 @@ const AllCollectionRow = React.memo(
<div style={style}>
<FlexWrapper gap={"4px"} padding={"16px"}>
{collectionRow.map((item: any) => (
- <AllCollectionCard
+ <CollectionButton
isScrolling={isScrolling}
onCollectionClick={onCollectionClick}
collectionSummary={item}
@@ -160,13 +160,13 @@ interface AllCollectionCardProps {
isScrolling?: boolean;
}
-const AllCollectionCard: React.FC<AllCollectionCardProps> = ({
+const CollectionButton: React.FC<AllCollectionCardProps> = ({
onCollectionClick,
collectionSummary,
isScrolling,
}) => (
<ItemCard
- TileComponent={CollectionTile}
+ TileComponent={CollectionTileButton}
coverFile={collectionSummary.coverFile}
onClick={() => onCollectionClick(collectionSummary.id)}
isScrolling={isScrolling}
diff --git a/web/packages/new/photos/components/CollectionSelector.tsx b/web/packages/new/photos/components/CollectionSelector.tsx
index ccd510dca8..f2341e350e 100644
--- a/web/packages/new/photos/components/CollectionSelector.tsx
+++ b/web/packages/new/photos/components/CollectionSelector.tsx
@@ -1,6 +1,6 @@
import type { Collection } from "@/media/collection";
import {
- CollectionTile,
+ CollectionTileButton,
ItemCard,
ItemTileOverlay,
LargeTileTextOverlay,
@@ -180,7 +180,7 @@ export const CollectionSelector: React.FC<CollectionSelectorProps> = ({
<DialogContent_>
<AddCollectionButton onClick={onCreateCollection} />
{filteredCollections.map((collectionSummary) => (
- <CollectionSelectorCard
+ <CollectionButton
key={collectionSummary.id}
collectionSummary={collectionSummary}
onCollectionClick={handleCollectionClick}
@@ -212,17 +212,17 @@ const titleForAction = (action: CollectionSelectorAction) => {
}
};
-interface CollectionSelectorCardProps {
+interface CollectionButtonProps {
collectionSummary: CollectionSummary;
onCollectionClick: (collectionID: number) => void;
}
-const CollectionSelectorCard: React.FC<CollectionSelectorCardProps> = ({
+const CollectionButton: React.FC<CollectionButtonProps> = ({
collectionSummary,
onCollectionClick,
}) => (
<ItemCard
- TileComponent={CollectionTile}
+ TileComponent={CollectionTileButton}
coverFile={collectionSummary.coverFile}
onClick={() => onCollectionClick(collectionSummary.id)}
>
@@ -239,7 +239,7 @@ interface AddCollectionButtonProps {
const AddCollectionButton: React.FC<AddCollectionButtonProps> = ({
onClick,
}) => (
- <ItemCard TileComponent={CollectionTile} onClick={onClick}>
+ <ItemCard TileComponent={CollectionTileButton} onClick={onClick}>
<LargeTileTextOverlay>{t("create_albums")}</LargeTileTextOverlay>
<PlusOverlay>+</PlusOverlay>
</ItemCard>
diff --git a/web/packages/new/photos/components/ItemCards.tsx b/web/packages/new/photos/components/ItemCards.tsx
index f4ff88912d..c687f26224 100644
--- a/web/packages/new/photos/components/ItemCards.tsx
+++ b/web/packages/new/photos/components/ItemCards.tsx
@@ -7,6 +7,7 @@ import { type EnteFile } from "@/new/photos/types/file";
import { styled } from "@mui/material";
import React, { useEffect, useState } from "react";
import { faceCrop } from "../services/ml";
+import { UnstyledButton } from "./UnstyledButton";
interface ItemCardProps {
/**
@@ -134,11 +135,33 @@ export const BarItemTile = styled(ItemTile)`
height: 64px;
`;
+/**
+ * A variant of {@link ItemTile} meant for use when the tile is interactable.
+ */
+export const ItemTileButton = styled(UnstyledButton)`
+ /* Buttons reset this to center */
+ text-align: inherit;
+
+ /* Rest of this is mostly verbatim from ItemTile ... */
+
+ display: flex;
+ /* Act as container for the absolutely positioned ItemTileOverlays. */
+ position: relative;
+ border-radius: 4px;
+ overflow: hidden;
+ & > img {
+ object-fit: cover;
+ width: 100%;
+ height: 100%;
+ pointer-events: none;
+ }
+`;
+
/**
* A large 150x150 TileComponent used when showing the list of collections in
* the all collections view and in the collection selector.
*/
-export const CollectionTile = styled(ItemTile)`
+export const CollectionTileButton = styled(ItemTileButton)`
width: 150px;
height: 150px;
`;