Skip to content

armgit / ente

Public Imported from GitHub
0

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

Inline

Manav Rathi2e6c7d29e4a3
diff --git a/web/apps/photos/src/components/Collections/CollectionListBar/index.tsx b/web/apps/photos/src/components/Collections/CollectionListBar.tsx
similarity index 72%
rename from web/apps/photos/src/components/Collections/CollectionListBar/index.tsx
rename to web/apps/photos/src/components/Collections/CollectionListBar.tsx
index a0cb169a69..520cff1b89 100644
--- a/web/apps/photos/src/components/Collections/CollectionListBar/index.tsx
+++ b/web/apps/photos/src/components/Collections/CollectionListBar.tsx
@@ -4,10 +4,15 @@ import {
SpaceBetweenFlex,
} from "@ente/shared/components/Container";
import useWindowSize from "@ente/shared/hooks/useWindowSize";
+import ArchiveIcon from "@mui/icons-material/Archive";
import ExpandMore from "@mui/icons-material/ExpandMore";
+import Favorite from "@mui/icons-material/FavoriteRounded";
+import LinkIcon from "@mui/icons-material/Link";
import NavigateNextIcon from "@mui/icons-material/NavigateNext";
+import PeopleIcon from "@mui/icons-material/People";
+import PushPin from "@mui/icons-material/PushPin";
import { Box, IconButton, Typography, styled } from "@mui/material";
-import CollectionListBarCard from "components/Collections/CollectionListBar/CollectionCard";
+import Tooltip from "@mui/material/Tooltip";
import {
CollectionListBarWrapper,
CollectionListWrapper,
@@ -21,9 +26,16 @@ import {
ListChildComponentProps,
areEqual,
} from "react-window";
-import { CollectionSummary } from "types/collection";
+import { CollectionSummary, CollectionSummaryType } from "types/collection";
import { ALL_SECTION, COLLECTION_LIST_SORT_BY } from "utils/collection";
-import CollectionListSortBy from "../CollectionListSortBy";
+import CollectionCard from "./CollectionCard";
+import CollectionListSortBy from "./CollectionListSortBy";
+import {
+ ActiveIndicator,
+ CollectionBarTile,
+ CollectionBarTileIcon,
+ CollectionBarTileText,
+} from "./styledComponents";
interface CollectionListBarProps {
activeCollectionID?: number;
@@ -276,3 +288,86 @@ const ScrollButtonRight = styled(ScrollButtonBase)`
text-align: left;
transform: translate(50%, 0%);
`;
+
+interface CollectionListBarCardProps {
+ collectionSummary: CollectionSummary;
+ activeCollectionID: number;
+ onCollectionClick: (collectionID: number) => void;
+ isScrolling?: boolean;
+}
+
+const CollectionListBarCard = (props: CollectionListBarCardProps) => {
+ const { activeCollectionID, collectionSummary, onCollectionClick } = props;
+
+ return (
+ <Box>
+ <CollectionCard
+ collectionTile={CollectionBarTile}
+ coverFile={collectionSummary.coverFile}
+ onClick={() => {
+ onCollectionClick(collectionSummary.id);
+ }}
+ >
+ <CollectionCardText collectionName={collectionSummary.name} />
+ <CollectionCardIcon collectionType={collectionSummary.type} />
+ </CollectionCard>
+ {activeCollectionID === collectionSummary.id && <ActiveIndicator />}
+ </Box>
+ );
+};
+
+function CollectionCardText({ collectionName }) {
+ return (
+ <CollectionBarTileText>
+ <TruncateText text={collectionName} />
+ </CollectionBarTileText>
+ );
+}
+
+function CollectionCardIcon({ collectionType }) {
+ return (
+ <CollectionBarTileIcon>
+ {collectionType === CollectionSummaryType.favorites && <Favorite />}
+ {collectionType === CollectionSummaryType.archived && (
+ <ArchiveIcon
+ sx={(theme) => ({
+ color: theme.colors.white.muted,
+ })}
+ />
+ )}
+ {collectionType === CollectionSummaryType.outgoingShare && (
+ <PeopleIcon />
+ )}
+ {(collectionType === CollectionSummaryType.incomingShareViewer ||
+ collectionType ===
+ CollectionSummaryType.incomingShareCollaborator) && (
+ <PeopleIcon />
+ )}
+ {collectionType === CollectionSummaryType.sharedOnlyViaLink && (
+ <LinkIcon />
+ )}
+ {collectionType === CollectionSummaryType.pinned && <PushPin />}
+ </CollectionBarTileIcon>
+ );
+}
+
+const TruncateText = ({ text }) => {
+ return (
+ <Tooltip title={text}>
+ <Box height={"2.1em"} overflow="hidden">
+ <Ellipse variant="small" sx={{ wordBreak: "break-word" }}>
+ {text}
+ </Ellipse>
+ </Box>
+ </Tooltip>
+ );
+};
+
+const Ellipse = styled(Typography)`
+ overflow: hidden;
+ text-overflow: ellipsis;
+ display: -webkit-box;
+ -webkit-line-clamp: 2; //number of lines to show
+ line-clamp: 2;
+ -webkit-box-orient: vertical;
+`;
diff --git a/web/apps/photos/src/components/Collections/CollectionListBar/CollectionCard.tsx b/web/apps/photos/src/components/Collections/CollectionListBar/CollectionCard.tsx
deleted file mode 100644
index efbf3510fd..0000000000
--- a/web/apps/photos/src/components/Collections/CollectionListBar/CollectionCard.tsx
+++ /dev/null
@@ -1,100 +0,0 @@
-import ArchiveIcon from "@mui/icons-material/Archive";
-import Favorite from "@mui/icons-material/FavoriteRounded";
-import LinkIcon from "@mui/icons-material/Link";
-import PeopleIcon from "@mui/icons-material/People";
-import PushPin from "@mui/icons-material/PushPin";
-import { Box, Typography, styled } from "@mui/material";
-import Tooltip from "@mui/material/Tooltip";
-import { CollectionSummary, CollectionSummaryType } from "types/collection";
-import CollectionCard from "../CollectionCard";
-import {
- ActiveIndicator,
- CollectionBarTile,
- CollectionBarTileIcon,
- CollectionBarTileText,
-} from "../styledComponents";
-
-interface Iprops {
- collectionSummary: CollectionSummary;
- activeCollectionID: number;
- onCollectionClick: (collectionID: number) => void;
- isScrolling?: boolean;
-}
-
-const CollectionListBarCard = (props: Iprops) => {
- const { activeCollectionID, collectionSummary, onCollectionClick } = props;
-
- return (
- <Box>
- <CollectionCard
- collectionTile={CollectionBarTile}
- coverFile={collectionSummary.coverFile}
- onClick={() => {
- onCollectionClick(collectionSummary.id);
- }}
- >
- <CollectionCardText collectionName={collectionSummary.name} />
- <CollectionCardIcon collectionType={collectionSummary.type} />
- </CollectionCard>
- {activeCollectionID === collectionSummary.id && <ActiveIndicator />}
- </Box>
- );
-};
-
-function CollectionCardText({ collectionName }) {
- return (
- <CollectionBarTileText>
- <TruncateText text={collectionName} />
- </CollectionBarTileText>
- );
-}
-
-function CollectionCardIcon({ collectionType }) {
- return (
- <CollectionBarTileIcon>
- {collectionType === CollectionSummaryType.favorites && <Favorite />}
- {collectionType === CollectionSummaryType.archived && (
- <ArchiveIcon
- sx={(theme) => ({
- color: theme.colors.white.muted,
- })}
- />
- )}
- {collectionType === CollectionSummaryType.outgoingShare && (
- <PeopleIcon />
- )}
- {(collectionType === CollectionSummaryType.incomingShareViewer ||
- collectionType ===
- CollectionSummaryType.incomingShareCollaborator) && (
- <PeopleIcon />
- )}
- {collectionType === CollectionSummaryType.sharedOnlyViaLink && (
- <LinkIcon />
- )}
- {collectionType === CollectionSummaryType.pinned && <PushPin />}
- </CollectionBarTileIcon>
- );
-}
-
-export default CollectionListBarCard;
-
-const TruncateText = ({ text }) => {
- return (
- <Tooltip title={text}>
- <Box height={"2.1em"} overflow="hidden">
- <Ellipse variant="small" sx={{ wordBreak: "break-word" }}>
- {text}
- </Ellipse>
- </Box>
- </Tooltip>
- );
-};
-
-const Ellipse = styled(Typography)`
- overflow: hidden;
- text-overflow: ellipsis;
- display: -webkit-box;
- -webkit-line-clamp: 2; //number of lines to show
- line-clamp: 2;
- -webkit-box-orient: vertical;
-`;