diff --git a/comps/custom/Breadcrumb.tsx b/comps/custom/Breadcrumb.tsx index 9bb3969..4c18207 100755 --- a/comps/custom/Breadcrumb.tsx +++ b/comps/custom/Breadcrumb.tsx @@ -1,6 +1,7 @@ import { useLocal } from "@/utils/use-local"; import { FC, ReactNode, useEffect } from "react"; import { FieldLoading } from "../ui/field-loading"; +import { ChevronLeft } from "lucide-react"; export type BreadItem = { label: React.ReactNode; @@ -39,10 +40,13 @@ export const Breadcrumb: FC = ({ value, className }) => { local.value = value; } + const list = Array.isArray(local.value) ? local.value : []; + return (
@@ -53,50 +57,79 @@ export const Breadcrumb: FC = ({ value, className }) => { {(!local.value || local.value.length === 0) && isEditor && "Breadcrumb"} - {(Array.isArray(local.value) ? local.value : []).map( - (cur, index): ReactNode => { - const lastIndex = (local.value || []).length - 1; + {isDesktop && ( + <> + {list.map((cur, index): ReactNode => { + const lastIndex = (local.value || []).length - 1; - return ( - <> - {index === lastIndex ? ( -

- {cur?.label} -

- ) : ( -

{ - if (isEditor) return; - if (cur.url) navigate(cur.url || ""); - if (cur.onClick) cur.onClick(ev); - }} - > - {cur?.label} -

- )} - - {index !== lastIndex && ( -
- + {index === lastIndex ? ( +

+ {cur?.label} +

+ ) : ( +

{ + if (isEditor) return; + if (cur.url) navigate(cur.url || ""); + if (cur.onClick) cur.onClick(ev); + }} > - - -

- )} - - ); - } + {cur?.label} + + )} + + {index !== lastIndex && ( +
+ + + +
+ )} + + ); + })} + + )} + {isMobile && ( + <> + {list.length > 1 && ( +
+
{ + const cur = list[list.length - 2]; + if (isEditor) return; + if (cur.url) navigate(cur.url || ""); + if (cur.onClick) cur.onClick(ev); + }} + > + +
+

+ {list[list.length - 1].label} +

+
+ )} + {list.length === 1 && ( +

+ {list[0].label} +

+ )} + )} )}