diff --git a/resources/js/Components/Collections/CollectionName/CollectionName.test.tsx b/resources/js/Components/Collections/CollectionName/CollectionName.test.tsx index 64d78fd9c..a9665c8af 100644 --- a/resources/js/Components/Collections/CollectionName/CollectionName.test.tsx +++ b/resources/js/Components/Collections/CollectionName/CollectionName.test.tsx @@ -1,21 +1,28 @@ -import React from "react"; import { CollectionName } from "./CollectionName"; -import CollectionFactory from "@/Tests/Factories/Collections/CollectionFactory"; import { render, screen } from "@/Tests/testing-library"; describe("CollectionName", () => { - it("should render", () => { - const collection = new CollectionFactory().create(); + const collection = { + name: "Test Collection", + chainId: 137 as App.Enums.Chain, + image: "https://example.com", + }; - render( - , - ); + it("can render", () => { + render(); expect(screen.getByTestId("CollectionName")).toBeInTheDocument(); expect(screen.getAllByTestId("Img")).toHaveLength(1); expect(screen.getByTestId("NetworkIcon")).toBeInTheDocument(); + expect(screen.queryByTestId("CollectionName__detail")).not.toBeInTheDocument(); + }); + + it("can render children", () => { + render(10 owned); + + expect(screen.getByTestId("CollectionName")).toBeInTheDocument(); + expect(screen.getAllByTestId("Img")).toHaveLength(1); + expect(screen.getByTestId("NetworkIcon")).toBeInTheDocument(); + expect(screen.getByTestId("CollectionName__detail")).toHaveTextContent("10 owned"); }); }); diff --git a/resources/js/Components/Collections/CollectionName/CollectionName.tsx b/resources/js/Components/Collections/CollectionName/CollectionName.tsx index c35e98293..fe2078367 100644 --- a/resources/js/Components/Collections/CollectionName/CollectionName.tsx +++ b/resources/js/Components/Collections/CollectionName/CollectionName.tsx @@ -1,38 +1,39 @@ -import { useRef } from "react"; -import { useTranslation } from "react-i18next"; +import cn from "classnames"; +import { type ReactNode, useRef } from "react"; import { Img } from "@/Components/Image"; import { NetworkIcon } from "@/Components/Networks/NetworkIcon"; import { Tooltip } from "@/Components/Tooltip"; import { useIsTruncated } from "@/Hooks/useIsTruncated"; -export const CollectionName = ({ - collection, - ownedCount, -}: { - ownedCount: number; - collection: App.Data.Collections.CollectionData; -}): JSX.Element => { - const { t } = useTranslation(); - const collectionNameReference = useRef(null); - const isTruncated = useIsTruncated({ reference: collectionNameReference }); +interface Properties { + collection: Pick; + className?: string; + children?: ReactNode; +} + +export const CollectionName = ({ collection, className, children }: Properties): JSX.Element => { + const nameReference = useRef(null); + const isTruncated = useIsTruncated({ reference: nameReference }); return (
-
+
{collection.name} -
- -
+
@@ -41,7 +42,7 @@ export const CollectionName = ({ content={collection.name} >

@@ -49,9 +50,14 @@ export const CollectionName = ({

-

- {ownedCount} {t("common.owned")} -

+ {children !== undefined && ( + + {children} + + )}
diff --git a/resources/js/Components/Collections/CollectionsFullTable/CollectionName.test.tsx b/resources/js/Components/Collections/CollectionsFullTable/CollectionName.test.tsx deleted file mode 100644 index a5145534b..000000000 --- a/resources/js/Components/Collections/CollectionsFullTable/CollectionName.test.tsx +++ /dev/null @@ -1,16 +0,0 @@ -import React from "react"; -import { CollectionName } from "@/Components/Collections/CollectionsFullTable/CollectionName"; -import CollectionFactory from "@/Tests/Factories/Collections/CollectionFactory"; -import { render, screen } from "@/Tests/testing-library"; - -describe("CollectionName", () => { - it("should render", () => { - const collection = new CollectionFactory().create(); - - render(); - - expect(screen.getByTestId("CollectionName")).toBeInTheDocument(); - expect(screen.getAllByTestId("Img")).toHaveLength(1); - expect(screen.getByTestId("NetworkIcon")).toBeInTheDocument(); - }); -}); diff --git a/resources/js/Components/Collections/CollectionsFullTable/CollectionName.tsx b/resources/js/Components/Collections/CollectionsFullTable/CollectionName.tsx deleted file mode 100644 index bcf1cd7f7..000000000 --- a/resources/js/Components/Collections/CollectionsFullTable/CollectionName.tsx +++ /dev/null @@ -1,53 +0,0 @@ -import { useRef } from "react"; -import { useTranslation } from "react-i18next"; -import { Img } from "@/Components/Image"; -import { NetworkIcon } from "@/Components/Networks/NetworkIcon"; -import { Tooltip } from "@/Components/Tooltip"; -import { useIsTruncated } from "@/Hooks/useIsTruncated"; - -export const CollectionName = ({ collection }: { collection: App.Data.Collections.CollectionData }): JSX.Element => { - const { t } = useTranslation(); - const collectionNameReference = useRef(null); - const isTruncated = useIsTruncated({ reference: collectionNameReference }); - - return ( -
-
-
- - -
- -
-
- -
- -

- {collection.name} -

-
- -

- {collection.nftsCount} {t("common.items").toLowerCase()} -

-
-
-
- ); -}; diff --git a/resources/js/Components/Collections/CollectionsFullTable/CollectionsFullTableItem.tsx b/resources/js/Components/Collections/CollectionsFullTable/CollectionsFullTableItem.tsx index be00f6427..57efc26fd 100644 --- a/resources/js/Components/Collections/CollectionsFullTable/CollectionsFullTableItem.tsx +++ b/resources/js/Components/Collections/CollectionsFullTable/CollectionsFullTableItem.tsx @@ -4,7 +4,7 @@ import { useTranslation } from "react-i18next"; import { type CollectionTableItemProperties } from "./CollectionsFullTable.contracts"; import { CollectionFloorPrice } from "@/Components/Collections/CollectionFloorPrice"; import { CollectionImages } from "@/Components/Collections/CollectionImages"; -import { CollectionName } from "@/Components/Collections/CollectionsFullTable/CollectionName"; +import { CollectionName } from "@/Components/Collections/CollectionName"; import { PopularCollectionVolume } from "@/Components/Collections/PopularCollectionsTable/PopularCollectionsTable.blocks"; import { NetworkIcon } from "@/Components/Networks/NetworkIcon"; import { TableCell, TableRow } from "@/Components/Table"; @@ -60,7 +60,9 @@ export const CollectionsFullTableItem = ({ paddingClassName="px-2 md:px-5" hoverClassName="" > - + + {collection.nftsCount} {t("common.items").toLowerCase()} + {isLgAndAbove && ( diff --git a/resources/js/Components/Collections/CollectionsTable/CollectionsTableItem.tsx b/resources/js/Components/Collections/CollectionsTable/CollectionsTableItem.tsx index 110b505a6..01b1b2e80 100644 --- a/resources/js/Components/Collections/CollectionsTable/CollectionsTableItem.tsx +++ b/resources/js/Components/Collections/CollectionsTable/CollectionsTableItem.tsx @@ -72,10 +72,9 @@ export const CollectionsTableItem = ({ paddingClassName="px-2 md:px-5" hoverClassName="" > - + + {collection.nftsCount} {t("common.owned")} + {isLgAndAbove && (