diff --git a/app/components/Breadcrumb/Breadcrumb.tsx b/app/components/Breadcrumb/Breadcrumb.tsx new file mode 100644 index 00000000..2a3de336 --- /dev/null +++ b/app/components/Breadcrumb/Breadcrumb.tsx @@ -0,0 +1,35 @@ +import React from "react"; +import BreadcrumbItem from "./BreadcrumbItem"; +import BreadcrumbSeparator from "./BreadcrumbSeparator"; + +interface Page { + name: string; + link: string; +} + +interface BreadcrumbProperties { + pages: Page[]; +} + +const Breadcrumb: React.FC = ({ pages }) => { + return ( + + ); +}; + +export default Breadcrumb; diff --git a/app/components/Breadcrumb/BreadcrumbItem.tsx b/app/components/Breadcrumb/BreadcrumbItem.tsx new file mode 100644 index 00000000..89fbcab9 --- /dev/null +++ b/app/components/Breadcrumb/BreadcrumbItem.tsx @@ -0,0 +1,39 @@ +import { Link } from "@remix-run/react"; +import React from "react"; + +interface BreadcrumbItemProperties { + name: string; + link: string; + isCurrent: boolean; +} + +const BreadcrumbItem: React.FC = ({ + name, + link, + isCurrent, +}) => { + const commonStyles = "text-[#222] font-roboto text-xs font-normal leading-4"; + const itemStyles = "flex items-center py-1"; + const marginRight = isCurrent ? "" : "mr-2"; + + if (isCurrent) { + return ( + + {name} + + ); + } + + return ( + + {name} + + ); +}; + +export default BreadcrumbItem; diff --git a/app/components/Breadcrumb/BreadcrumbProvider.tsx b/app/components/Breadcrumb/BreadcrumbProvider.tsx new file mode 100644 index 00000000..8ae5f561 --- /dev/null +++ b/app/components/Breadcrumb/BreadcrumbProvider.tsx @@ -0,0 +1,24 @@ +import { useLocation } from "@remix-run/react"; +import React from "react"; +import Breadcrumb from "./Breadcrumb"; + +const BreadcrumbProvider: React.FC = () => { + const location = useLocation(); + const pathnames = location.pathname.split("/").filter(Boolean); + + const breadcrumbPages = pathnames.map((pathname: string, index: number) => { + const link = `/${pathnames.slice(0, index + 1).join("/")}`; + return { + name: pathname.charAt(0).toUpperCase() + pathname.slice(1), + link, + }; + }); + breadcrumbPages.unshift({ + name: "Home", + link: "/", + }); + + return ; +}; + +export default BreadcrumbProvider; diff --git a/app/components/Breadcrumb/BreadcrumbSeparator.tsx b/app/components/Breadcrumb/BreadcrumbSeparator.tsx new file mode 100644 index 00000000..02c161a5 --- /dev/null +++ b/app/components/Breadcrumb/BreadcrumbSeparator.tsx @@ -0,0 +1,18 @@ +import React from "react"; + +const BreadcrumbSeparator: React.FC = () => ( + + + +); + +export default BreadcrumbSeparator; \ No newline at end of file diff --git a/app/components/Breadcrumb/index.ts b/app/components/Breadcrumb/index.ts new file mode 100644 index 00000000..4b2d0bad --- /dev/null +++ b/app/components/Breadcrumb/index.ts @@ -0,0 +1,2 @@ +export { default as Breadcrumb } from "./Breadcrumb"; +export { default as BreadcrumbItem } from "./BreadcrumbItem";